@stanlemon/eslint-config 0.1.112 → 0.1.114
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/README.md +2 -0
- package/index.js +24 -7
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ESLint Config
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/%40stanlemon%2Feslint-config)
|
|
4
|
+
|
|
3
5
|
ESLint is great, but it takes a lot to setup! This is my attempt to create a package that contains all of the dependencies I need, plus a simple config to use.
|
|
4
6
|
|
|
5
7
|
To use this, simply create the following file:
|
package/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
|
|
3
|
+
// A package can define a custom tsconfig just for eslint, and if they do we should use it
|
|
4
|
+
const tsconfigPath = fs.existsSync("./tsconfig.eslint.json")
|
|
5
|
+
? "./tsconfig.eslint.json"
|
|
6
|
+
: "./tsconfig.json";
|
|
7
|
+
// Does the desired tsconfig exist?
|
|
8
|
+
const tsconfigExists = fs.existsSync(tsconfigPath);
|
|
9
|
+
|
|
1
10
|
module.exports = {
|
|
2
11
|
env: {
|
|
3
12
|
es2022: true,
|
|
@@ -5,8 +14,10 @@ module.exports = {
|
|
|
5
14
|
node: true,
|
|
6
15
|
jest: true,
|
|
7
16
|
},
|
|
17
|
+
...(tsconfigExists && { parser: "@typescript-eslint/parser" }),
|
|
8
18
|
parserOptions: {
|
|
9
19
|
sourceType: "module",
|
|
20
|
+
...(tsconfigExists && { project: tsconfigPath }),
|
|
10
21
|
},
|
|
11
22
|
extends: [
|
|
12
23
|
"eslint:recommended",
|
|
@@ -18,7 +29,7 @@ module.exports = {
|
|
|
18
29
|
"typescript",
|
|
19
30
|
"typescript/react",
|
|
20
31
|
],
|
|
21
|
-
plugins: ["import"],
|
|
32
|
+
plugins: ["import", ...(tsconfigExists ? ["deprecation"] : [])],
|
|
22
33
|
settings: {
|
|
23
34
|
react: {
|
|
24
35
|
version: "detect",
|
|
@@ -37,12 +48,13 @@ module.exports = {
|
|
|
37
48
|
},
|
|
38
49
|
],
|
|
39
50
|
// Linting shouldn't break on this, but we also want to discourage using console logging
|
|
40
|
-
"no-console": "warn",
|
|
51
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
41
52
|
// Requires the displayName property to be set, not ideal for stateless components
|
|
42
53
|
"react/display-name": "off",
|
|
43
54
|
"react/react-in-jsx-scope": "off",
|
|
44
55
|
"react/jsx-uses-react": "off",
|
|
45
56
|
"react/prop-types": "off",
|
|
57
|
+
"react/no-unescaped-entities": ["error", { forbid: [">", "}"] }],
|
|
46
58
|
// Allow exporting of unnamed objects as a default
|
|
47
59
|
"import/no-anonymous-default-export": [
|
|
48
60
|
"error",
|
|
@@ -60,8 +72,12 @@ module.exports = {
|
|
|
60
72
|
trailingComma: "es5",
|
|
61
73
|
},
|
|
62
74
|
],
|
|
63
|
-
"no-unused-vars": "warn",
|
|
64
|
-
"@typescript-eslint/no-unused-vars":
|
|
75
|
+
"no-unused-vars": ["warn", { ignoreRestSiblings: true, args: "none" }],
|
|
76
|
+
"@typescript-eslint/no-unused-vars": [
|
|
77
|
+
"warn",
|
|
78
|
+
{ ignoreRestSiblings: true, args: "none" },
|
|
79
|
+
],
|
|
80
|
+
...(tsconfigExists && { "deprecation/deprecation": "warn" }),
|
|
65
81
|
},
|
|
66
82
|
overrides: [
|
|
67
83
|
{
|
|
@@ -75,12 +91,12 @@ module.exports = {
|
|
|
75
91
|
},
|
|
76
92
|
},
|
|
77
93
|
{
|
|
78
|
-
files: ["**/*.jsx", "
|
|
94
|
+
files: ["**/*.jsx", "**/*.tsx"],
|
|
79
95
|
rules: {
|
|
80
96
|
"max-lines-per-function": [
|
|
81
97
|
"error",
|
|
82
98
|
{
|
|
83
|
-
max: 160,
|
|
99
|
+
max: 160, // Twice as long as normal
|
|
84
100
|
skipBlankLines: true,
|
|
85
101
|
skipComments: true,
|
|
86
102
|
},
|
|
@@ -88,10 +104,11 @@ module.exports = {
|
|
|
88
104
|
},
|
|
89
105
|
},
|
|
90
106
|
{
|
|
91
|
-
files: ["**/*.test
|
|
107
|
+
files: ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx"],
|
|
92
108
|
rules: {
|
|
93
109
|
"max-lines-per-function": "off",
|
|
94
110
|
},
|
|
95
111
|
},
|
|
96
112
|
],
|
|
113
|
+
ignorePatterns: [".eslintrc.js", "dist/", "node_modules/"],
|
|
97
114
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanlemon/eslint-config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.114",
|
|
4
4
|
"description": "My typical eslint setup, but without all the copy and paste.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint"
|
|
@@ -13,23 +13,24 @@
|
|
|
13
13
|
"type": "commonjs",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"lint": "eslint --ext js,jsx,ts,tsx ./",
|
|
16
|
-
"lint:
|
|
16
|
+
"lint:fix": "eslint --fix --ext js,jsx,ts,tsx ./"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/eslint-parser": "^7.23.3",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
21
|
-
"@typescript-eslint/parser": "^6.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
21
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
22
22
|
"eslint": "^8.56.0",
|
|
23
23
|
"eslint-config-prettier": "^9.1.0",
|
|
24
24
|
"eslint-config-react": "^1.1.7",
|
|
25
25
|
"eslint-config-typescript": "^3.0.0",
|
|
26
|
+
"eslint-plugin-deprecation": "^2.0.0",
|
|
26
27
|
"eslint-plugin-import": "^2.29.1",
|
|
27
|
-
"eslint-plugin-jest": "^27.6.
|
|
28
|
+
"eslint-plugin-jest": "^27.6.2",
|
|
28
29
|
"eslint-plugin-jest-dom": "^5.1.0",
|
|
29
30
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
30
|
-
"eslint-plugin-prettier": "^5.1.
|
|
31
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
31
32
|
"eslint-plugin-react": "^7.33.2",
|
|
32
33
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
33
34
|
"prettier": "^3.1.1"
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
+
}
|