@firefoxic/eslint-config 6.0.1 → 7.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,
|
|
@@ -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": "7.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sergey Artemov",
|
|
@@ -25,23 +25,24 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"./lib/**/*.d.ts",
|
|
28
|
-
"./lib/**/*.js"
|
|
28
|
+
"./lib/**/*.js",
|
|
29
|
+
"!**/*.test.js"
|
|
29
30
|
],
|
|
30
31
|
"peerDependencies": {
|
|
31
|
-
"eslint": "^
|
|
32
|
+
"eslint": "^10.0.0"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@stylistic/eslint-plugin": "^5.7.
|
|
35
|
-
"eslint-plugin-prefer-let": "^4.0.1",
|
|
35
|
+
"@stylistic/eslint-plugin": "^5.7.1",
|
|
36
36
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
37
|
-
"globals": "^17.
|
|
37
|
+
"globals": "^17.3.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"help": "make help",
|
|
41
41
|
"eslint": "eslint"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"eslint": "^
|
|
44
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
45
|
+
"eslint": "^10.0.0"
|
|
45
46
|
},
|
|
46
47
|
"keywords": [
|
|
47
48
|
"config",
|