@firefoxic/eslint-config 6.0.1 → 8.0.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import noMultilineNamedImports from "./no-multiline-named-imports/index.js"
|
|
2
2
|
import noSingleQuotesInImportsAndObjectKeys from "./no-single-quotes-in-imports-and-object-keys/index.js"
|
|
3
|
+
import preferLet from "./prefer-let/index.js"
|
|
3
4
|
|
|
4
5
|
const plugin = {
|
|
5
6
|
// preferred location of name and version
|
|
@@ -10,6 +11,7 @@ const plugin = {
|
|
|
10
11
|
rules: {
|
|
11
12
|
"no-multiline-named-imports": noMultilineNamedImports,
|
|
12
13
|
"no-single-quotes-in-imports-and-object-keys": noSingleQuotesInImportsAndObjectKeys,
|
|
14
|
+
"prefer-let": preferLet,
|
|
13
15
|
},
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Use `let` declarations to bind names to values
|
|
3
|
+
* @author Charles Lowell
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
meta: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: `Use "let" declarations to bind names to values`,
|
|
10
|
+
category: `Stylistic Issues`,
|
|
11
|
+
recommended: false,
|
|
12
|
+
},
|
|
13
|
+
fixable: `code`, // or "code" or "whitespace"
|
|
14
|
+
schema: [], // fill in your schema
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
create (context) {
|
|
18
|
+
let sourceCode = context.sourceCode ?? context.getSourceCode()
|
|
19
|
+
|
|
20
|
+
function getScope (node) {
|
|
21
|
+
return sourceCode.getScope ? sourceCode.getScope(node) : context.getScope()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isGlobalScope (node) {
|
|
25
|
+
return getScope(node).type === `global`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isModuleScope (node) {
|
|
29
|
+
return getScope(node).type === `module`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isProgramScope (node) {
|
|
33
|
+
return getScope(node).block.type === `Program`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isTopLevelScope (node) {
|
|
37
|
+
return isGlobalScope(node) || isModuleScope(node) || isProgramScope(node)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isInAmbientContext (node) {
|
|
41
|
+
let current = node.parent
|
|
42
|
+
while (current) {
|
|
43
|
+
if (current.type === `TSModuleDeclaration` && current.declare === true) return true
|
|
44
|
+
|
|
45
|
+
current = current.parent
|
|
46
|
+
}
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
VariableDeclaration (node) {
|
|
52
|
+
if (node.kind === `var`) {
|
|
53
|
+
if (isInAmbientContext(node)) return
|
|
54
|
+
|
|
55
|
+
context.report({
|
|
56
|
+
message: `prefer "let" over "var" to declare value bindings`,
|
|
57
|
+
node,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
else if (node.kind === `const` && !isTopLevelScope(node)) {
|
|
61
|
+
let constToken = sourceCode.getFirstToken(node)
|
|
62
|
+
|
|
63
|
+
context.report({
|
|
64
|
+
message: `"const" declaration outside top-level scope`,
|
|
65
|
+
node,
|
|
66
|
+
fix (fixer) {
|
|
67
|
+
return fixer.replaceText(constToken, `let`)
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import stylistic from "@stylistic/eslint-plugin"
|
|
2
|
-
import eslintPluginPreferLet from "eslint-plugin-prefer-let"
|
|
3
2
|
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort"
|
|
4
3
|
|
|
5
4
|
import enoughIsEnough from "./enough-is-enough/index.js"
|
|
@@ -130,14 +129,6 @@ export default [
|
|
|
130
129
|
"valid-typeof": `error`,
|
|
131
130
|
},
|
|
132
131
|
},
|
|
133
|
-
{
|
|
134
|
-
plugins: {
|
|
135
|
-
"prefer-let": eslintPluginPreferLet,
|
|
136
|
-
},
|
|
137
|
-
rules: {
|
|
138
|
-
"prefer-let/prefer-let": `error`,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
132
|
{
|
|
142
133
|
plugins: {
|
|
143
134
|
"simple-import-sort": eslintPluginSimpleImportSort,
|
|
@@ -148,25 +139,25 @@ export default [
|
|
|
148
139
|
`error`,
|
|
149
140
|
{
|
|
150
141
|
groups: [
|
|
151
|
-
// 1.Node.js modules
|
|
142
|
+
// 1. Node.js modules
|
|
152
143
|
[`^node:`],
|
|
153
144
|
// 2. Foreign modules
|
|
154
145
|
[`^@?\\w`],
|
|
155
|
-
// 3.
|
|
146
|
+
// 3. Styles
|
|
147
|
+
[`^.+\\.s?css$`],
|
|
148
|
+
// 4. Absolute imports (@/...)
|
|
156
149
|
[`^@/`],
|
|
157
|
-
//
|
|
150
|
+
// 5. Relative imports (up)
|
|
158
151
|
[
|
|
159
152
|
`^\\.\\.(?!/?$)`,
|
|
160
153
|
`^\\.\\./?$`,
|
|
161
154
|
],
|
|
162
|
-
//
|
|
155
|
+
// 6. Relative imports (down)
|
|
163
156
|
[
|
|
164
157
|
`^\\./(?=.*/)(?!/?$)`,
|
|
165
158
|
`^\\.(?!/?$)`,
|
|
166
159
|
`^\\./?$`,
|
|
167
160
|
],
|
|
168
|
-
// 6. Styles
|
|
169
|
-
[`^.+\\.s?css$`],
|
|
170
161
|
],
|
|
171
162
|
},
|
|
172
163
|
],
|
|
@@ -426,6 +417,7 @@ export default [
|
|
|
426
417
|
rules: {
|
|
427
418
|
"enough-is-enough/no-multiline-named-imports": `error`,
|
|
428
419
|
"enough-is-enough/no-single-quotes-in-imports-and-object-keys": `error`,
|
|
420
|
+
"enough-is-enough/prefer-let": `error`,
|
|
429
421
|
},
|
|
430
422
|
},
|
|
431
423
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firefoxic/eslint-config",
|
|
3
3
|
"description": "Shared config for eslint by firefoxic.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sergey Artemov",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=20.19"
|
|
20
|
+
"node": ">=20.19",
|
|
21
|
+
"pnpm": ">=10.30"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
23
24
|
"default": "./lib/index.js",
|
|
@@ -25,23 +26,23 @@
|
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
27
28
|
"./lib/**/*.d.ts",
|
|
28
|
-
"./lib/**/*.js"
|
|
29
|
+
"./lib/**/*.js",
|
|
30
|
+
"!**/*.test.js"
|
|
29
31
|
],
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"eslint": "^
|
|
33
|
+
"eslint": "^10.0.0"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@stylistic/eslint-plugin": "^5.
|
|
35
|
-
"eslint-plugin-prefer-let": "^4.0.1",
|
|
36
|
+
"@stylistic/eslint-plugin": "^5.9.0",
|
|
36
37
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
37
|
-
"globals": "^17.
|
|
38
|
+
"globals": "^17.3.0"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
|
-
"help": "make help"
|
|
41
|
-
"eslint": "eslint"
|
|
41
|
+
"help": "make help"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"eslint": "^
|
|
44
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
45
|
+
"eslint": "^10.0.2"
|
|
45
46
|
},
|
|
46
47
|
"keywords": [
|
|
47
48
|
"config",
|