@mlaursen/eslint-config 5.0.0 → 5.1.1
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 +50 -8
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/frontend.js +4 -2
- package/dist/gitignore.d.ts +2 -0
- package/dist/gitignore.js +15 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -1
- package/dist/jsxA11y.d.ts +2 -0
- package/dist/jsxA11y.js +25 -0
- package/dist/next.d.ts +2 -0
- package/dist/{react-hooks.js → next.js} +7 -6
- package/dist/react.d.ts +10 -0
- package/dist/react.js +46 -0
- package/package.json +4 -1
- package/dist/react-hooks.d.ts +0 -2
package/README.md
CHANGED
|
@@ -14,19 +14,24 @@ Then create an `eslint.config.mjs` with the following:
|
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
16
|
// @ts-check
|
|
17
|
-
import { config, configs } from "@mlaursen/eslint-config";
|
|
17
|
+
import { config, configs, gitignore } from "@mlaursen/eslint-config";
|
|
18
18
|
|
|
19
|
-
// choose the config you want to use
|
|
20
|
-
|
|
21
|
-
export default config(
|
|
19
|
+
// choose the config you want to use:
|
|
20
|
+
// somewhat strict type checking
|
|
21
|
+
export default config(gitignore(import.meta.url), ...configs.frontend);
|
|
22
|
+
|
|
23
|
+
// strict type checking
|
|
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,9 +136,43 @@ 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
|
+
|
|
161
|
+
### next
|
|
162
|
+
|
|
163
|
+
This is a small wrapper around the `@next/eslint-plugin-next` that works with eslint v9.
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
// @ts-check
|
|
167
|
+
import { config, configs } from "@mlaursen/eslint-config";
|
|
168
|
+
|
|
169
|
+
export default config(...configs.next);
|
|
170
|
+
```
|
|
171
|
+
|
|
131
172
|
### frontend
|
|
132
173
|
|
|
133
|
-
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`.
|
|
134
176
|
|
|
135
177
|
```js
|
|
136
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.gitignore = gitignore;
|
|
7
|
+
var compat_1 = require("@eslint/compat");
|
|
8
|
+
var node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
var node_url_1 = require("node:url");
|
|
10
|
+
function gitignore(importMetaUrl) {
|
|
11
|
+
var __filename = (0, node_url_1.fileURLToPath)(importMetaUrl);
|
|
12
|
+
var __dirname = node_path_1.default.dirname(__filename);
|
|
13
|
+
var gitignorePath = node_path_1.default.resolve(__dirname, ".gitignore");
|
|
14
|
+
return (0, compat_1.includeIgnoreFile)(gitignorePath);
|
|
15
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
export { config } from "typescript-eslint";
|
|
2
|
+
export { gitignore } from "./gitignore";
|
|
2
3
|
export declare const configs: {
|
|
3
4
|
readonly base: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
4
5
|
readonly jest: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
5
6
|
readonly jestDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
7
|
+
readonly react: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
6
8
|
readonly typescript: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
7
9
|
readonly typescriptTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
8
10
|
readonly testingLibraryDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
9
11
|
readonly testingLibraryReact: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
10
12
|
readonly frontend: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
11
13
|
readonly frontendTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
14
|
+
readonly jsxA11y: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
15
|
+
readonly next: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
|
|
12
16
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configs = exports.config = void 0;
|
|
3
|
+
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");
|
|
8
|
+
var next_1 = require("./next");
|
|
9
|
+
var react_1 = require("./react");
|
|
7
10
|
var testing_library_1 = require("./testing-library");
|
|
8
11
|
var typescript_1 = require("./typescript");
|
|
9
12
|
var typescript_eslint_1 = require("typescript-eslint");
|
|
10
13
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return typescript_eslint_1.config; } });
|
|
14
|
+
var gitignore_1 = require("./gitignore");
|
|
15
|
+
Object.defineProperty(exports, "gitignore", { enumerable: true, get: function () { return gitignore_1.gitignore; } });
|
|
11
16
|
exports.configs = {
|
|
12
17
|
base: base_1.base,
|
|
13
18
|
jest: jest_1.jest,
|
|
14
19
|
jestDom: jest_1.jestDom,
|
|
20
|
+
react: react_1.react,
|
|
15
21
|
typescript: typescript_1.typescript,
|
|
16
22
|
typescriptTypeChecking: typescript_1.typescriptTypeChecking,
|
|
17
23
|
testingLibraryDom: testing_library_1.testingLibraryDom,
|
|
18
24
|
testingLibraryReact: testing_library_1.testingLibraryReact,
|
|
19
25
|
frontend: frontend_1.frontend,
|
|
20
26
|
frontendTypeChecking: frontend_1.frontendTypeChecking,
|
|
27
|
+
jsxA11y: jsxA11y_1.jsxA11y,
|
|
28
|
+
next: next_1.next,
|
|
21
29
|
};
|
package/dist/jsxA11y.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
} }),
|
|
25
|
+
];
|
package/dist/next.d.ts
ADDED
|
@@ -14,14 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
var
|
|
19
|
-
|
|
17
|
+
exports.next = void 0;
|
|
18
|
+
var compat_1 = require("@eslint/compat");
|
|
19
|
+
var eslint_plugin_next_1 = __importDefault(require("@next/eslint-plugin-next"));
|
|
20
|
+
exports.next = [
|
|
20
21
|
{
|
|
21
|
-
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
22
22
|
plugins: {
|
|
23
|
-
|
|
23
|
+
// @ts-expect-error There is a bad typing atm
|
|
24
|
+
"@next/next": (0, compat_1.fixupPluginRules)(eslint_plugin_next_1.default),
|
|
24
25
|
},
|
|
25
|
-
rules: __assign({},
|
|
26
|
+
rules: __assign({}, eslint_plugin_next_1.default.configs.recommended.rules),
|
|
26
27
|
},
|
|
27
28
|
];
|
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,46 @@
|
|
|
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({}, recommendedRules), jsxRuntimeRules), eslint_plugin_react_hooks_1.default.configs.recommended.rules),
|
|
44
|
+
languageOptions: __assign(__assign({}, flat.recommended.languageOptions), { globals: __assign({}, globals_1.default.browser) }),
|
|
45
|
+
},
|
|
46
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlaursen/eslint-config",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
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>",
|
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@eslint/compat": "^1.2.0",
|
|
24
24
|
"@eslint/js": "^9.12.0",
|
|
25
|
+
"@next/eslint-plugin-next": "^14.2.15",
|
|
25
26
|
"@types/eslint__js": "^8.42.3",
|
|
26
27
|
"@typescript-eslint/utils": "^8.8.1",
|
|
27
28
|
"eslint-plugin-jest": "^28.8.3",
|
|
28
29
|
"eslint-plugin-jest-dom": "^5.4.0",
|
|
30
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
31
|
+
"eslint-plugin-react": "^7.37.1",
|
|
29
32
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
30
33
|
"eslint-plugin-testing-library": "^6.3.0",
|
|
31
34
|
"typescript-eslint": "^8.8.1"
|
package/dist/react-hooks.d.ts
DELETED