@ota-meshi/eslint-plugin 0.7.1 → 0.9.0
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/+json.js +8 -5
- package/lib/configs/+md.js +1 -0
- package/lib/configs/+node.js +1 -0
- package/lib/configs/+package-json.js +17 -0
- package/lib/configs/+prettier.js +1 -5
- package/lib/configs/+toml.js +14 -10
- package/lib/configs/+typescript.js +13 -9
- package/lib/configs/+vue2.js +16 -10
- package/lib/configs/+vue3.js +16 -10
- package/lib/configs/+yaml.js +13 -5
- package/lib/configs/base-plugins/regexp.js +3 -27
- package/lib/configs/ts/index.js +17 -0
- package/lib/index.js +1 -0
- package/lib/utils/module.js +31 -3
- package/package.json +7 -6
package/lib/configs/+json.js
CHANGED
|
@@ -3,15 +3,18 @@
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
4
|
["eslint-plugin-jsonc"],
|
|
5
5
|
() => ({
|
|
6
|
-
extends: ["plugin:jsonc/recommended-with-jsonc"],
|
|
7
|
-
rules: {
|
|
8
|
-
"jsonc/auto": "error",
|
|
9
|
-
},
|
|
10
6
|
overrides: [
|
|
11
7
|
{
|
|
12
8
|
files: ["*.json", "*.json5"],
|
|
13
|
-
extends: [
|
|
9
|
+
extends: [
|
|
10
|
+
"plugin:jsonc/recommended-with-jsonc",
|
|
11
|
+
require.resolve("./json-schema/config"),
|
|
12
|
+
],
|
|
13
|
+
rules: {
|
|
14
|
+
"jsonc/auto": "error",
|
|
15
|
+
},
|
|
14
16
|
},
|
|
15
17
|
],
|
|
16
18
|
}),
|
|
19
|
+
{ files: ["*.json", "*.json5"] },
|
|
17
20
|
)
|
package/lib/configs/+md.js
CHANGED
package/lib/configs/+node.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
module.exports = require("../utils/module").requireOf(
|
|
4
|
+
["eslint-plugin-node-dependencies"],
|
|
5
|
+
() => ({
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["package.json"],
|
|
9
|
+
extends: [
|
|
10
|
+
"plugin:node-dependencies/recommended",
|
|
11
|
+
require.resolve("./+json"),
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
}),
|
|
16
|
+
{ files: ["package.json"] },
|
|
17
|
+
)
|
package/lib/configs/+prettier.js
CHANGED
|
@@ -12,11 +12,7 @@ function getConfigArrayIfHasConfig(config) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
module.exports = require("../utils/module").requireOf(
|
|
15
|
-
[
|
|
16
|
-
// "eslint-plugin-prettier",
|
|
17
|
-
"eslint-config-prettier",
|
|
18
|
-
"prettier",
|
|
19
|
-
],
|
|
15
|
+
["eslint-plugin-prettier", "eslint-config-prettier", "prettier"],
|
|
20
16
|
() => ({
|
|
21
17
|
plugins: ["prettier"],
|
|
22
18
|
extends: [
|
package/lib/configs/+toml.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
-
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
3
|
+
module.exports = require("../utils/module").requireOf(
|
|
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
|
+
)
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
+
const { getProject } = require("./ts")
|
|
3
4
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
[
|
|
5
|
+
[
|
|
6
|
+
"@typescript-eslint/parser",
|
|
7
|
+
"typescript",
|
|
8
|
+
"@typescript-eslint/eslint-plugin",
|
|
9
|
+
],
|
|
5
10
|
() => ({
|
|
6
11
|
overrides: [
|
|
7
12
|
{
|
|
@@ -10,6 +15,7 @@ module.exports = require("../utils/module").requireOf(
|
|
|
10
15
|
parser: require.resolve("@typescript-eslint/parser"),
|
|
11
16
|
parserOptions: {
|
|
12
17
|
sourceType: "module",
|
|
18
|
+
project: getProject(),
|
|
13
19
|
},
|
|
14
20
|
rules: {
|
|
15
21
|
"@typescript-eslint/array-type": "error",
|
|
@@ -137,12 +143,10 @@ module.exports = require("../utils/module").requireOf(
|
|
|
137
143
|
},
|
|
138
144
|
],
|
|
139
145
|
}),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
],
|
|
147
|
-
}),
|
|
146
|
+
{
|
|
147
|
+
files: ["*.ts"],
|
|
148
|
+
fallback: () => ({
|
|
149
|
+
processor: "@ota-meshi/missing-parser",
|
|
150
|
+
}),
|
|
151
|
+
},
|
|
148
152
|
)
|
package/lib/configs/+vue2.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
+
const { getProject } = require("./ts")
|
|
3
4
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
["vue-eslint-parser"],
|
|
5
|
+
["eslint-plugin-vue", "vue-eslint-parser"],
|
|
5
6
|
() => ({
|
|
6
7
|
extends: ["plugin:vue/recommended"],
|
|
7
|
-
parser: "espree",
|
|
8
8
|
overrides: [
|
|
9
9
|
{
|
|
10
10
|
files: ["*.vue"],
|
|
11
11
|
parser: require.resolve("vue-eslint-parser"),
|
|
12
|
+
parserOptions: {
|
|
13
|
+
parser: {
|
|
14
|
+
ts: "@typescript-eslint/parser",
|
|
15
|
+
},
|
|
16
|
+
sourceType: "module",
|
|
17
|
+
project: getProject(),
|
|
18
|
+
extraFileExtensions: [".vue"],
|
|
19
|
+
},
|
|
12
20
|
},
|
|
13
21
|
],
|
|
14
22
|
}),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
}),
|
|
23
|
+
{
|
|
24
|
+
files: ["*.vue"],
|
|
25
|
+
fallback: () => ({
|
|
26
|
+
processor: "@ota-meshi/missing-parser",
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
23
29
|
)
|
package/lib/configs/+vue3.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
+
const { getProject } = require("./ts")
|
|
3
4
|
module.exports = require("../utils/module").requireOf(
|
|
4
|
-
["vue-eslint-parser"],
|
|
5
|
+
["eslint-plugin-vue", "vue-eslint-parser"],
|
|
5
6
|
() => ({
|
|
6
7
|
extends: ["plugin:vue/vue3-recommended"],
|
|
7
|
-
parser: "espree",
|
|
8
8
|
overrides: [
|
|
9
9
|
{
|
|
10
10
|
files: ["*.vue"],
|
|
11
11
|
parser: require.resolve("vue-eslint-parser"),
|
|
12
|
+
parserOptions: {
|
|
13
|
+
parser: {
|
|
14
|
+
ts: "@typescript-eslint/parser",
|
|
15
|
+
},
|
|
16
|
+
sourceType: "module",
|
|
17
|
+
project: getProject(),
|
|
18
|
+
extraFileExtensions: [".vue"],
|
|
19
|
+
},
|
|
12
20
|
},
|
|
13
21
|
],
|
|
14
22
|
}),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
}),
|
|
23
|
+
{
|
|
24
|
+
files: ["*.vue"],
|
|
25
|
+
fallback: () => ({
|
|
26
|
+
processor: "@ota-meshi/missing-parser",
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
23
29
|
)
|
package/lib/configs/+yaml.js
CHANGED
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
module.exports = require("../utils/module").requireOf(
|
|
4
4
|
["eslint-plugin-yml"],
|
|
5
5
|
() => ({
|
|
6
|
-
extends: ["plugin:yml/standard"],
|
|
7
|
-
rules: {
|
|
8
|
-
"yml/require-string-key": "error",
|
|
9
|
-
},
|
|
10
6
|
overrides: [
|
|
11
7
|
{
|
|
12
8
|
files: ["*.yaml", "*.yml"],
|
|
13
|
-
extends: [
|
|
9
|
+
extends: [
|
|
10
|
+
"plugin:yml/standard",
|
|
11
|
+
require.resolve("./json-schema/config"),
|
|
12
|
+
],
|
|
13
|
+
rules: {
|
|
14
|
+
"yml/require-string-key": "error",
|
|
15
|
+
},
|
|
14
16
|
},
|
|
15
17
|
],
|
|
16
18
|
}),
|
|
19
|
+
{
|
|
20
|
+
files: ["*.yaml", "*.yml"],
|
|
21
|
+
fallback: () => ({
|
|
22
|
+
processor: "@ota-meshi/missing-parser",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
17
25
|
)
|
|
@@ -1,39 +1,15 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
3
|
module.exports = require("../../utils/module").requireOf(
|
|
4
|
-
["eslint-plugin-regexp@0.
|
|
4
|
+
["eslint-plugin-regexp@1.0.0"],
|
|
5
5
|
() => ({
|
|
6
6
|
extends: ["plugin:regexp/recommended"],
|
|
7
7
|
rules: {
|
|
8
|
-
|
|
9
|
-
"no-empty-character-class": "error",
|
|
10
|
-
"regexp/negation": "error",
|
|
11
|
-
"regexp/no-legacy-features": "error",
|
|
12
|
-
"regexp/no-unused-capturing-group": "error",
|
|
13
|
-
"regexp/no-useless-character-class": "error",
|
|
14
|
-
"regexp/no-useless-dollar-replacements": "error",
|
|
15
|
-
"regexp/no-useless-escape": "error",
|
|
16
|
-
"regexp/no-useless-non-capturing-group": "error",
|
|
17
|
-
"regexp/no-useless-non-greedy": "error",
|
|
18
|
-
"regexp/no-useless-range": "error",
|
|
19
|
-
"regexp/prefer-character-class": "error",
|
|
20
|
-
"regexp/prefer-escape-replacement-dollar-char": "error",
|
|
21
|
-
"regexp/prefer-range": "error",
|
|
22
|
-
"regexp/prefer-unicode-codepoint-escapes": "error",
|
|
23
|
-
|
|
24
|
-
// others
|
|
25
|
-
"regexp/no-dupe-disjunctions": [
|
|
26
|
-
"error",
|
|
27
|
-
{ disallowNeverMatch: true },
|
|
28
|
-
],
|
|
29
|
-
"regexp/letter-case": [
|
|
30
|
-
"error",
|
|
31
|
-
{ hexadecimalEscape: "lowercase", controlEscape: "uppercase" },
|
|
32
|
-
],
|
|
33
|
-
"regexp/order-in-character-class": "error",
|
|
8
|
+
"regexp/letter-case": ["error"],
|
|
34
9
|
"regexp/prefer-quantifier": "error",
|
|
35
10
|
"regexp/prefer-regexp-exec": "error",
|
|
36
11
|
"regexp/prefer-regexp-test": "error",
|
|
12
|
+
"regexp/sort-character-class-elements": ["error"],
|
|
37
13
|
},
|
|
38
14
|
}),
|
|
39
15
|
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
getProject() {
|
|
5
|
+
let project = undefined
|
|
6
|
+
try {
|
|
7
|
+
project = require("module")
|
|
8
|
+
.createRequire(
|
|
9
|
+
require("path").join(process.cwd(), "__placeholder__.js"),
|
|
10
|
+
)
|
|
11
|
+
.resolve("./tsconfig.json")
|
|
12
|
+
} catch {
|
|
13
|
+
// ignore
|
|
14
|
+
}
|
|
15
|
+
return project
|
|
16
|
+
},
|
|
17
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
"+yaml": require("./configs/+yaml"),
|
|
14
14
|
"+toml": require("./configs/+toml"),
|
|
15
15
|
"+md": require("./configs/+md"),
|
|
16
|
+
"+package-json": require("./configs/+package-json"),
|
|
16
17
|
},
|
|
17
18
|
rules: {
|
|
18
19
|
"missing-module-for-config": require("./rules/missing-module-for-config"),
|
package/lib/utils/module.js
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = {
|
|
|
12
12
|
* @param {string} name
|
|
13
13
|
*/
|
|
14
14
|
function has(name) {
|
|
15
|
-
const parts = name.split(/@/
|
|
15
|
+
const parts = name.split(/@/u)
|
|
16
16
|
if (parts.length > 1 && parts[0]) {
|
|
17
17
|
const v = parts[parts.length - 1]
|
|
18
18
|
try {
|
|
@@ -33,16 +33,44 @@ function has(name) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Checks exists module and return config
|
|
35
35
|
*/
|
|
36
|
-
function requireOf(names, getConfig,
|
|
36
|
+
function requireOf(names, getConfig, fallback) {
|
|
37
37
|
let missings = names.filter((n) => !has(n))
|
|
38
38
|
|
|
39
39
|
if (missings.length) {
|
|
40
|
+
const fb =
|
|
41
|
+
(typeof fallback === "function"
|
|
42
|
+
? {
|
|
43
|
+
fallback,
|
|
44
|
+
}
|
|
45
|
+
: fallback) || {}
|
|
46
|
+
if (fb.fallback) {
|
|
47
|
+
Object.assign(fb, fb.fallback())
|
|
48
|
+
delete fb.fallback
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// getFallback, files
|
|
52
|
+
if (fb.files && fb.files.length) {
|
|
53
|
+
return {
|
|
54
|
+
overrides: [
|
|
55
|
+
{
|
|
56
|
+
plugins: ["@ota-meshi"],
|
|
57
|
+
rules: {
|
|
58
|
+
"@ota-meshi/missing-module-for-config": [
|
|
59
|
+
"error",
|
|
60
|
+
missings,
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
...fb,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}
|
|
67
|
+
}
|
|
40
68
|
return {
|
|
41
69
|
plugins: ["@ota-meshi"],
|
|
42
70
|
rules: {
|
|
43
71
|
"@ota-meshi/missing-module-for-config": ["error", missings],
|
|
44
72
|
},
|
|
45
|
-
...
|
|
73
|
+
...fb,
|
|
46
74
|
}
|
|
47
75
|
}
|
|
48
76
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ota-meshi/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "ESLint configuration plugin for me.",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "
|
|
10
|
+
"node": "^12.20.0 || ^14.14.0 || >=16"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"lib"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"homepage": "https://github.com/ota-meshi/eslint-plugin#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"eslint": "^7.0.0",
|
|
32
|
-
"eslint-plugin-regexp": "^0.
|
|
32
|
+
"eslint-plugin-regexp": "^1.0.0",
|
|
33
33
|
"eslint-plugin-eslint-comments": "^3.2.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
"eslint-plugin-jsonc": "^1.0.0",
|
|
44
44
|
"eslint-plugin-markdown": "^2.0.0",
|
|
45
45
|
"eslint-plugin-node": "^11.1.0",
|
|
46
|
+
"eslint-plugin-node-dependencies": "^0.5.0",
|
|
46
47
|
"eslint-plugin-prettier": "^3.1.4",
|
|
47
|
-
"eslint-plugin-regexp": "^0.
|
|
48
|
+
"eslint-plugin-regexp": "^1.0.0",
|
|
48
49
|
"eslint-plugin-toml": "0.2.0",
|
|
49
50
|
"eslint-plugin-vue": "^7.0.0-0",
|
|
50
|
-
"eslint-plugin-yml": "^0.
|
|
51
|
-
"mocha": "^
|
|
51
|
+
"eslint-plugin-yml": "^0.10.0",
|
|
52
|
+
"mocha": "^9.0.0",
|
|
52
53
|
"prettier": "^2.0.5",
|
|
53
54
|
"typescript": "^4.1.5"
|
|
54
55
|
},
|