@mlaursen/eslint-config 4.2.0 → 5.1.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/README.md CHANGED
@@ -2,36 +2,161 @@
2
2
 
3
3
  A reusable eslint config that I use for most of my projects.
4
4
 
5
- ## Usage
6
-
7
- ```js
8
- module.exports = {
9
- extends: "@mlaursen/eslint-config",
10
- };
11
- ```
12
-
13
- ## Additional Type Checking
14
-
15
- Or if I want to do additional rules and strict type checking linting rules:
16
-
17
- ```js
18
- module.exports = {
19
- extends: "@mlaursen/eslint-config",
20
- parserOptions: {
21
- tsconfigRootDir: __dirname,
22
- project: ["./tsconfig.json"],
23
- },
24
- rules: {
25
- // any custom rules for this project
26
- },
27
- overrides: [
28
- {
29
- files: ["**/*.ts", "**/*.tsx"],
30
- extends: [
31
- "plugin:@typescript-eslint/recommended-requiring-type-checking",
32
- ],
33
- },
34
- // any custom overrides for this project
35
- ],
36
- };
5
+ Starting at `5.0.0`, I only support `eslint@^9` or greater.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install -D eslint @mlaursen/eslint-config
11
+ ```
12
+
13
+ Then create an `eslint.config.mjs` with the following:
14
+
15
+ ```js
16
+ // @ts-check
17
+ import { config, configs, gitignore } from "@mlaursen/eslint-config";
18
+
19
+ // choose the config you want to use
20
+ export default config(gitignore(import.meta.url), ...configs.frontend);
21
+ export default config(gitignore(import.meta.url), ...configs.frontendTypeChecking(import.meta.dirname));
22
+ ```
23
+
24
+ The `config` export is the `typescript-eslint.config()` function to provide
25
+ type definitions.
26
+
27
+ ## Configs
28
+
29
+ I normally just use the `frontend` or `frontendTypeChecking` configs, but the others can be used individually if needed.
30
+
31
+ <!--toc:start-->
32
+
33
+ - [base](#base)
34
+ - [typescript](#typescript)
35
+ - [typescriptTypeChecking](#typescripttypechecking)
36
+ - [jest](#jest)
37
+ - [jestDom](#jestdom)
38
+ - [testingLibraryReact](#testinglibraryreact)
39
+ - [testingLibraryDom](#testinglibrarydom)
40
+ - [frontend](#frontend)
41
+ - [frontendTypeChecking](#frontendtypechecking)
42
+
43
+ <!--toc:end-->
44
+
45
+ ### base
46
+
47
+ The base config is automatically used by the [typescript](#typescript) config and is just the `eslint.configs.recommended` and a few other stylistic changes.
48
+
49
+ > This should not be used if the [typescript](#typescript) or [typescriptTypeChecking](#typescripttypechecking) configs are used.
50
+
51
+ ```js
52
+ // @ts-check
53
+ import { config, configs } from "@mlaursen/eslint-config";
54
+
55
+ export default config(...configs.base);
56
+ ```
57
+
58
+ ### typescript
59
+
60
+ This extends the [base](#base) config and the `tseslint.configs.strict` config. It also includes a few stylistic choices for type
61
+ behavior and disabled strict rules in test files.
62
+
63
+ > Only this rule or [typescripttypechecking](#typescripttypechecking) should be used. They should not be used together.
64
+
65
+ ```js
66
+ // @ts-check
67
+ import { config, configs } from "@mlaursen/eslint-config";
68
+
69
+ export default config(...configs.typescript);
70
+ ```
71
+
72
+ ### typescriptTypeChecking
73
+
74
+ This is the same as the [typescript](#typescript) config but also includes the `tseslint.configs.strictTypeCheckedOnly` config.
75
+
76
+ > Only this rule or [typescript](#typescript) should be used. They should not be used together.
77
+
78
+ ```js
79
+ // @ts-check
80
+ import { config, configs } from "@mlaursen/eslint-config";
81
+
82
+ export default config(...configs.typescriptTypeChecking(import.meta.dirname));
83
+ ```
84
+
85
+ ### jest
86
+
87
+ This only enables the `eslint-plugin-jest.configs['flat/recommended]` rules on tests files.
88
+
89
+ ```js
90
+ // @ts-check
91
+ import { config, configs } from "@mlaursen/eslint-config";
92
+
93
+ export default config(...configs.jest);
94
+ ```
95
+
96
+ ### jestDom
97
+
98
+ This only enables the `eslint-plugin-jest-dom.configs['flat/recommended]` rules on tests files.
99
+
100
+ ```js
101
+ // @ts-check
102
+ import { config, configs } from "@mlaursen/eslint-config";
103
+
104
+ export default config(...configs.jestDom);
105
+ ```
106
+
107
+ ### testingLibraryReact
108
+
109
+ This enables the `eslint-plugin-testing-library/.configs["flat/react]` plugin and rules on test files.
110
+
111
+ ```js
112
+ // @ts-check
113
+ import { config, configs } from "@mlaursen/eslint-config";
114
+
115
+ export default config(...configs.testingLibraryReact);
116
+ ```
117
+
118
+ ### testingLibraryDom
119
+
120
+ This enables the `eslint-plugin-testing-library/.configs["flat/dom]` plugin and rules on test files.
121
+
122
+ > This should **not** be used with the [testingLibraryReact](#testinglibraryreact) rules
123
+
124
+ ```js
125
+ // @ts-check
126
+ import { config, configs } from "@mlaursen/eslint-config";
127
+
128
+ export default config(...configs.testingLibraryDom);
129
+ ```
130
+
131
+ ### next
132
+
133
+ This is a small wrapper around the `@next/eslint-plugin-next` that works with eslint v9.
134
+
135
+ ```js
136
+ // @ts-check
137
+ import { config, configs } from "@mlaursen/eslint-config";
138
+
139
+ export default config(...configs.next);
140
+ ```
141
+
142
+ ### frontend
143
+
144
+ This is my normal frontend repo setup with `jest`, `jest-dom`, `typescript`, `react`, `testing-library/react`.
145
+
146
+ ```js
147
+ // @ts-check
148
+ import { config, configs } from "@mlaursen/eslint-config";
149
+
150
+ export default config(...configs.frontend);
151
+ ```
152
+
153
+ ### frontendTypeChecking
154
+
155
+ Same as the [frontend](#frontend), but enables the strict type checking.
156
+
157
+ ```js
158
+ // @ts-check
159
+ import { config, configs } from "@mlaursen/eslint-config";
160
+
161
+ export default config(...configs.frontendTypeChecking(import.meta.dirname));
37
162
  ```
package/dist/base.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const base: TSESLint.FlatConfig.ConfigArray;
package/dist/base.js ADDED
@@ -0,0 +1,28 @@
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.base = void 0;
7
+ var js_1 = __importDefault(require("@eslint/js"));
8
+ var constants_1 = require("./constants");
9
+ exports.base = [
10
+ js_1.default.configs.recommended,
11
+ {
12
+ rules: {
13
+ // You normally do not want `console.{whatever}` in prod but is fine for
14
+ // development in debugging
15
+ "no-console": constants_1.DEV_WARNING_PROD_ERROR,
16
+ "no-use-before-define": "warn",
17
+ // I want to enforce all statements to require curly braces even if it
18
+ // could be omitted for consistency
19
+ curly: "error",
20
+ // Since this is auto-fixable, I like `{ someproperty }` instead of
21
+ // `{ someproperty: someproperty }`
22
+ "object-shorthand": ["error", "always"],
23
+ // This is about the same as `object-shorthand`. Only rename if it has to
24
+ // be renamed
25
+ "no-useless-rename": ["error"],
26
+ },
27
+ },
28
+ ];
@@ -0,0 +1,2 @@
1
+ export declare const DEV_WARNING_PROD_ERROR: string;
2
+ export declare const TEST_FILES: string[];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEST_FILES = exports.DEV_WARNING_PROD_ERROR = void 0;
4
+ exports.DEV_WARNING_PROD_ERROR = process.env.NODE_ENV !== "production" ? "warn" : "error";
5
+ exports.TEST_FILES = [
6
+ "**/__tests__/**",
7
+ "**/*.{spec,test}.{ts,tsx,js,jsx}",
8
+ ];
@@ -0,0 +1,3 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const frontend: TSESLint.FlatConfig.ConfigArray;
3
+ export declare const frontendTypeChecking: (tsconfigRootDir: string) => TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.frontendTypeChecking = exports.frontend = void 0;
29
+ var jest_1 = require("./jest");
30
+ var testing_library_1 = require("./testing-library");
31
+ 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.frontendTypeChecking = frontendTypeChecking;
@@ -0,0 +1,2 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare function gitignore(importMetaUrl: string): TSESLint.FlatConfig.Config;
@@ -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
+ }
@@ -0,0 +1,14 @@
1
+ export { config } from "typescript-eslint";
2
+ export { gitignore } from "./gitignore";
3
+ export declare const configs: {
4
+ readonly base: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
5
+ readonly jest: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
6
+ readonly jestDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
7
+ readonly typescript: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
8
+ readonly typescriptTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
9
+ readonly testingLibraryDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
10
+ readonly testingLibraryReact: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
11
+ readonly frontend: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
12
+ readonly frontendTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
13
+ readonly next: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
14
+ };
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configs = exports.gitignore = exports.config = void 0;
4
+ var base_1 = require("./base");
5
+ var frontend_1 = require("./frontend");
6
+ var jest_1 = require("./jest");
7
+ var next_1 = require("./next");
8
+ var testing_library_1 = require("./testing-library");
9
+ var typescript_1 = require("./typescript");
10
+ var typescript_eslint_1 = require("typescript-eslint");
11
+ Object.defineProperty(exports, "config", { enumerable: true, get: function () { return typescript_eslint_1.config; } });
12
+ var gitignore_1 = require("./gitignore");
13
+ Object.defineProperty(exports, "gitignore", { enumerable: true, get: function () { return gitignore_1.gitignore; } });
14
+ exports.configs = {
15
+ base: base_1.base,
16
+ jest: jest_1.jest,
17
+ jestDom: jest_1.jestDom,
18
+ typescript: typescript_1.typescript,
19
+ typescriptTypeChecking: typescript_1.typescriptTypeChecking,
20
+ testingLibraryDom: testing_library_1.testingLibraryDom,
21
+ testingLibraryReact: testing_library_1.testingLibraryReact,
22
+ frontend: frontend_1.frontend,
23
+ frontendTypeChecking: frontend_1.frontendTypeChecking,
24
+ next: next_1.next,
25
+ };
package/dist/jest.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const jest: TSESLint.FlatConfig.ConfigArray;
3
+ export declare const jestDom: TSESLint.FlatConfig.ConfigArray;
package/dist/jest.js ADDED
@@ -0,0 +1,26 @@
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.jestDom = exports.jest = void 0;
18
+ var eslint_plugin_jest_1 = __importDefault(require("eslint-plugin-jest"));
19
+ var eslint_plugin_jest_dom_1 = __importDefault(require("eslint-plugin-jest-dom"));
20
+ var constants_1 = require("./constants");
21
+ exports.jest = [
22
+ __assign({ files: constants_1.TEST_FILES }, eslint_plugin_jest_1.default.configs["flat/recommended"]),
23
+ ];
24
+ exports.jestDom = [
25
+ __assign({ files: constants_1.TEST_FILES }, eslint_plugin_jest_dom_1.default.configs["flat/recommended"]),
26
+ ];
package/dist/next.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const next: TSESLint.FlatConfig.ConfigArray;
package/dist/next.js ADDED
@@ -0,0 +1,28 @@
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.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 = [
21
+ {
22
+ plugins: {
23
+ // @ts-expect-error There is a bad typing atm
24
+ "@next/next": (0, compat_1.fixupPluginRules)(eslint_plugin_next_1.default),
25
+ },
26
+ rules: __assign({}, eslint_plugin_next_1.default.configs.recommended.rules),
27
+ },
28
+ ];
@@ -0,0 +1,2 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const reactHooks: TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,27 @@
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
+ ];
@@ -0,0 +1,11 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
4
+ * both.
5
+ */
6
+ export declare const testingLibraryReact: TSESLint.FlatConfig.ConfigArray;
7
+ /**
8
+ * NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
9
+ * both.
10
+ */
11
+ export declare const testingLibraryDom: TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,41 @@
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.testingLibraryDom = exports.testingLibraryReact = void 0;
18
+ var compat_1 = require("@eslint/compat");
19
+ var eslint_plugin_testing_library_1 = __importDefault(require("eslint-plugin-testing-library"));
20
+ var constants_1 = require("./constants");
21
+ var testingLibrary = {
22
+ files: constants_1.TEST_FILES,
23
+ plugins: {
24
+ // @ts-expect-error There is a bad typing atm
25
+ "testing-library": (0, compat_1.fixupPluginRules)(eslint_plugin_testing_library_1.default),
26
+ },
27
+ };
28
+ /**
29
+ * NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
30
+ * both.
31
+ */
32
+ exports.testingLibraryReact = [
33
+ __assign(__assign({}, testingLibrary), { rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/react"].rules) }),
34
+ ];
35
+ /**
36
+ * NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
37
+ * both.
38
+ */
39
+ exports.testingLibraryDom = [
40
+ __assign(__assign({}, testingLibrary), { rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/dom"].rules) }),
41
+ ];
@@ -0,0 +1,12 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const typescript: TSESLint.FlatConfig.ConfigArray;
3
+ /**
4
+ * @example
5
+ * ```ts
6
+ * // @ts-check
7
+ * import { config, configs } from "@mlaursen/eslint-config";
8
+ *
9
+ * export default config(...configs.typescriptTypeChecking(import.meta.dirname));
10
+ * ```
11
+ */
12
+ export declare const typescriptTypeChecking: (tsconfigRootDir: string) => TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __importDefault = (this && this.__importDefault) || function (mod) {
28
+ return (mod && mod.__esModule) ? mod : { "default": mod };
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.typescriptTypeChecking = exports.typescript = void 0;
32
+ var typescript_eslint_1 = __importDefault(require("typescript-eslint"));
33
+ var base_1 = require("./base");
34
+ var constants_1 = require("./constants");
35
+ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1.base), false), __read(typescript_eslint_1.default.configs.strict), false), [
36
+ {
37
+ files: ["**/*.{ts,tsx}"],
38
+ rules: {
39
+ // I prefer specifying when something is used only as a type
40
+ "@typescript-eslint/consistent-type-imports": [
41
+ "error",
42
+ { fixStyle: "inline-type-imports" },
43
+ ],
44
+ // I prefer shorthand syntax
45
+ "@typescript-eslint/array-type": ["error", { default: "array" }],
46
+ // I prefer using `interface` over `type = {}`
47
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
48
+ // Allow expressions to work with react hooks. Annoying to have to
49
+ // typedef each arrow function in a `useEffect` or `useCallback` when
50
+ // it can be derived.
51
+ "@typescript-eslint/explicit-function-return-type": [
52
+ "error",
53
+ {
54
+ allowExpressions: true,
55
+ // allow FC definitions for React
56
+ allowTypedFunctionExpressions: true,
57
+ },
58
+ ],
59
+ "@typescript-eslint/no-unused-vars": [
60
+ "error",
61
+ {
62
+ argsIgnorePattern: "^_",
63
+ varsIgnorePattern: "^_",
64
+ },
65
+ ],
66
+ "@typescript-eslint/no-use-before-define": [
67
+ "warn",
68
+ { ignoreTypeReferences: true },
69
+ ],
70
+ },
71
+ },
72
+ {
73
+ files: constants_1.TEST_FILES,
74
+ rules: {
75
+ // allow tests to be less strict
76
+ "@typescript-eslint/ban-ts-comment": "off",
77
+ "@typescript-eslint/explicit-function-return-type": "off",
78
+ "@typescript-eslint/no-empty-function": "off",
79
+ "@typescript-eslint/no-explicit-any": "off",
80
+ "@typescript-eslint/no-object-literal-type-assertion": "off",
81
+ "@typescript-eslint/no-var-requires": "off",
82
+ },
83
+ },
84
+ ], false);
85
+ /**
86
+ * @example
87
+ * ```ts
88
+ * // @ts-check
89
+ * import { config, configs } from "@mlaursen/eslint-config";
90
+ *
91
+ * export default config(...configs.typescriptTypeChecking(import.meta.dirname));
92
+ * ```
93
+ */
94
+ var typescriptTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray([], __read(exports.typescript), false), __read(typescript_eslint_1.default.configs.strictTypeCheckedOnly), false), [
95
+ {
96
+ languageOptions: {
97
+ parserOptions: {
98
+ projectService: true,
99
+ tsconfigRootDir: tsconfigRootDir,
100
+ },
101
+ },
102
+ },
103
+ ], false); };
104
+ exports.typescriptTypeChecking = typescriptTypeChecking;
package/package.json CHANGED
@@ -1,25 +1,17 @@
1
1
  {
2
2
  "name": "@mlaursen/eslint-config",
3
- "version": "4.2.0",
3
+ "version": "5.1.0",
4
4
  "description": "An eslint config used by mlaursen for most projects.",
5
- "main": "index.js",
6
5
  "repository": "https://github.com/mlaursen/eslint-config.git",
7
6
  "author": "Mikkel Laursen <mlaursen03@gmail.com>",
8
7
  "license": "MIT",
9
- "scripts": {
10
- "test": "eslint -c index.js \"test/**/*.{js,jsx,ts,tsx}\"",
11
- "lint": "eslint -c scripts/.eslintrc.js \"scripts/**/*.ts\"",
12
- "run-script": "tsx --tsconfig scripts/tsconfig.json",
13
- "release": "pnpm run run-script scripts/release.ts"
14
- },
15
- "engines": {
16
- "pnpm": ">=7",
17
- "node": ">=16"
18
- },
19
- "engineStrict": true,
20
8
  "files": [
21
- "index.js"
9
+ "dist/"
22
10
  ],
11
+ "exports": {
12
+ ".": "./dist/index.js",
13
+ "./package.json": "./package.json"
14
+ },
23
15
  "bugs": {
24
16
  "url": "https://github.com/mlaursen/eslint-config/issues"
25
17
  },
@@ -28,33 +20,33 @@
28
20
  "typescript"
29
21
  ],
30
22
  "dependencies": {
31
- "@typescript-eslint/eslint-plugin": "^7.16.0",
32
- "@typescript-eslint/parser": "^7.16.0",
33
- "confusing-browser-globals": "^1.0.11",
34
- "eslint-config-prettier": "^9.1.0",
35
- "eslint-plugin-import": "^2.29.1",
36
- "eslint-plugin-jest": "^28.6.0",
37
- "eslint-plugin-jsx-a11y": "^6.9.0",
38
- "eslint-plugin-react": "^7.34.4",
39
- "eslint-plugin-react-hooks": "^4.6.2",
40
- "eslint-plugin-testing-library": "^6.2.2",
41
- "eslint-plugin-tsdoc": "^0.3.0"
23
+ "@eslint/compat": "^1.2.0",
24
+ "@eslint/js": "^9.12.0",
25
+ "@next/eslint-plugin-next": "^14.2.15",
26
+ "@types/eslint__js": "^8.42.3",
27
+ "@typescript-eslint/utils": "^8.8.1",
28
+ "eslint-plugin-jest": "^28.8.3",
29
+ "eslint-plugin-jest-dom": "^5.4.0",
30
+ "eslint-plugin-react-hooks": "^5.0.0",
31
+ "eslint-plugin-testing-library": "^6.3.0",
32
+ "typescript-eslint": "^8.8.1"
42
33
  },
43
34
  "devDependencies": {
44
- "@mlaursen/changelog-preset": "^1.1.0",
35
+ "@changesets/cli": "^2.27.9",
36
+ "@inquirer/prompts": "^7.0.0",
45
37
  "@octokit/core": "^6.1.2",
46
- "@swc/core": "^1.6.13",
47
- "@types/inquirer": "^9.0.7",
48
38
  "@types/node": "^20.14.10",
49
39
  "dotenv": "^16.4.5",
50
- "eslint": "^8.57.0",
51
- "inquirer": "^8.2.6",
52
- "standard-version": "^9.5.0",
53
- "tsx": "^4.16.2",
54
- "typescript": "^5.5.3"
40
+ "eslint": "^9.12.0",
41
+ "husky": "^9.1.6",
42
+ "inquirer": "^12.0.0",
43
+ "lint-staged": "^15.2.10",
44
+ "prettier": "^3.3.3",
45
+ "tsx": "^4.19.1",
46
+ "typescript": "^5.6.3"
55
47
  },
56
48
  "peerDependencies": {
57
- "eslint": ">= 8.0.0",
49
+ "eslint": ">= 9.0.0",
58
50
  "typescript": ">= 5"
59
51
  },
60
52
  "peerDependenciesMeta": {
@@ -68,8 +60,19 @@
68
60
  "publishConfig": {
69
61
  "access": "public"
70
62
  },
63
+ "lint-staged": {
64
+ "**/*.{js,jsx,ts,tsx,md,yml,yaml,json}": [
65
+ "prettier --write"
66
+ ]
67
+ },
71
68
  "volta": {
72
- "node": "20.15.1",
73
- "pnpm": "9.5.0"
69
+ "node": "20.12.2",
70
+ "pnpm": "9.12.1"
71
+ },
72
+ "scripts": {
73
+ "clean": "rm -rf dist",
74
+ "build": "tsc -p tsconfig.build.json",
75
+ "run-script": "tsx --tsconfig scripts/tsconfig.json",
76
+ "release": "pnpm run run-script scripts/release.ts"
74
77
  }
75
- }
78
+ }
package/index.js DELETED
@@ -1,184 +0,0 @@
1
- const confusingBrowserGlobals = require("confusing-browser-globals");
2
-
3
- let react = false;
4
- let isNewJsx = false;
5
- try {
6
- require.resolve("react");
7
- react = true;
8
- isNewJsx = parseInt(require("react").version, 10) > 16;
9
- } catch (e) {}
10
-
11
- module.exports = {
12
- parser: "@typescript-eslint/parser",
13
- parserOptions: {
14
- ecmaVersion: 2018,
15
- sourceType: "module",
16
- },
17
- extends: [
18
- "eslint:recommended",
19
- "plugin:react/recommended",
20
- "plugin:react-hooks/recommended",
21
- isNewJsx && "plugin:react/jsx-runtime",
22
- "plugin:import/errors",
23
- "plugin:import/warnings",
24
- "plugin:import/typescript",
25
- "plugin:jsx-a11y/recommended",
26
- "prettier",
27
- ].filter(Boolean),
28
- plugins: ["@typescript-eslint", "jest", "jsx-a11y", "react-hooks", "tsdoc"],
29
- env: {
30
- es6: true,
31
- node: true,
32
- browser: true,
33
- },
34
- settings: {
35
- "import/extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
36
- "import/parsers": {
37
- "@typescript-eslint/parser": [".ts", ".tsx"],
38
- },
39
- "import/resolver": {
40
- node: {
41
- extensions: [".js", ".jsx", ".ts", ".tsx"],
42
- },
43
- },
44
- react: {
45
- version: react ? "detect" : "17.0.0",
46
- },
47
- },
48
- rules: {
49
- "no-console": "warn",
50
- "no-use-before-define": "warn",
51
-
52
- "no-restricted-globals": ["error", "isFinite", "isNaN"].concat(
53
- confusingBrowserGlobals
54
- ),
55
-
56
- // too many false positives with aliases/root dirs
57
- "import/no-unresolved": "off",
58
-
59
- curly: "error",
60
-
61
- "object-shorthand": ["error", "always"],
62
- "no-useless-rename": ["error"],
63
- },
64
- overrides: [
65
- {
66
- files: ["**/*.ts", "**/*.tsx"],
67
- extends: ["plugin:@typescript-eslint/recommended"],
68
- rules: {
69
- "@typescript-eslint/consistent-type-imports": [
70
- "error",
71
- { fixStyle: "inline-type-imports" },
72
- ],
73
-
74
- // I want correct tsdoc syntax
75
- "tsdoc/syntax": "warn",
76
-
77
- "react/prop-types": "off",
78
-
79
- // have to disable since it can report incorrect errors
80
- "no-empty-function": "off",
81
-
82
- // I prefer shorthand syntax
83
- "@typescript-eslint/array-type": ["error", { default: "array" }],
84
-
85
- // I prefer using `interface` over `type = {}`
86
- "@typescript-eslint/consistent-type-definitions": [
87
- "error",
88
- "interface",
89
- ],
90
-
91
- // Allow expressions to work with react hooks. Annoying to have to
92
- // typedef each arrow function in a `useEffect` or `useCallback` when
93
- // it can be derived.
94
- "@typescript-eslint/explicit-function-return-type": [
95
- "error",
96
- {
97
- allowExpressions: true,
98
- // allow FC definitions for React
99
- allowTypedFunctionExpressions: true,
100
- },
101
- ],
102
-
103
- // not a big fan of requiring unknown objects to require the index signature
104
- "@typescript-eslint/ban-types": "off",
105
-
106
- // This is a "better" version of the `noUnusedLocals` and
107
- // `noUnusedParameters` from the tsconfig.json since it can catch
108
- // unused vars in rest parameters that weren't meant to be omitted. I
109
- // must manually rename to be _name so I know it was intentionally
110
- // omitted
111
- "@typescript-eslint/no-unused-vars": [
112
- "error",
113
- {
114
- argsIgnorePattern: "^_",
115
- varsIgnorePattern: "^_",
116
- },
117
- ],
118
-
119
- "no-use-before-define": "off",
120
- "@typescript-eslint/no-use-before-define": [
121
- "warn",
122
- { ignoreTypeReferences: true },
123
- ],
124
- },
125
- },
126
- {
127
- files: [
128
- "src/setupTests.js",
129
- "src/setupTests.ts",
130
- "**/__tests__/**",
131
- "**/*.test.*",
132
- ],
133
- env: {
134
- jest: true,
135
- },
136
- // allow for less strict rules when writing tests
137
- rules: {
138
- "prefer-template": "off",
139
-
140
- "@typescript-eslint/no-explicit-any": "off",
141
- "@typescript-eslint/explicit-function-return-type": "off",
142
- "@typescript-eslint/no-object-literal-type-assertion": "off",
143
- "@typescript-eslint/no-var-requires": "off",
144
- "@typescript-eslint/no-empty-function": "off",
145
- "@typescript-eslint/ban-ts-comment": "off",
146
- "@typescript-eslint/no-empty-function": "off",
147
-
148
- "jsx-a11y/anchor-has-content": 0,
149
- "jsx-a11y/anchor-is-valid": "off",
150
- "jsx-a11y/click-events-have-key-events": 0,
151
- "jsx-a11y/control-has-associated-label": "off",
152
- "jsx-a11y/no-autofocus": "off",
153
- "jsx-a11y/no-static-element-interactions": "off",
154
-
155
- "react/prop-types": "off",
156
- "react/display-name": "off",
157
- "react/prefer-stateless-function": "off",
158
- },
159
- },
160
- {
161
- files: ["**/__tests__/**", "**/*.test.*"],
162
- extends: ["plugin:jest/recommended", "plugin:testing-library/react"],
163
- rules: {
164
- // it's valid to do @jest-environment or other things in tests
165
- "tsdoc/syntax": 0,
166
- },
167
- },
168
- {
169
- files: ["**/*.js", "**/*.jsx"],
170
- rules: {
171
- "no-unused-vars": [
172
- "error",
173
- {
174
- vars: "all",
175
- varsIgnorePattern: "^_",
176
- args: "after-used",
177
- varsIgnorePattern: "^_",
178
- ignoreRestSiblings: true,
179
- },
180
- ],
181
- },
182
- },
183
- ],
184
- };