11// LICENSE : MIT
22"use strict" ;
33import { RuleHelper , IgnoreNodeManager } from "textlint-rule-helper" ;
4- const StringSource = require ( "textlint-util-to-string" ) . default ;
4+ const StringSource = require ( "textlint-util-to-string" ) ;
55const rousseau = require ( "rousseau" ) ;
66const map = require ( "unist-util-map" ) ;
7- const ObjectAssign = require ( "object-assign" ) ;
87const defaultOptions = {
98 // "suggestion", "warning", "error"
109 showLevels : [ "suggestion" , "warning" , "error" ] ,
@@ -16,7 +15,7 @@ const defaultOptions = {
1615
1716const mapNode = function ( ast , mapFn ) {
1817 return ( function preorder ( node , index , parent ) {
19- const newNode = ObjectAssign ( { } , mapFn ( node , index , parent ) ) ;
18+ const newNode = Object . assign ( { } , mapFn ( node , index , parent ) ) ;
2019 if ( node . children ) {
2120 newNode . children = node . children . map ( function ( child , index ) {
2221 return preorder ( child , index , node ) ;
@@ -26,43 +25,43 @@ const mapNode = function (ast, mapFn) {
2625 } ( ast , null , null ) ) ;
2726} ;
2827
29- export default function textlintRousseau ( context , options = defaultOptions ) {
28+ module . exports = function textlintRousseau ( context , options = defaultOptions ) {
3029 const helper = new RuleHelper ( context ) ;
3130 const ignoreNodeManager = new IgnoreNodeManager ( ) ;
3231 const { Syntax, RuleError, report, getSource} = context ;
3332 const showLevels = options . showLevels || defaultOptions . showLevels ;
3433 const ignoreTypes = options . ignoreTypes || defaultOptions . ignoreTypes ;
3534 const ignoreInlineNodeTypes = options . ignoreInlineNodeTypes || [ Syntax . Code ] ;
36- const isShowType = ( type ) => {
35+ const isShowType = ( type ) => {
3736 return ignoreTypes . indexOf ( type ) === - 1 ;
3837 } ;
3938 const isShowLevel = ( level ) => {
4039 return showLevels . indexOf ( level ) !== - 1 ;
4140 } ;
4241 /*
4342 {
44- // Type of check that output this suggestion
45- type: "so",
43+ // Type of check that output this suggestion
44+ type: "so",
4645
47- // Level of importance
48- // "suggestion", "warning", "error"
49- level: "warning",
46+ // Level of importance
47+ // "suggestion", "warning", "error"
48+ level: "warning",
5049
51- // Index in the text
52- index: 10,
50+ // Index in the text
51+ index: 10,
5352
54- // Size of the section in the text
55- offset: 2,
53+ // Size of the section in the text
54+ offset: 2,
5655
57- // Message to describe the suggestion
58- message: "omit 'So' from the beginning of sentences",
56+ // Message to describe the suggestion
57+ message: "omit 'So' from the beginning of sentences",
5958
60- // Replacements suggestion
61- replacements: [
62- {
63- value: ""
64- }
65- ]
59+ // Replacements suggestion
60+ replacements: [
61+ {
62+ value: ""
63+ }
64+ ]
6665 }
6766 */
6867 const createSuggest = ( replacements ) => {
@@ -97,7 +96,7 @@ export default function textlintRousseau(context, options = defaultOptions) {
9796 } ;
9897
9998 return {
100- [ Syntax . Paragraph ] ( node ) {
99+ [ Syntax . Paragraph ] ( node ) {
101100 // ignore if wrapped node types
102101 if ( helper . isChildNode ( node , [ Syntax . Link , Syntax . Image , Syntax . BlockQuote , Syntax . Emphasis ] ) ) {
103102 return ;
@@ -110,7 +109,7 @@ export default function textlintRousseau(context, options = defaultOptions) {
110109 const filteredNode = map ( node , ( node ) => {
111110 if ( node . type === Syntax . Code ) {
112111 // only change `value` to dummy
113- return ObjectAssign ( { } , node , {
112+ return Object . assign ( { } , node , {
114113 value : new Array ( node . value . length + 1 ) . join ( "x" )
115114 } ) ;
116115 }
@@ -132,4 +131,4 @@ export default function textlintRousseau(context, options = defaultOptions) {
132131 } ) ;
133132 }
134133 }
135- }
134+ } ;
0 commit comments