@mlaursen/eslint-config 5.1.0 → 5.1.2
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 +36 -5
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/frontend.js +4 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/jsxA11y.d.ts +2 -0
- package/dist/jsxA11y.js +37 -0
- package/dist/react.d.ts +10 -0
- package/dist/react.js +51 -0
- package/dist/typescript.js +33 -0
- package/package.json +4 -1
- package/dist/react-hooks.d.ts +0 -2
- package/dist/react-hooks.js +0 -27
package/README.md
CHANGED
|
@@ -16,17 +16,22 @@ Then create an `eslint.config.mjs` with the following:
|
|
|
16
16
|
// @ts-check
|
|
17
17
|
import { config, configs, gitignore } from "@mlaursen/eslint-config";
|
|
18
18
|
|
|
19
|
-
// choose the config you want to use
|
|
19
|
+
// choose the config you want to use:
|
|
20
|
+
// somewhat strict type checking
|
|
20
21
|
export default config(gitignore(import.meta.url), ...configs.frontend);
|
|
22
|
+
|
|
23
|
+
// strict type checking
|
|
21
24
|
export default config(gitignore(import.meta.url), ...configs.frontendTypeChecking(import.meta.dirname));
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
The `config` export is the `typescript-eslint.config()` function to provide
|
|
25
|
-
|
|
27
|
+
The `config` export is the `typescript-eslint.config()` function to provide type
|
|
28
|
+
definitions and `gitignore` automatically ignores files from linting based on
|
|
29
|
+
your `.gitignore` rules.
|
|
26
30
|
|
|
27
31
|
## Configs
|
|
28
32
|
|
|
29
|
-
I normally just use the `frontend` or `frontendTypeChecking` configs, but the
|
|
33
|
+
I normally just use the `frontend` or `frontendTypeChecking` configs, but the
|
|
34
|
+
others can be used individually if needed.
|
|
30
35
|
|
|
31
36
|
<!--toc:start-->
|
|
32
37
|
|
|
@@ -37,6 +42,9 @@ I normally just use the `frontend` or `frontendTypeChecking` configs, but the ot
|
|
|
37
42
|
- [jestDom](#jestdom)
|
|
38
43
|
- [testingLibraryReact](#testinglibraryreact)
|
|
39
44
|
- [testingLibraryDom](#testinglibrarydom)
|
|
45
|
+
- [react](#react)
|
|
46
|
+
- [jsxA11y](#jsxa11y)
|
|
47
|
+
- [next](#next)
|
|
40
48
|
- [frontend](#frontend)
|
|
41
49
|
- [frontendTypeChecking](#frontendtypechecking)
|
|
42
50
|
|
|
@@ -128,6 +136,28 @@ import { config, configs } from "@mlaursen/eslint-config";
|
|
|
128
136
|
export default config(...configs.testingLibraryDom);
|
|
129
137
|
```
|
|
130
138
|
|
|
139
|
+
### react
|
|
140
|
+
|
|
141
|
+
This enables the `eslint-plugin-react` and `eslint-plugin-react-hooks`:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
// @ts-check
|
|
145
|
+
import { config, configs } from "@mlaursen/eslint-config";
|
|
146
|
+
|
|
147
|
+
export default config(...configs.react);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### jsxA11y
|
|
151
|
+
|
|
152
|
+
This enables `eslint-plugin-jsx-a11y`:
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
// @ts-check
|
|
156
|
+
import { config, configs } from "@mlaursen/eslint-config";
|
|
157
|
+
|
|
158
|
+
export default config(...configs.jsxA11y);
|
|
159
|
+
```
|
|
160
|
+
|
|
131
161
|
### next
|
|
132
162
|
|
|
133
163
|
This is a small wrapper around the `@next/eslint-plugin-next` that works with eslint v9.
|
|
@@ -141,7 +171,8 @@ export default config(...configs.next);
|
|
|
141
171
|
|
|
142
172
|
### frontend
|
|
143
173
|
|
|
144
|
-
This is my normal frontend repo setup with `
|
|
174
|
+
This is my normal frontend repo setup with `react`, `jsxA11y`, `jest`,
|
|
175
|
+
`jest-dom`, `typescript`, `testing-library/react`.
|
|
145
176
|
|
|
146
177
|
```js
|
|
147
178
|
// @ts-check
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEST_FILES = exports.DEV_WARNING_PROD_ERROR = void 0;
|
|
3
|
+
exports.JSX_FILES = exports.TEST_FILES = exports.DEV_WARNING_PROD_ERROR = void 0;
|
|
4
4
|
exports.DEV_WARNING_PROD_ERROR = process.env.NODE_ENV !== "production" ? "warn" : "error";
|
|
5
5
|
exports.TEST_FILES = [
|
|
6
6
|
"**/__tests__/**",
|
|
7
7
|
"**/*.{spec,test}.{ts,tsx,js,jsx}",
|
|
8
8
|
];
|
|
9
|
+
exports.JSX_FILES = ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"];
|
package/dist/frontend.js
CHANGED
|
@@ -27,8 +27,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.frontendTypeChecking = exports.frontend = void 0;
|
|
29
29
|
var jest_1 = require("./jest");
|
|
30
|
+
var jsxA11y_1 = require("./jsxA11y");
|
|
31
|
+
var react_1 = require("./react");
|
|
30
32
|
var testing_library_1 = require("./testing-library");
|
|
31
33
|
var typescript_1 = require("./typescript");
|
|
32
|
-
exports.frontend = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(typescript_1.typescript), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false);
|
|
33
|
-
var frontendTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, typescript_1.typescriptTypeChecking)(tsconfigRootDir)), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false); };
|
|
34
|
+
exports.frontend = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(typescript_1.typescript), false), __read(react_1.react), false), __read(jsxA11y_1.jsxA11y), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false);
|
|
35
|
+
var frontendTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, typescript_1.typescriptTypeChecking)(tsconfigRootDir)), false), __read(react_1.react), false), __read(jsxA11y_1.jsxA11y), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false); };
|
|
34
36
|
exports.frontendTypeChecking = frontendTypeChecking;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ export declare const configs: {
|
|
|
4
4
|
readonly base: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
5
5
|
readonly jest: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
6
6
|
readonly jestDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
7
|
+
readonly react: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
7
8
|
readonly typescript: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
8
9
|
readonly typescriptTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
9
10
|
readonly testingLibraryDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
10
11
|
readonly testingLibraryReact: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
11
12
|
readonly frontend: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
12
13
|
readonly frontendTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
14
|
+
readonly jsxA11y: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
13
15
|
readonly next: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
14
16
|
};
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,9 @@ exports.configs = exports.gitignore = exports.config = void 0;
|
|
|
4
4
|
var base_1 = require("./base");
|
|
5
5
|
var frontend_1 = require("./frontend");
|
|
6
6
|
var jest_1 = require("./jest");
|
|
7
|
+
var jsxA11y_1 = require("./jsxA11y");
|
|
7
8
|
var next_1 = require("./next");
|
|
9
|
+
var react_1 = require("./react");
|
|
8
10
|
var testing_library_1 = require("./testing-library");
|
|
9
11
|
var typescript_1 = require("./typescript");
|
|
10
12
|
var typescript_eslint_1 = require("typescript-eslint");
|
|
@@ -15,11 +17,13 @@ exports.configs = {
|
|
|
15
17
|
base: base_1.base,
|
|
16
18
|
jest: jest_1.jest,
|
|
17
19
|
jestDom: jest_1.jestDom,
|
|
20
|
+
react: react_1.react,
|
|
18
21
|
typescript: typescript_1.typescript,
|
|
19
22
|
typescriptTypeChecking: typescript_1.typescriptTypeChecking,
|
|
20
23
|
testingLibraryDom: testing_library_1.testingLibraryDom,
|
|
21
24
|
testingLibraryReact: testing_library_1.testingLibraryReact,
|
|
22
25
|
frontend: frontend_1.frontend,
|
|
23
26
|
frontendTypeChecking: frontend_1.frontendTypeChecking,
|
|
27
|
+
jsxA11y: jsxA11y_1.jsxA11y,
|
|
24
28
|
next: next_1.next,
|
|
25
29
|
};
|
package/dist/jsxA11y.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.jsxA11y = void 0;
|
|
18
|
+
var eslint_plugin_jsx_a11y_1 = __importDefault(require("eslint-plugin-jsx-a11y"));
|
|
19
|
+
var globals_1 = __importDefault(require("globals"));
|
|
20
|
+
var constants_1 = require("./constants");
|
|
21
|
+
exports.jsxA11y = [
|
|
22
|
+
__assign(__assign({ files: constants_1.JSX_FILES }, eslint_plugin_jsx_a11y_1.default.flatConfigs.recommended), { languageOptions: {
|
|
23
|
+
globals: __assign({}, globals_1.default.browser),
|
|
24
|
+
}, rules: {
|
|
25
|
+
// I **only** use autoFocus within dialogs which provide the correct
|
|
26
|
+
// context for screen readers.
|
|
27
|
+
"jsx-a11y/no-autofocus": "off",
|
|
28
|
+
} }),
|
|
29
|
+
{
|
|
30
|
+
files: constants_1.TEST_FILES,
|
|
31
|
+
rules: {
|
|
32
|
+
"jsx-a11y/anchor-has-content": "off",
|
|
33
|
+
"jsx-a11y/click-events-have-key-events": "off",
|
|
34
|
+
"jsx-a11y/no-static-element-interactions": "off",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Enables:
|
|
4
|
+
* - `eslint-plugin-react` with:
|
|
5
|
+
* - flat.recommended
|
|
6
|
+
* - flat['jsx-runtime']
|
|
7
|
+
* - `eslint-plugin-react-hooks` with:
|
|
8
|
+
* - recommended rules
|
|
9
|
+
*/
|
|
10
|
+
export declare const react: TSESLint.FlatConfig.ConfigArray;
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.react = void 0;
|
|
18
|
+
var eslint_plugin_react_1 = __importDefault(require("eslint-plugin-react"));
|
|
19
|
+
var eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
|
|
20
|
+
var globals_1 = __importDefault(require("globals"));
|
|
21
|
+
var constants_1 = require("./constants");
|
|
22
|
+
var flat = eslint_plugin_react_1.default.configs.flat;
|
|
23
|
+
var reactPlugins = flat.recommended.plugins;
|
|
24
|
+
var recommendedRules = flat.recommended.rules;
|
|
25
|
+
var jsxRuntimeRules = flat["jsx-runtime"].rules;
|
|
26
|
+
/**
|
|
27
|
+
* Enables:
|
|
28
|
+
* - `eslint-plugin-react` with:
|
|
29
|
+
* - flat.recommended
|
|
30
|
+
* - flat['jsx-runtime']
|
|
31
|
+
* - `eslint-plugin-react-hooks` with:
|
|
32
|
+
* - recommended rules
|
|
33
|
+
*/
|
|
34
|
+
exports.react = [
|
|
35
|
+
{
|
|
36
|
+
files: constants_1.JSX_FILES,
|
|
37
|
+
settings: {
|
|
38
|
+
react: {
|
|
39
|
+
version: "detect",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
plugins: __assign(__assign({}, reactPlugins), { "react-hooks": eslint_plugin_react_hooks_1.default }),
|
|
43
|
+
rules: __assign(__assign(__assign(__assign({}, recommendedRules), jsxRuntimeRules), eslint_plugin_react_hooks_1.default.configs.recommended.rules), { "react-hooks/exhaustive-deps": [
|
|
44
|
+
"error",
|
|
45
|
+
{
|
|
46
|
+
additionalHooks: "(useIsomorphicLayoutEffect)",
|
|
47
|
+
},
|
|
48
|
+
] }),
|
|
49
|
+
languageOptions: __assign(__assign({}, flat.recommended.languageOptions), { globals: __assign({}, globals_1.default.browser) }),
|
|
50
|
+
},
|
|
51
|
+
];
|
package/dist/typescript.js
CHANGED
|
@@ -63,6 +63,7 @@ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1
|
|
|
63
63
|
varsIgnorePattern: "^_",
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
+
"no-use-before-define": "off",
|
|
66
67
|
"@typescript-eslint/no-use-before-define": [
|
|
67
68
|
"warn",
|
|
68
69
|
{ ignoreTypeReferences: true },
|
|
@@ -92,6 +93,38 @@ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1
|
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
94
95
|
var typescriptTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray([], __read(exports.typescript), false), __read(typescript_eslint_1.default.configs.strictTypeCheckedOnly), false), [
|
|
96
|
+
{
|
|
97
|
+
rules: {
|
|
98
|
+
// I do not enable the `noUncheckedIndexedAccess` tsconfig option, so I
|
|
99
|
+
// still need to verify that stuff exists. There are other cases where I
|
|
100
|
+
// know it exists, so I can ignore those as well
|
|
101
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
102
|
+
// I never use `this`
|
|
103
|
+
"@typescript-eslint/unbound-method": "off",
|
|
104
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
105
|
+
"error",
|
|
106
|
+
{
|
|
107
|
+
allowNumber: true,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
// I want to allow `onClick={async (event) => { ... }}`
|
|
111
|
+
"@typescript-eslint/no-misused-promises": [
|
|
112
|
+
"error",
|
|
113
|
+
{
|
|
114
|
+
checksVoidReturn: false,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
files: constants_1.TEST_FILES,
|
|
121
|
+
rules: {
|
|
122
|
+
// like base typescript, can be less strict in tests
|
|
123
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
124
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
125
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
95
128
|
{
|
|
96
129
|
languageOptions: {
|
|
97
130
|
parserOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlaursen/eslint-config",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "An eslint config used by mlaursen for most projects.",
|
|
5
5
|
"repository": "https://github.com/mlaursen/eslint-config.git",
|
|
6
6
|
"author": "Mikkel Laursen <mlaursen03@gmail.com>",
|
|
@@ -27,8 +27,11 @@
|
|
|
27
27
|
"@typescript-eslint/utils": "^8.8.1",
|
|
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
|
+
"eslint-plugin-react": "^7.37.1",
|
|
30
32
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
31
33
|
"eslint-plugin-testing-library": "^6.3.0",
|
|
34
|
+
"globals": "^15.11.0",
|
|
32
35
|
"typescript-eslint": "^8.8.1"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
package/dist/react-hooks.d.ts
DELETED
package/dist/react-hooks.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.reactHooks = void 0;
|
|
18
|
-
var eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
|
|
19
|
-
exports.reactHooks = [
|
|
20
|
-
{
|
|
21
|
-
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
22
|
-
plugins: {
|
|
23
|
-
"react-hooks": eslint_plugin_react_hooks_1.default,
|
|
24
|
-
},
|
|
25
|
-
rules: __assign({}, eslint_plugin_react_hooks_1.default.configs.recommended.rules),
|
|
26
|
-
},
|
|
27
|
-
];
|