@ota-meshi/eslint-plugin 0.10.1 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/configs/+eslint-plugin.js +81 -84
- package/lib/configs/+json.js +17 -17
- package/lib/configs/+md.js +16 -16
- package/lib/configs/+node.js +31 -28
- package/lib/configs/+package-json.js +14 -14
- package/lib/configs/+prettier.js +56 -67
- package/lib/configs/+toml.js +14 -14
- package/lib/configs/+typescript.js +150 -144
- package/lib/configs/+vue2.js +26 -26
- package/lib/configs/+vue3.js +26 -26
- package/lib/configs/+yaml.js +21 -21
- package/lib/configs/base-plugins/eslint-comments.js +10 -10
- package/lib/configs/base-plugins/regexp.js +13 -13
- package/lib/configs/json-schema/config.js +33 -33
- package/lib/configs/recommended.js +254 -246
- package/lib/configs/ts/index.js +15 -15
- package/lib/index.js +29 -29
- package/lib/rules/missing-module-for-config.js +57 -67
- package/lib/utils/find-root-dir.js +15 -15
- package/lib/utils/get-linters.js +22 -22
- package/lib/utils/module.js +48 -51
- package/package.json +56 -57
|
@@ -1,86 +1,83 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const path = require("path")
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
5
|
module.exports = require("../utils/module").requireOf(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
rules: {
|
|
17
|
-
"eslint-plugin/consistent-output": "error",
|
|
18
|
-
"eslint-plugin/meta-property-ordering": [
|
|
19
|
-
"error",
|
|
20
|
-
[
|
|
21
|
-
"deprecated",
|
|
22
|
-
"docs",
|
|
23
|
-
"fixable",
|
|
24
|
-
"messages",
|
|
25
|
-
"replacedBy",
|
|
26
|
-
"schema",
|
|
27
|
-
"type",
|
|
28
|
-
],
|
|
29
|
-
],
|
|
30
|
-
"eslint-plugin/no-deprecated-context-methods": "error",
|
|
31
|
-
"eslint-plugin/prefer-output-null": "error",
|
|
32
|
-
"eslint-plugin/prefer-placeholders": "error",
|
|
33
|
-
"eslint-plugin/prefer-replace-text": "error",
|
|
34
|
-
"eslint-plugin/report-message-format": [
|
|
35
|
-
"error",
|
|
36
|
-
"[^a-z'\"{].*\\.$",
|
|
37
|
-
],
|
|
38
|
-
"eslint-plugin/require-meta-docs-description": "error",
|
|
39
|
-
"eslint-plugin/require-meta-docs-url": [
|
|
40
|
-
"error",
|
|
41
|
-
{ pattern: rulesDocumentUrl() },
|
|
42
|
-
],
|
|
43
|
-
"eslint-plugin/require-meta-fixable": "error",
|
|
44
|
-
"eslint-plugin/require-meta-schema": "error",
|
|
45
|
-
"eslint-plugin/require-meta-type": "error",
|
|
46
|
-
"eslint-plugin/test-case-property-ordering": [
|
|
47
|
-
"error",
|
|
48
|
-
[
|
|
49
|
-
"filename",
|
|
50
|
-
"code",
|
|
51
|
-
"output",
|
|
52
|
-
"options",
|
|
53
|
-
"parser",
|
|
54
|
-
"parserOptions",
|
|
55
|
-
"globals",
|
|
56
|
-
"env",
|
|
57
|
-
"errors",
|
|
58
|
-
],
|
|
59
|
-
],
|
|
60
|
-
"eslint-plugin/test-case-shorthand-strings": "error",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
6
|
+
["eslint-plugin-eslint-plugin"],
|
|
7
|
+
() => ({
|
|
8
|
+
plugins: ["eslint-plugin"],
|
|
9
|
+
overrides: [
|
|
10
|
+
{
|
|
11
|
+
files: ["**/rules/**", "**/internal-rules/**"],
|
|
12
|
+
extends: [
|
|
13
|
+
require.resolve("./+node"),
|
|
14
|
+
"plugin:eslint-plugin/recommended",
|
|
63
15
|
],
|
|
64
|
-
|
|
65
|
-
|
|
16
|
+
rules: {
|
|
17
|
+
"eslint-plugin/consistent-output": "error",
|
|
18
|
+
"eslint-plugin/meta-property-ordering": [
|
|
19
|
+
"error",
|
|
20
|
+
[
|
|
21
|
+
"deprecated",
|
|
22
|
+
"docs",
|
|
23
|
+
"fixable",
|
|
24
|
+
"messages",
|
|
25
|
+
"replacedBy",
|
|
26
|
+
"schema",
|
|
27
|
+
"type",
|
|
28
|
+
],
|
|
29
|
+
],
|
|
30
|
+
"eslint-plugin/no-deprecated-context-methods": "error",
|
|
31
|
+
"eslint-plugin/prefer-output-null": "error",
|
|
32
|
+
"eslint-plugin/prefer-placeholders": "error",
|
|
33
|
+
"eslint-plugin/prefer-replace-text": "error",
|
|
34
|
+
"eslint-plugin/report-message-format": ["error", "[^a-z'\"{].*\\.$"],
|
|
35
|
+
"eslint-plugin/require-meta-docs-description": "error",
|
|
36
|
+
"eslint-plugin/require-meta-docs-url": [
|
|
37
|
+
"error",
|
|
38
|
+
{ pattern: rulesDocumentUrl() },
|
|
39
|
+
],
|
|
40
|
+
"eslint-plugin/require-meta-fixable": "error",
|
|
41
|
+
"eslint-plugin/require-meta-schema": "error",
|
|
42
|
+
"eslint-plugin/require-meta-type": "error",
|
|
43
|
+
"eslint-plugin/test-case-property-ordering": [
|
|
44
|
+
"error",
|
|
45
|
+
[
|
|
46
|
+
"filename",
|
|
47
|
+
"code",
|
|
48
|
+
"output",
|
|
49
|
+
"options",
|
|
50
|
+
"parser",
|
|
51
|
+
"parserOptions",
|
|
52
|
+
"globals",
|
|
53
|
+
"env",
|
|
54
|
+
"errors",
|
|
55
|
+
],
|
|
56
|
+
],
|
|
57
|
+
"eslint-plugin/test-case-shorthand-strings": "error",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
);
|
|
66
63
|
|
|
67
64
|
/**
|
|
68
65
|
* The URL of rule's documentation for the `+eslint-plugin` config.
|
|
69
66
|
* @type {string}
|
|
70
67
|
*/
|
|
71
68
|
function rulesDocumentUrl() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
} catch (_error) {
|
|
81
|
-
// ignore
|
|
69
|
+
try {
|
|
70
|
+
const { version, repository } = JSON.parse(
|
|
71
|
+
fs.readFileSync(path.join(process.cwd(), "package.json"), "utf8")
|
|
72
|
+
);
|
|
73
|
+
const baseUrl = getBaseUrl(repository);
|
|
74
|
+
if (baseUrl) {
|
|
75
|
+
return `${baseUrl}/blob/v${version}/docs/rules/{{name}}.md`;
|
|
82
76
|
}
|
|
83
|
-
|
|
77
|
+
} catch (_error) {
|
|
78
|
+
// ignore
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
/**
|
|
@@ -89,16 +86,16 @@ function rulesDocumentUrl() {
|
|
|
89
86
|
* @returns {string|null} The base URL.
|
|
90
87
|
*/
|
|
91
88
|
function getBaseUrl(repository) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
if (typeof repository === "string") {
|
|
90
|
+
return `https://github.com/${repository}`;
|
|
91
|
+
}
|
|
92
|
+
if (
|
|
93
|
+
repository &&
|
|
94
|
+
typeof repository.url === "string" &&
|
|
95
|
+
/^git\+.+\.git$/u.test(repository.url)
|
|
96
|
+
) {
|
|
97
|
+
return repository.url.slice(4, -4);
|
|
98
|
+
}
|
|
102
99
|
|
|
103
|
-
|
|
100
|
+
return null;
|
|
104
101
|
}
|
package/lib/configs/+json.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
],
|
|
13
|
-
rules: {
|
|
14
|
-
"jsonc/auto": "error",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
4
|
+
["eslint-plugin-jsonc"],
|
|
5
|
+
() => ({
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["*.json", "*.json5"],
|
|
9
|
+
extends: [
|
|
10
|
+
"plugin:jsonc/recommended-with-jsonc",
|
|
11
|
+
require.resolve("./json-schema/config"),
|
|
17
12
|
],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
rules: {
|
|
14
|
+
"jsonc/auto": "error",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}),
|
|
19
|
+
{ files: ["*.json", "*.json5"] }
|
|
20
|
+
);
|
package/lib/configs/+md.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
4
|
+
["eslint-plugin-markdown"],
|
|
5
|
+
() => ({
|
|
6
|
+
extends: ["plugin:markdown/recommended"],
|
|
7
|
+
rules: {},
|
|
8
|
+
overrides: [
|
|
9
|
+
{
|
|
10
|
+
files: ["**/*.md/*.js"],
|
|
11
|
+
rules: {
|
|
12
|
+
strict: "off",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
}),
|
|
17
|
+
{ files: ["*.md"] }
|
|
18
|
+
);
|
package/lib/configs/+node.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
4
|
+
["eslint-plugin-node"],
|
|
5
|
+
() => ({
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["*.js", "*.mjs", "*.cjs"],
|
|
9
|
+
extends: ["plugin:node/recommended"],
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaFeatures: { globalReturn: true },
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
sourceType: "script",
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"node/exports-style": ["error", "module.exports"],
|
|
17
|
+
"node/file-extension-in-import": [
|
|
18
|
+
"error",
|
|
19
|
+
"always",
|
|
20
|
+
{ ".js": "never", ".ts": "never", ".tsx": "never" },
|
|
21
|
+
],
|
|
22
|
+
"node/prefer-global/buffer": "error",
|
|
23
|
+
"node/prefer-global/console": "error",
|
|
24
|
+
"node/prefer-global/process": "error",
|
|
25
|
+
},
|
|
26
|
+
globals: {
|
|
27
|
+
URL: "readonly",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}),
|
|
32
|
+
{ files: ["*.js", "*.mjs", "*.cjs"] }
|
|
33
|
+
);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
],
|
|
13
|
-
},
|
|
4
|
+
["eslint-plugin-node-dependencies"],
|
|
5
|
+
() => ({
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["package.json"],
|
|
9
|
+
extends: [
|
|
10
|
+
"plugin:node-dependencies/recommended",
|
|
11
|
+
require.resolve("./+json"),
|
|
14
12
|
],
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
}),
|
|
16
|
+
{ files: ["package.json"] }
|
|
17
|
+
);
|
package/lib/configs/+prettier.js
CHANGED
|
@@ -1,75 +1,64 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/** @param {string} config */
|
|
4
4
|
function getConfigArrayIfHasConfig(config) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
try {
|
|
6
|
+
const configPath = require.resolve(`eslint-config-${config}`);
|
|
7
|
+
require(configPath);
|
|
8
|
+
} catch (_e) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return [config];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
module.exports = require("../utils/module").requireOf(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"jsonc/array-bracket-newline": "off",
|
|
39
|
-
"jsonc/array-element-newline": "off",
|
|
40
|
-
"jsonc/comma-style": "off",
|
|
41
|
-
"jsonc/indent": "off",
|
|
42
|
-
"jsonc/key-spacing": "off",
|
|
43
|
-
"jsonc/object-curly-spacing": "off",
|
|
44
|
-
"jsonc/object-curly-newline": "off",
|
|
45
|
-
"jsonc/object-property-newline": "off",
|
|
46
|
-
"jsonc/quote-props": "off",
|
|
47
|
-
"jsonc/quotes": "off",
|
|
48
|
-
"jsonc/space-unary-ops": "off",
|
|
15
|
+
["eslint-plugin-prettier", "eslint-config-prettier", "prettier"],
|
|
16
|
+
() => ({
|
|
17
|
+
plugins: ["prettier"],
|
|
18
|
+
extends: [
|
|
19
|
+
"prettier",
|
|
20
|
+
...getConfigArrayIfHasConfig("prettier/@typescript-eslint"),
|
|
21
|
+
...getConfigArrayIfHasConfig("prettier/react"),
|
|
22
|
+
...getConfigArrayIfHasConfig("prettier/vue"),
|
|
23
|
+
],
|
|
24
|
+
rules: {
|
|
25
|
+
"prettier/prettier": "error",
|
|
26
|
+
"jsonc/array-bracket-spacing": "off",
|
|
27
|
+
"jsonc/array-bracket-newline": "off",
|
|
28
|
+
"jsonc/array-element-newline": "off",
|
|
29
|
+
"jsonc/comma-style": "off",
|
|
30
|
+
"jsonc/indent": "off",
|
|
31
|
+
"jsonc/key-spacing": "off",
|
|
32
|
+
"jsonc/object-curly-spacing": "off",
|
|
33
|
+
"jsonc/object-curly-newline": "off",
|
|
34
|
+
"jsonc/object-property-newline": "off",
|
|
35
|
+
"jsonc/quote-props": "off",
|
|
36
|
+
"jsonc/quotes": "off",
|
|
37
|
+
"jsonc/space-unary-ops": "off",
|
|
49
38
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
"yml/block-mapping-question-indicator-newline": "off",
|
|
40
|
+
"yml/block-sequence-hyphen-indicator-newline": "off",
|
|
41
|
+
"yml/indent": "off",
|
|
42
|
+
"yml/flow-mapping-curly-newline": "off",
|
|
43
|
+
"yml/flow-mapping-curly-spacing": "off",
|
|
44
|
+
"yml/flow-sequence-bracket-newline": "off",
|
|
45
|
+
"yml/flow-sequence-bracket-spacing": "off",
|
|
46
|
+
"yml/key-spacing": "off",
|
|
47
|
+
"yml/spaced-comment": "off",
|
|
48
|
+
},
|
|
49
|
+
overrides: [
|
|
50
|
+
{
|
|
51
|
+
files: ["**/*.md/*.*"],
|
|
52
|
+
rules: {
|
|
53
|
+
"prettier/prettier": "off",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ["**/*.toml"],
|
|
58
|
+
rules: {
|
|
59
|
+
"prettier/prettier": "off",
|
|
59
60
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"prettier/prettier": "off",
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
files: ["**/*.toml"],
|
|
69
|
-
rules: {
|
|
70
|
-
"prettier/prettier": "off",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
}),
|
|
75
|
-
)
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
})
|
|
64
|
+
);
|
package/lib/configs/+toml.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
4
|
+
[],
|
|
5
|
+
() => ({
|
|
6
|
+
extends: ["plugin:toml/standard"],
|
|
7
|
+
rules: {},
|
|
8
|
+
overrides: [
|
|
9
|
+
{
|
|
10
|
+
files: ["*.toml"],
|
|
11
|
+
extends: [require.resolve("./json-schema/config")],
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
}),
|
|
15
|
+
{ files: ["*.toml"] }
|
|
16
|
+
);
|