File tree Expand file tree Collapse file tree 21 files changed +99
-86
lines changed Expand file tree Collapse file tree 21 files changed +99
-86
lines changed Original file line number Diff line number Diff line change 1
1
extends :
2
- - plugin:@mysticatea/es2015
3
- - plugin:@mysticatea/+eslint-plugin
2
+ - plugin:@eslint-community/ mysticatea/es2015
3
+ - plugin:@eslint-community/ mysticatea/+eslint-plugin
4
4
5
5
overrides :
6
6
- files : " docs/.vuepress/components/*.vue"
@@ -9,6 +9,15 @@ overrides:
9
9
10
10
- files : " lib/rules/*.js"
11
11
rules :
12
- " @mysticatea/eslint-plugin/require-meta-docs-url " :
12
+ " @eslint-community/ mysticatea/eslint-plugin/require-meta-docs-url " :
13
13
- error
14
14
- pattern : " https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/{{name}}.html"
15
+
16
+ - files : ["lib/configs.js", "lib/rules.js", "lib/utils.js"]
17
+ rules :
18
+ " @eslint-community/mysticatea/node/global-require " : off
19
+
20
+ - files : ["tests/**/*.js", "scripts/**/*.js"]
21
+ rules :
22
+ " @eslint-community/mysticatea/node/global-require " : off
23
+ " @eslint-community/mysticatea/node/no-sync " : off
Original file line number Diff line number Diff line change @@ -10,13 +10,14 @@ const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}`
10
10
module . exports = ( ) => {
11
11
const eslintPaths = new Set (
12
12
Object . keys ( require . cache )
13
- . filter ( id => id . includes ( needle ) )
14
- . map ( id => id . slice ( 0 , id . indexOf ( needle ) + needle . length ) )
13
+ . filter ( ( id ) => id . includes ( needle ) )
14
+ . map ( ( id ) => id . slice ( 0 , id . indexOf ( needle ) + needle . length ) )
15
15
)
16
16
const linters = [ ]
17
17
18
18
for ( const eslintPath of eslintPaths ) {
19
19
try {
20
+ // eslint-disable-next-line @eslint-community/mysticatea/node/global-require
20
21
const linter = require ( eslintPath ) . Linter
21
22
22
23
if ( linter ) {
Original file line number Diff line number Diff line change 7
7
const escapeStringRegexp = require ( "escape-string-regexp" )
8
8
const LINE_PATTERN = / [ ^ \r \n \u2028 \u2029 ] * (?: \r \n | [ \r \n \u2028 \u2029 ] | $ ) / gu
9
9
10
- const DIRECTIVE_PATTERN = / ^ ( e s l i n t (?: - e n v | - e n a b l e | - d i s a b l e (?: (?: - n e x t ) ? - l i n e ) ? ) ? | e x p o r t e d | g l o b a l s ? ) (?: \s | $ ) / u
10
+ const DIRECTIVE_PATTERN =
11
+ / ^ ( e s l i n t (?: - e n v | - e n a b l e | - d i s a b l e (?: (?: - n e x t ) ? - l i n e ) ? ) ? | e x p o r t e d | g l o b a l s ? ) (?: \s | $ ) / u
11
12
const LINE_COMMENT_PATTERN = / ^ e s l i n t - d i s a b l e - ( n e x t - ) ? l i n e $ / u
12
13
13
14
module . exports = {
Original file line number Diff line number Diff line change @@ -14,10 +14,14 @@ module.exports = {
14
14
"require a `eslint-enable` comment for every `eslint-disable` comment" ,
15
15
category : "Best Practices" ,
16
16
recommended : true ,
17
- url :
18
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html" ,
17
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html" ,
19
18
} ,
20
19
fixable : null ,
20
+ messages : {
21
+ missingPair : "Requires 'eslint-enable' directive." ,
22
+ missingRulePair :
23
+ "Requires 'eslint-enable' directive for '{{ruleId}}'." ,
24
+ } ,
21
25
schema : [
22
26
{
23
27
type : "object" ,
@@ -57,9 +61,9 @@ module.exports = {
57
61
58
62
context . report ( {
59
63
loc : utils . toRuleIdLocation ( area . comment , area . ruleId ) ,
60
- message : area . ruleId
61
- ? "Requires 'eslint-enable' directive for '{{ruleId}}'. "
62
- : "Requires 'eslint-enable' directive. " ,
64
+ messageId : area . ruleId
65
+ ? "missingRulePair "
66
+ : "missingPair " ,
63
67
data : area ,
64
68
} )
65
69
}
Original file line number Diff line number Diff line change @@ -14,10 +14,13 @@ module.exports = {
14
14
"disallow a `eslint-enable` comment for multiple `eslint-disable` comments" ,
15
15
category : "Best Practices" ,
16
16
recommended : true ,
17
- url :
18
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html" ,
17
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html" ,
19
18
} ,
20
19
fixable : null ,
20
+ messages : {
21
+ aggregatingEnable :
22
+ "This `eslint-enable` comment affects {{count}} `eslint-disable` comments. An `eslint-enable` comment should be for an `eslint-disable` comment." ,
23
+ } ,
21
24
schema : [ ] ,
22
25
type : "suggestion" ,
23
26
} ,
@@ -35,8 +38,7 @@ module.exports = {
35
38
if ( count >= 2 ) {
36
39
context . report ( {
37
40
loc : utils . toForceLocation ( comment . loc ) ,
38
- message :
39
- "This `eslint-enable` comment affects {{count}} `eslint-disable` comments. An `eslint-enable` comment should be for an `eslint-disable` comment." ,
41
+ messageId : "aggregatingEnable" ,
40
42
data : { count } ,
41
43
} )
42
44
}
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ module.exports = {
13
13
description : "disallow duplicate `eslint-disable` comments" ,
14
14
category : "Best Practices" ,
15
15
recommended : true ,
16
- url :
17
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html" ,
16
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html" ,
18
17
} ,
19
18
fixable : null ,
19
+ messages : {
20
+ duplicate : "ESLint rules have been disabled already." ,
21
+ duplicateRule : "'{{ruleId}}' rule has been disabled already." ,
22
+ } ,
20
23
schema : [ ] ,
21
24
type : "problem" ,
22
25
} ,
@@ -30,9 +33,7 @@ module.exports = {
30
33
for ( const item of disabledArea . duplicateDisableDirectives ) {
31
34
context . report ( {
32
35
loc : utils . toRuleIdLocation ( item . comment , item . ruleId ) ,
33
- message : item . ruleId
34
- ? "'{{ruleId}}' rule has been disabled already."
35
- : "ESLint rules have been disabled already." ,
36
+ messageId : item . ruleId ? "duplicateRule" : "duplicate" ,
36
37
data : item ,
37
38
} )
38
39
}
Original file line number Diff line number Diff line change @@ -15,10 +15,12 @@ module.exports = {
15
15
"disallow `eslint-disable` comments about specific rules" ,
16
16
category : "Stylistic Issues" ,
17
17
recommended : false ,
18
- url :
19
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html" ,
18
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html" ,
20
19
} ,
21
20
fixable : null ,
21
+ messages : {
22
+ disallow : "Disabling '{{ruleId}}' is not allowed." ,
23
+ } ,
22
24
schema : {
23
25
type : "array" ,
24
26
items : { type : "string" } ,
@@ -49,7 +51,7 @@ module.exports = {
49
51
area . comment ,
50
52
area . ruleId
51
53
) ,
52
- message : "Disabling '{{ruleId}}' is not allowed. " ,
54
+ messageId : "disallow " ,
53
55
data : {
54
56
ruleId : area . ruleId || String ( context . options ) ,
55
57
} ,
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ module.exports = {
13
13
"disallow `eslint-disable` comments without rule names" ,
14
14
category : "Best Practices" ,
15
15
recommended : true ,
16
- url :
17
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html" ,
16
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html" ,
18
17
} ,
19
18
fixable : null ,
19
+ messages : {
20
+ unexpected :
21
+ "Unexpected unlimited '{{kind}}' comment. Specify some rule names to disable." ,
22
+ } ,
20
23
schema : [ ] ,
21
24
type : "suggestion" ,
22
25
} ,
@@ -27,9 +30,8 @@ module.exports = {
27
30
return {
28
31
Program ( ) {
29
32
for ( const comment of sourceCode . getAllComments ( ) ) {
30
- const directiveComment = utils . parseDirectiveComment (
31
- comment
32
- )
33
+ const directiveComment =
34
+ utils . parseDirectiveComment ( comment )
33
35
if ( directiveComment == null ) {
34
36
continue
35
37
}
@@ -45,8 +47,7 @@ module.exports = {
45
47
if ( ! directiveComment . value ) {
46
48
context . report ( {
47
49
loc : utils . toForceLocation ( comment . loc ) ,
48
- message :
49
- "Unexpected unlimited '{{kind}}' comment. Specify some rule names to disable." ,
50
+ messageId : "unexpected" ,
50
51
data : { kind : directiveComment . kind } ,
51
52
} )
52
53
}
Original file line number Diff line number Diff line change @@ -13,10 +13,11 @@ module.exports = {
13
13
description : "disallow unused `eslint-disable` comments" ,
14
14
category : "Best Practices" ,
15
15
recommended : false ,
16
- url :
17
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html" ,
16
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html" ,
18
17
} ,
19
18
fixable : null ,
19
+ // eslint-disable-next-line @eslint-community/mysticatea/eslint-plugin/prefer-message-ids
20
+ messages : { } ,
20
21
schema : [ ] ,
21
22
type : "problem" ,
22
23
} ,
Original file line number Diff line number Diff line change @@ -13,10 +13,14 @@ module.exports = {
13
13
description : "disallow unused `eslint-enable` comments" ,
14
14
category : "Best Practices" ,
15
15
recommended : true ,
16
- url :
17
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html" ,
16
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html" ,
18
17
} ,
19
18
fixable : null ,
19
+ messages : {
20
+ unused : "ESLint rules are re-enabled but those have not been disabled." ,
21
+ unusedRule :
22
+ "'{{ruleId}}' rule is re-enabled but it has not been disabled." ,
23
+ } ,
20
24
schema : [ ] ,
21
25
type : "problem" ,
22
26
} ,
@@ -30,9 +34,7 @@ module.exports = {
30
34
for ( const item of disabledArea . unusedEnableDirectives ) {
31
35
context . report ( {
32
36
loc : utils . toRuleIdLocation ( item . comment , item . ruleId ) ,
33
- message : item . ruleId
34
- ? "'{{ruleId}}' rule is re-enabled but it has not been disabled."
35
- : "ESLint rules are re-enabled but those have not been disabled." ,
37
+ messageId : item . ruleId ? "unusedRule" : "unused" ,
36
38
data : item ,
37
39
} )
38
40
}
Original file line number Diff line number Diff line change @@ -12,10 +12,12 @@ module.exports = {
12
12
description : "disallow ESLint directive-comments" ,
13
13
category : "Stylistic Issues" ,
14
14
recommended : false ,
15
- url :
16
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-use.html" ,
15
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-use.html" ,
17
16
} ,
18
17
fixable : null ,
18
+ messages : {
19
+ disallow : "Unexpected ESLint directive comment." ,
20
+ } ,
19
21
schema : [
20
22
{
21
23
type : "object" ,
@@ -54,17 +56,16 @@ module.exports = {
54
56
return {
55
57
Program ( ) {
56
58
for ( const comment of sourceCode . getAllComments ( ) ) {
57
- const directiveComment = utils . parseDirectiveComment (
58
- comment
59
- )
59
+ const directiveComment =
60
+ utils . parseDirectiveComment ( comment )
60
61
if ( directiveComment == null ) {
61
62
continue
62
63
}
63
64
64
65
if ( ! allowed . has ( directiveComment . kind ) ) {
65
66
context . report ( {
66
67
loc : utils . toForceLocation ( comment . loc ) ,
67
- message : "Unexpected ESLint directive comment. " ,
68
+ messageId : "disallow " ,
68
69
} )
69
70
}
70
71
}
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ module.exports = {
13
13
"require include descriptions in ESLint directive-comments" ,
14
14
category : "Stylistic Issues" ,
15
15
recommended : false ,
16
- url :
17
- "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/require-description.html" ,
16
+ url : "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/require-description.html" ,
18
17
} ,
19
18
fixable : null ,
19
+ messages : {
20
+ missingDescription :
21
+ "Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary." ,
22
+ } ,
20
23
schema : [
21
24
{
22
25
type : "object" ,
@@ -55,9 +58,8 @@ module.exports = {
55
58
return {
56
59
Program ( ) {
57
60
for ( const comment of sourceCode . getAllComments ( ) ) {
58
- const directiveComment = utils . parseDirectiveComment (
59
- comment
60
- )
61
+ const directiveComment =
62
+ utils . parseDirectiveComment ( comment )
61
63
if ( directiveComment == null ) {
62
64
continue
63
65
}
@@ -67,8 +69,7 @@ module.exports = {
67
69
if ( ! directiveComment . description ) {
68
70
context . report ( {
69
71
loc : utils . toForceLocation ( comment . loc ) ,
70
- message :
71
- "Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary." ,
72
+ messageId : "missingDescription" ,
72
73
} )
73
74
}
74
75
}
Original file line number Diff line number Diff line change 17
17
"ignore" : " ^5.2.4"
18
18
},
19
19
"devDependencies" : {
20
- "@mysticatea /eslint-plugin" : " ^13.0.0 " ,
20
+ "@eslint-community /eslint-plugin-mysticatea " : " ^15.5.1 " ,
21
21
"@types/node" : " ^14.18.36" ,
22
22
"@vuepress/plugin-pwa" : " ^1.9.8" ,
23
23
"babel-eslint" : " ^10.0.1" ,
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ const path = require("path")
12
12
*/
13
13
const rules = fs
14
14
. readdirSync ( path . resolve ( __dirname , "../../lib/rules" ) )
15
- . map ( fileName => path . basename ( fileName , ".js" ) )
16
- . map ( name => {
15
+ . map ( ( fileName ) => path . basename ( fileName , ".js" ) )
16
+ . map ( ( name ) => {
17
17
const meta = require ( `../../lib/rules/${ name } ` ) . meta
18
18
return {
19
19
id : `@eslint-community/eslint-comments/${ name } ` ,
@@ -29,10 +29,10 @@ const rules = fs
29
29
30
30
module . exports = rules
31
31
module . exports . withCategories = [ "Best Practices" , "Stylistic Issues" ] . map (
32
- category => ( {
32
+ ( category ) => ( {
33
33
category,
34
34
rules : rules . filter (
35
- rule => rule . category === category && ! rule . deprecated
35
+ ( rule ) => rule . category === category && ! rule . deprecated
36
36
) ,
37
37
} )
38
38
)
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ function createIndex(dirPath) {
31
31
module.exports = {
32
32
${ fs
33
33
. readdirSync ( dirPath )
34
- . map ( file => path . basename ( file , ".js" ) )
35
- . map ( id => `"${ id } ": require("./${ dirName } /${ id } "),` )
34
+ . map ( ( file ) => path . basename ( file , ".js" ) )
35
+ . map ( ( id ) => `"${ id } ": require("./${ dirName } /${ id } "),` )
36
36
. join ( "\n " ) }
37
37
}
38
38
` )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ for (const rule of rules) {
19
19
if ( rule . deprecated ) {
20
20
headerLines . push (
21
21
`- ⚠️ This rule was **deprecated** and replaced by ${ rule . replacedBy
22
- . map ( id => `[${ id } ](${ id } .md) rule` )
22
+ . map ( ( id ) => `[${ id } ](${ id } .md) rule` )
23
23
. join ( ", " ) } .`
24
24
)
25
25
} else if ( rule . recommended ) {
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ module.exports = {
19
19
plugins: ["@eslint-community/eslint-comments"],
20
20
rules: {
21
21
${ rules
22
- . filter ( rule => rule . recommended )
23
- . map ( rule => `"${ rule . id } ": "error",` )
22
+ . filter ( ( rule ) => rule . recommended )
23
+ . map ( ( rule ) => `"${ rule . id } ": "error",` )
24
24
. join ( "\n " ) }
25
25
},
26
26
}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ for (const dirPath of [
21
21
path . resolve ( __dirname , "../lib/rules" ) ,
22
22
path . resolve ( __dirname , "../lib/utils" ) ,
23
23
] ) {
24
- createIndex ( dirPath ) . then ( content =>
24
+ createIndex ( dirPath ) . then ( ( content ) =>
25
25
fs . writeFileSync ( `${ dirPath } .js` , content )
26
26
)
27
27
}
You can’t perform that action at this time.
0 commit comments