@stanlemon/eslint-config 0.1.160 → 2.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.
- package/eslint.config.js +138 -0
- package/package.json +13 -12
- package/.eslintrc.js +0 -1
- package/index.js +0 -127
package/eslint.config.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import eslint from "@eslint/js";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import prettierPlugin from "eslint-plugin-prettier/recommended";
|
|
5
|
+
import reactPlugin from "eslint-plugin-react";
|
|
6
|
+
import importPlugin from "eslint-plugin-import";
|
|
7
|
+
import jest from "eslint-plugin-jest";
|
|
8
|
+
import jestDom from "eslint-plugin-jest-dom";
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
{
|
|
12
|
+
ignores: ["**/node_modules/", ".git/", "**/dist/"],
|
|
13
|
+
},
|
|
14
|
+
eslint.configs.recommended,
|
|
15
|
+
prettierPlugin,
|
|
16
|
+
importPlugin.flatConfigs.react,
|
|
17
|
+
importPlugin.flatConfigs.typescript,
|
|
18
|
+
|
|
19
|
+
reactPlugin.configs.flat.recommended,
|
|
20
|
+
{
|
|
21
|
+
languageOptions: {
|
|
22
|
+
parser: tseslint.parser,
|
|
23
|
+
ecmaVersion: "latest",
|
|
24
|
+
sourceType: "module",
|
|
25
|
+
parserOptions: {
|
|
26
|
+
ecmaFeatures: {
|
|
27
|
+
jsx: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.browser,
|
|
32
|
+
...globals.jest,
|
|
33
|
+
...globals.node,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
plugins: {
|
|
37
|
+
reactPlugin,
|
|
38
|
+
},
|
|
39
|
+
settings: {
|
|
40
|
+
react: {
|
|
41
|
+
version: "detect",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
// Requires strict equality
|
|
46
|
+
eqeqeq: "error",
|
|
47
|
+
// If functions are too long, break them up into smaller ones
|
|
48
|
+
"max-lines-per-function": [
|
|
49
|
+
"error",
|
|
50
|
+
{
|
|
51
|
+
max: 80,
|
|
52
|
+
skipBlankLines: true,
|
|
53
|
+
skipComments: true,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
// Linting shouldn't break on this, but we also want to discourage using console logging
|
|
57
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
58
|
+
// Requires the displayName property to be set, not ideal for stateless components
|
|
59
|
+
"no-unused-vars": [
|
|
60
|
+
"warn",
|
|
61
|
+
{
|
|
62
|
+
caughtErrors: "none",
|
|
63
|
+
destructuredArrayIgnorePattern: "^_",
|
|
64
|
+
ignoreRestSiblings: true,
|
|
65
|
+
args: "none",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
"no-empty-function": "off",
|
|
69
|
+
"react/display-name": "off",
|
|
70
|
+
"react/react-in-jsx-scope": "off",
|
|
71
|
+
"react/jsx-uses-react": "off",
|
|
72
|
+
"react/prop-types": "off",
|
|
73
|
+
"react/no-unescaped-entities": ["error", { forbid: [">", "}"] }],
|
|
74
|
+
"prettier/prettier": [
|
|
75
|
+
"error",
|
|
76
|
+
{
|
|
77
|
+
trailingComma: "es5",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
84
|
+
extends: [...tseslint.configs.recommended],
|
|
85
|
+
/*
|
|
86
|
+
languageOptions: {
|
|
87
|
+
parserOptions: {
|
|
88
|
+
projectService: {
|
|
89
|
+
allowDefaultProject: ['*.ts', '*.tsx'],
|
|
90
|
+
},
|
|
91
|
+
tsconfigRootDir: import.meta.dirname,
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
*/
|
|
96
|
+
rules: {
|
|
97
|
+
"@typescript-eslint/no-unused-vars": [
|
|
98
|
+
"warn",
|
|
99
|
+
{
|
|
100
|
+
caughtErrors: "none",
|
|
101
|
+
destructuredArrayIgnorePattern: "^_",
|
|
102
|
+
ignoreRestSiblings: true,
|
|
103
|
+
args: "none",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
107
|
+
// Do not require 'public' before public methods
|
|
108
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
files: ["**/*.jsx", "**/*.tsx"],
|
|
113
|
+
rules: {
|
|
114
|
+
"max-lines-per-function": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
max: 160, // Twice as long as normal
|
|
118
|
+
skipBlankLines: true,
|
|
119
|
+
skipComments: true,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
files: [
|
|
126
|
+
"**/*.test.js",
|
|
127
|
+
"**/*.test.ts",
|
|
128
|
+
"**/*.test.tsx",
|
|
129
|
+
"jest.setup.js",
|
|
130
|
+
"jest.config.js",
|
|
131
|
+
],
|
|
132
|
+
...jestDom.configs["flat/recommended"],
|
|
133
|
+
...jest.configs["flat/recommended"],
|
|
134
|
+
rules: {
|
|
135
|
+
"max-lines-per-function": "off",
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanlemon/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "My typical eslint setup, but without all the copy and paste.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint"
|
|
@@ -8,29 +8,30 @@
|
|
|
8
8
|
"author": "Stan Lemon <stanlemon@users.noreply.github.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=20.0"
|
|
12
12
|
},
|
|
13
|
-
"type": "
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./eslint.config.js",
|
|
14
15
|
"scripts": {
|
|
15
|
-
"lint": "eslint
|
|
16
|
-
"lint:fix": "eslint --fix
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"lint:fix": "eslint --fix ."
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@typescript-eslint/parser": "^8.8.0",
|
|
20
|
+
"@eslint/js": "^9.12.0",
|
|
21
|
+
"@types/eslint__js": "^8.42.3",
|
|
22
22
|
"eslint": "^9.12.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-
|
|
26
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
27
27
|
"eslint-plugin-import": "^2.31.0",
|
|
28
28
|
"eslint-plugin-jest": "^28.8.3",
|
|
29
29
|
"eslint-plugin-jest-dom": "^5.4.0",
|
|
30
|
-
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
31
30
|
"eslint-plugin-prettier": "^5.2.1",
|
|
32
31
|
"eslint-plugin-react": "^7.37.1",
|
|
33
|
-
"
|
|
34
|
-
"prettier": "^3.3.3"
|
|
32
|
+
"globals": "^15.10.0",
|
|
33
|
+
"prettier": "^3.3.3",
|
|
34
|
+
"typescript": "^5.6.2",
|
|
35
|
+
"typescript-eslint": "^8.8.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./index.js");
|
package/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
env: {
|
|
12
|
-
es2022: true,
|
|
13
|
-
browser: true,
|
|
14
|
-
node: true,
|
|
15
|
-
jest: true,
|
|
16
|
-
},
|
|
17
|
-
...(tsconfigExists && { parser: "@typescript-eslint/parser" }),
|
|
18
|
-
parserOptions: {
|
|
19
|
-
sourceType: "module",
|
|
20
|
-
...(tsconfigExists && { project: tsconfigPath }),
|
|
21
|
-
},
|
|
22
|
-
extends: [
|
|
23
|
-
"eslint:recommended",
|
|
24
|
-
"plugin:jest/recommended",
|
|
25
|
-
"plugin:jest-dom/recommended",
|
|
26
|
-
"plugin:prettier/recommended",
|
|
27
|
-
"plugin:react/recommended",
|
|
28
|
-
"plugin:react/jsx-runtime",
|
|
29
|
-
"typescript",
|
|
30
|
-
"typescript/react",
|
|
31
|
-
],
|
|
32
|
-
plugins: ["import", ...(tsconfigExists ? ["deprecation"] : [])],
|
|
33
|
-
settings: {
|
|
34
|
-
react: {
|
|
35
|
-
version: "detect",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
rules: {
|
|
39
|
-
// Requires strict equality
|
|
40
|
-
eqeqeq: "error",
|
|
41
|
-
// If functions are too long, break them up into smaller ones
|
|
42
|
-
"max-lines-per-function": [
|
|
43
|
-
"error",
|
|
44
|
-
{
|
|
45
|
-
max: 80,
|
|
46
|
-
skipBlankLines: true,
|
|
47
|
-
skipComments: true,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
// Linting shouldn't break on this, but we also want to discourage using console logging
|
|
51
|
-
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
52
|
-
// Requires the displayName property to be set, not ideal for stateless components
|
|
53
|
-
"react/display-name": "off",
|
|
54
|
-
"react/react-in-jsx-scope": "off",
|
|
55
|
-
"react/jsx-uses-react": "off",
|
|
56
|
-
"react/prop-types": "off",
|
|
57
|
-
"react/no-unescaped-entities": ["error", { forbid: [">", "}"] }],
|
|
58
|
-
// Allow exporting of unnamed objects as a default
|
|
59
|
-
"import/no-anonymous-default-export": [
|
|
60
|
-
"error",
|
|
61
|
-
{
|
|
62
|
-
allowObject: true,
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
"import/first": "error",
|
|
66
|
-
"import/no-amd": "error",
|
|
67
|
-
"import/no-webpack-loader-syntax": "error",
|
|
68
|
-
"import/no-unused-modules": "error",
|
|
69
|
-
"prettier/prettier": [
|
|
70
|
-
"error",
|
|
71
|
-
{
|
|
72
|
-
trailingComma: "es5",
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
"no-unused-vars": [
|
|
76
|
-
"warn",
|
|
77
|
-
{
|
|
78
|
-
caughtErrors: "none",
|
|
79
|
-
destructuredArrayIgnorePattern: "^_",
|
|
80
|
-
ignoreRestSiblings: true,
|
|
81
|
-
args: "none",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
"@typescript-eslint/no-unused-vars": [
|
|
85
|
-
"warn",
|
|
86
|
-
{
|
|
87
|
-
caughtErrors: "none",
|
|
88
|
-
destructuredArrayIgnorePattern: "^_",
|
|
89
|
-
ignoreRestSiblings: true,
|
|
90
|
-
args: "none",
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
...(tsconfigExists && { "deprecation/deprecation": "warn" }),
|
|
94
|
-
},
|
|
95
|
-
overrides: [
|
|
96
|
-
{
|
|
97
|
-
files: ["**/*.{ts,tsx}"],
|
|
98
|
-
rules: {
|
|
99
|
-
// Empty functions are ok, especially for default values
|
|
100
|
-
"no-empty-function": "off",
|
|
101
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
102
|
-
// Requires 'public' before public methods
|
|
103
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
files: ["**/*.jsx", "**/*.tsx"],
|
|
108
|
-
rules: {
|
|
109
|
-
"max-lines-per-function": [
|
|
110
|
-
"error",
|
|
111
|
-
{
|
|
112
|
-
max: 160, // Twice as long as normal
|
|
113
|
-
skipBlankLines: true,
|
|
114
|
-
skipComments: true,
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
files: ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx"],
|
|
121
|
-
rules: {
|
|
122
|
-
"max-lines-per-function": "off",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
ignorePatterns: [".eslintrc.js", "dist/", "node_modules/"],
|
|
127
|
-
};
|