@haltcase/style 6.2.1 → 7.0.0-canary.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.
Files changed (59) hide show
  1. package/eslint/configs/browser.js +19 -0
  2. package/eslint/configs/cjs.js +1 -0
  3. package/eslint/configs/internal/base.js +180 -0
  4. package/eslint/configs/internal/commonjs.js +22 -0
  5. package/eslint/{rules → configs/internal}/es2015.js +14 -16
  6. package/eslint/configs/internal/simple-import-sort.js +24 -0
  7. package/eslint/configs/internal/tsdoc.js +17 -0
  8. package/eslint/{rules → configs/internal}/unicorn.js +116 -121
  9. package/eslint/configs/next.js +36 -0
  10. package/eslint/configs/node.js +19 -0
  11. package/eslint/configs/playwright-test.js +17 -0
  12. package/eslint/configs/react.js +54 -0
  13. package/eslint/configs/typescript.js +84 -0
  14. package/eslint/constants.js +12 -28
  15. package/eslint/index.js +27 -0
  16. package/eslint/rules/best-practice.js +250 -245
  17. package/eslint/rules/imports.js +94 -0
  18. package/eslint/rules/jsx-a11y.js +11 -10
  19. package/eslint/rules/playwright-test.js +25 -26
  20. package/eslint/rules/possible-errors.js +38 -45
  21. package/eslint/rules/react.js +105 -104
  22. package/eslint/rules/stylistic.js +83 -84
  23. package/eslint/rules/typescript/extension.js +55 -39
  24. package/eslint/rules/typescript/import.js +16 -15
  25. package/eslint/rules/typescript/index.js +109 -121
  26. package/eslint/rules/typescript/naming-convention.js +71 -0
  27. package/eslint/rules/variables.js +34 -34
  28. package/eslint/withFiles.js +15 -0
  29. package/package.json +58 -56
  30. package/prettier/index.js +4 -11
  31. package/readme.md +181 -98
  32. package/stylelint/_base.js +2 -4
  33. package/stylelint/index.js +6 -7
  34. package/stylelint/modules.js +7 -8
  35. package/stylelint/standard.js +2 -5
  36. package/typescript/tsconfig.base.json +2 -1
  37. package/typescript/tsconfig.bundler.json +7 -3
  38. package/typescript/tsconfig.next.json +14 -6
  39. package/typescript/tsconfig.node.json +1 -1
  40. package/typescript/tsconfig.node18.json +4 -7
  41. package/typescript/tsconfig.node20.json +4 -7
  42. package/typescript/tsconfig.node22.json +10 -0
  43. package/typescript/tsconfig.web.json +1 -1
  44. package/eslint/_base.js +0 -82
  45. package/eslint/astro.js +0 -40
  46. package/eslint/browser.js +0 -8
  47. package/eslint/cjs.js +0 -12
  48. package/eslint/jest.js +0 -28
  49. package/eslint/next.js +0 -38
  50. package/eslint/node.js +0 -8
  51. package/eslint/playwright-test.js +0 -8
  52. package/eslint/react.js +0 -18
  53. package/eslint/rules/import.js +0 -92
  54. package/eslint/rules/jest.js +0 -28
  55. package/eslint/rules/simple-import-sort.js +0 -23
  56. package/eslint/rules/tsdoc.js +0 -17
  57. package/eslint/rules/typescript/strict.js +0 -18
  58. package/eslint/typescript.js +0 -26
  59. package/eslint/utils/require-package.js +0 -44
package/readme.md CHANGED
@@ -7,26 +7,27 @@
7
7
  - [TypeScript](#typescript)
8
8
  - [Stylelint](#stylelint)
9
9
 
10
- > This package originated from [Vercel's style guide](https://github.com/vercel/style-guide).
10
+ > This package originated from [Vercel's style guide](https://github.com/vercel/style-guide),
11
+ > but has since diverged in both architecture and rules.
11
12
 
12
13
  ## installation
13
14
 
14
15
  Install `@haltcase/style` with your preferred package manager:
15
16
 
16
17
  ```sh
18
+ # pnpm
19
+ pnpm add --save-dev @haltcase/style
20
+
17
21
  # npm
18
22
  npm i --save-dev @haltcase/style
19
23
 
20
- # pnpm
21
- pnpm i --save-dev @haltcase/style
22
-
23
24
  # yarn
24
25
  yarn add --dev @haltcase/style
25
26
  ```
26
27
 
27
28
  > [!NOTE]
28
29
  > Some scenarios require additional peer dependencies.
29
- > See the [Prettier](#prettier) and [ESLint](#eslint) sections.
30
+ > See the [Prettier](#prettier), [ESLint](#eslint), and [Stylelint](#stylelint) sections.
30
31
 
31
32
  ## usage
32
33
 
@@ -54,73 +55,156 @@ Add the following in `package.json`:
54
55
  >
55
56
  > See: https://eslint.org/docs/user-guide/getting-started#installation-and-usage
56
57
 
57
- Several ESLint configs are available which can be combined.
58
+ > [!IMPORTANT]
59
+ > This config requires ESLint 9+ and the use of
60
+ > [flat config](https://eslint.org/docs/latest/extend/plugin-migration-flat-config).
58
61
 
59
- Start with at least one of these base configs, which should always be first in `extends`:
62
+ At its simplest, your config might look like this for a general purpose
63
+ project:
60
64
 
61
- - `@haltcase/style/eslint/browser`
62
- - `@haltcase/style/eslint/node`
65
+ ```js
66
+ // eslint.config.js
67
+ import { getEslintConfig } from "@haltcase/style/eslint";
63
68
 
64
- > [!TIP]
65
- > You can scope configs so they only target specific files.
66
- >
67
- > See: [Scoped configuration with `overrides`](#scoped-configuration-with-overrides).
69
+ export default getEslintConfig();
70
+ ```
71
+
72
+ TypeScript support is enabled by default by applying TypeScript-specific
73
+ configurations to files with TypeScript file extensions
74
+ (`ts`, `tsx`, `mts`, and `mtsx`). You may need to apply your own project-specific
75
+ configurations — see [Configuring ESLint for TypeScript](#configuring-eslint-for-typescript)
76
+ for details on how to do so.
68
77
 
69
- The following additional configs are available:
78
+ #### ESLint customization
70
79
 
71
- - `@haltcase/style/eslint/astro` (requires `eslint-plugin-astro` to be installed)
72
- - `@haltcase/style/eslint/cjs`
73
- - `@haltcase/style/eslint/jest`
74
- - `@haltcase/style/eslint/next` (requires `@next/eslint-plugin-next` to be installed at the same version as `next`)
75
- - `@haltcase/style/eslint/playwright-test`
76
- - `@haltcase/style/eslint/react`
77
- - `@haltcase/style/eslint/typescript` (requires `typescript` to be installed and [additional configuration](#configuring-eslint-for-typescript))
80
+ You can enable more rules for your project with configuration options:
81
+
82
+ ```js
83
+ // eslint.config.js
84
+ import { getEslintConfig } from "@haltcase/style/eslint";
78
85
 
79
- Be sure to use `require.resolve` to reference these configs — ESLint requires absolute paths ([eslint/eslint#9188](https://github.com/eslint/eslint/issues/9188)).
86
+ export default getEslintConfig({
87
+ // for browser environments
88
+ browser: true,
80
89
 
81
- For example, to use the shared ESLint config(s) in a Next.js project, set the
82
- following in `.eslintrc.js`.
90
+ // treat *.js files as CommonJS instead of ES Modules
91
+ commonjs: true,
92
+
93
+ // for Next.js projects (implies `react`)
94
+ nextjs: true,
95
+
96
+ // for Node.js projects
97
+ node: true,
98
+
99
+ // for React
100
+ react: true
101
+ });
102
+ ```
103
+
104
+ And, of course, you may include configs as any part of a larger one:
83
105
 
84
106
  ```js
85
- module.exports = {
86
- extends: [
87
- require.resolve("@haltcase/style/eslint/browser"),
88
- require.resolve("@haltcase/style/eslint/react"),
89
- require.resolve("@haltcase/style/eslint/next")
90
- ]
91
- };
107
+ // eslint.config.js
108
+ import { getEslintConfig } from "@haltcase/style/eslint";
109
+
110
+ export default [
111
+ ...getEslintConfig({
112
+ nextjs: true
113
+ }),
114
+
115
+ {
116
+ name: "Customizations",
117
+ files: ["src/lib/**"],
118
+ rules: {
119
+ "no-unused-vars": "warn"
120
+ }
121
+ }
122
+ ];
92
123
  ```
93
124
 
125
+ You can be more granular with your customizations by using the modular configs
126
+ also exported from `@haltcase/style/eslint`:
127
+
128
+ ```js
129
+ // eslint.config.js
130
+ import {
131
+ getEslintBaseConfig,
132
+ getEslintCommonJsConfig,
133
+ getEslintNodeConfig,
134
+ getEslintReactConfig,
135
+ withFiles
136
+ } from "@haltcase/style/eslint";
137
+
138
+ export default [
139
+ // use the base config for everything by default
140
+ ...getEslintBaseConfig(),
141
+
142
+ // apply Common JS rules to some files
143
+ ...getEslintCommonJsConfig().map((config) => ({
144
+ ...config,
145
+ files: ["src/legacy/cjs/**/*.js"]
146
+ })),
147
+
148
+ // apply React rules to some files
149
+ // (`withFiles` is equivalent to the above `map`)
150
+ ...withFiles(getEslintReactConfig(), ["src/frontend/**/*.{ts,js,tsx,jsx}"]),
151
+
152
+ ...withFiles(getEslintNodeConfig(), ["src/backend/**/*.{ts,js}"]),
153
+
154
+ {
155
+ name: "Customizations",
156
+ files: ["src/lib/**"],
157
+ rules: {
158
+ "no-unused-vars": "warn"
159
+ }
160
+ }
161
+ ];
162
+ ```
163
+
164
+ > [!TIP]
165
+ > See the ESLint documentation for more details on using configs:
166
+ > https://eslint.org/docs/latest/use/configure/combine-configs
167
+
94
168
  #### Configuring ESLint for TypeScript
95
169
 
96
170
  Some of the rules enabled in the TypeScript config require additional type
97
- information, so you'll need to use `project: true` and `tsconfigRootDir` or
98
- explicitly supply the path(s) to your `tsconfig.json` per the typescript-eslint
99
- documentation.
171
+ information. By default, this config will configure `parserOptions` with
172
+ [`projectService: true`](https://typescript-eslint.io/packages/parser#projectservice).
100
173
 
101
- For more information, see: https://typescript-eslint.io/linting/typed-linting/
174
+ You can customize this behavior with the `typescriptProjectServiceOptions` option:
102
175
 
103
176
  ```js
104
- module.exports = {
105
- root: true,
106
- extends: [
107
- require.resolve("@haltcase/style/eslint/node"),
108
- require.resolve("@haltcase/style/eslint/typescript")
109
- ],
110
- parserOptions: {
111
- project: true,
112
- tsconfigRootDir: __dirname
113
- },
114
- settings: {
115
- "import/resolver": {
116
- typescript: {
117
- project
118
- }
177
+ import { getEslintConfig } from "@haltcase/style/eslint";
178
+
179
+ export default [
180
+ ...getEslintConfig({
181
+ typescriptProjectServiceOptions: {
182
+ allowDefaultProject: ["*.js"]
183
+ }
184
+ })
185
+ ];
186
+ ```
187
+
188
+ If you need to further customize the TypeScript behavior, use a separate config
189
+ with your own options, for example:
190
+
191
+ ```js
192
+ import { getEslintConfig } from "@haltcase/style/eslint";
193
+
194
+ export default [
195
+ ...getEslintConfig(),
196
+
197
+ {
198
+ files: ["*.{c,m,}ts{x,}"],
199
+ parserOptions: {
200
+ project: true
119
201
  }
120
202
  }
121
- };
203
+ ];
122
204
  ```
123
205
 
206
+ For more information, see: https://typescript-eslint.io/linting/typed-linting/
207
+
124
208
  #### Configuring custom components for `jsx-a11y`
125
209
 
126
210
  It's common practice for React apps to have shared components like `Button`
@@ -130,63 +214,51 @@ via the `components` setting.
130
214
  The below list is not exhaustive.
131
215
 
132
216
  ```js
133
- module.exports = {
134
- root: true,
135
- extends: [require.resolve("@haltcase/style/eslint/react")],
136
- settings: {
137
- "jsx-a11y": {
138
- components: {
139
- Article: "article",
140
- Button: "button",
141
- Image: "img",
142
- Input: "input",
143
- Link: "a",
144
- Video: "video"
217
+ import { getEslintConfig } from "@haltcase/style/eslint";
218
+
219
+ export default [
220
+ getEslintConfig({
221
+ react: true
222
+ }),
223
+
224
+ {
225
+ settings: {
226
+ "jsx-a11y": {
227
+ components: {
228
+ Article: "article",
229
+ Button: "button",
230
+ Image: "img",
231
+ Input: "input",
232
+ Link: "a",
233
+ Video: "video"
234
+ }
145
235
  }
146
236
  }
147
237
  }
148
- };
149
- ```
150
-
151
- #### Scoped configuration with `overrides`
152
-
153
- ESLint configs can be scoped to include/exclude specific paths. This ensures
154
- that rules don't "leak" into places where those rules don't apply.
155
-
156
- In this example, Jest rules are only being applied to files matching Jest's
157
- default test match pattern.
158
-
159
- ```js
160
- module.exports = {
161
- extends: [require.resolve("@haltcase/style/eslint/node")],
162
- overrides: [
163
- {
164
- files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
165
- extends: [require.resolve("@haltcase/style/eslint/jest")]
166
- }
167
- ]
168
- };
238
+ ];
169
239
  ```
170
240
 
171
241
  ##### A note on file extensions
172
242
 
173
- By default, all TypeScript rules are scoped to files ending with `.ts` and
174
- `.tsx`.
243
+ By default, all TypeScript rules are scoped to files with extensions ending in
244
+ `ts` or `tsx`.
175
245
 
176
- However, when using overrides, file extensions must be included or ESLint will
177
- only include `.js` files.
246
+ If you need to override configuration for TypeScript files, make sure to
247
+ specify the `files` property or ESLint will
248
+ [only target `*.js` files](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores).
178
249
 
179
250
  ```js
180
- module.exports = {
181
- overrides: [
182
- {
183
- files: ["directory/**/*.[jt]s?(x)"],
184
- rules: {
185
- "my-rule": "off"
186
- }
251
+ export default [
252
+ ...getEslintConfig(),
253
+
254
+ {
255
+ // apply this config to js, ts, jsx, and tsx files
256
+ files: ["directory/**/*.[jt]s?(x)"],
257
+ rules: {
258
+ "my-rule": "off"
187
259
  }
188
- ]
189
- };
260
+ }
261
+ ];
190
262
  ```
191
263
 
192
264
  ### TypeScript
@@ -198,9 +270,10 @@ Several Typescript configs are available to cover various scenarios:
198
270
  | `@haltcase/style/typescript/base` | Baseline config, intended to be extended from. |
199
271
  | `@haltcase/style/typescript/bundler` | For use in bundled projects, most commonly [Vite](https://vitejs.dev/) + [React](https://react.dev). |
200
272
  | `@haltcase/style/typescript/next` | For use in [Next.js](https://nextjs.org/) projects. |
201
- | `@haltcase/style/typescript/node` | Default Node config, currently targeting Node 20. |
273
+ | `@haltcase/style/typescript/node` | Default Node config, currently targeting Node 22. |
202
274
  | `@haltcase/style/typescript/node18` | For projects targeting Node 18. |
203
275
  | `@haltcase/style/typescript/node20` | For projects targeting Node 20. |
276
+ | `@haltcase/style/typescript/node22` | For projects targeting Node 22. |
204
277
  | `@haltcase/style/typescript/web` | For use in web projects. |
205
278
 
206
279
  Typically, you'll only need to extend from one of these:
@@ -225,6 +298,16 @@ You could also combine them with an `extends` array in [Typescript 5+](https://d
225
298
  > [!TIP]
226
299
  > Run `tsc --showConfig` to see the result of the combined configs.
227
300
 
301
+ #### TypeScript includes, excludes, and `paths` aliases
302
+
303
+ Some TypeScript configs set `include`, `exclude`, and `paths` for you with
304
+ common options. Currently:
305
+
306
+ | Name | Description |
307
+ | ------------------------------------ | --------------------------------------------------------------------------------- |
308
+ | `@haltcase/style/typescript/bundler` | Includes `@/*` → `src/*` path alias. |
309
+ | `@haltcase/style/typescript/next` | Includes `@/*` → `src/*` path alias and Next.js `include` and `exclude` settings. |
310
+
228
311
  ### Stylelint
229
312
 
230
313
  To format and check CSS with Stylelint, install the `stylelint` package and
@@ -1,10 +1,8 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { defineConfig } from "stylelint-define-config";
4
4
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
-
7
- module.exports = defineConfig({
5
+ export const stylelintBase = defineConfig({
8
6
  extends: [
9
7
  "stylelint-config-standard",
10
8
  "stylelint-config-html",
@@ -1,16 +1,15 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
+ import { defineConfig } from "stylelint-define-config";
4
5
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
+ import { stylelintBase } from "./_base.js";
6
7
 
7
- const base = require("./_base.js");
8
-
9
- module.exports = defineConfig({
10
- ...base,
8
+ export default defineConfig({
9
+ ...stylelintBase,
11
10
 
12
11
  rules: {
13
- ...base.rules,
12
+ ...stylelintBase.rules,
14
13
 
15
14
  // disable identifier casing rules
16
15
  "custom-media-pattern": null,
@@ -1,18 +1,17 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
+ import { defineConfig } from "stylelint-define-config";
4
5
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
+ import { stylelintBase } from "./_base.js";
6
7
 
7
- const base = require("./_base.js");
8
+ const camelCaseRegex = /^[a-z][a-zA-Z0-9]+$/;
8
9
 
9
- const camelCaseRegex = /^(?<=^|[^A-Z_a-z])_*[a-z]+[A-Z_a-z]*$/;
10
-
11
- module.exports = defineConfig({
12
- ...base,
10
+ export default defineConfig({
11
+ ...stylelintBase,
13
12
 
14
13
  rules: {
15
- ...base.rules,
14
+ ...stylelintBase.rules,
16
15
 
17
16
  "custom-media-pattern": camelCaseRegex,
18
17
 
@@ -1,7 +1,4 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
-
5
- const base = require("./_base.js");
6
-
7
- module.exports = base;
4
+ export { stylelintBase as default } from "./_base.js";
@@ -8,6 +8,7 @@
8
8
  "noFallthroughCasesInSwitch": true,
9
9
  "noUncheckedIndexedAccess": true,
10
10
  "skipLibCheck": true,
11
- "strict": true
11
+ "strict": true,
12
+ "useDefineForClassFields": true
12
13
  }
13
14
  }
@@ -2,12 +2,16 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "extends": "./tsconfig.base.json",
4
4
  "compilerOptions": {
5
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
6
  "jsx": "react-jsx",
7
- "module": "ESNext",
7
+ "module": "esnext",
8
8
  "moduleResolution": "bundler",
9
9
  "noEmit": true,
10
+ "allowImportingTsExtensions": true,
10
11
  "resolveJsonModule": true,
11
- "target": "ES2015"
12
+ "target": "es2020",
13
+ "paths": {
14
+ "@/*": ["${configDir}/src/*"]
15
+ }
12
16
  }
13
17
  }
@@ -7,20 +7,28 @@
7
7
  "incremental": true,
8
8
  "isolatedModules": true,
9
9
  "jsx": "preserve",
10
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
11
- "module": "ESNext",
12
- "moduleResolution": "node",
10
+ "lib": ["dom", "dom.iterable", "esnext"],
11
+ "module": "esnext",
12
+ "moduleResolution": "bundler",
13
13
  "noEmit": true,
14
14
  "resolveJsonModule": true,
15
15
  "skipLibCheck": true,
16
16
  "strict": true,
17
- "target": "ES5",
17
+ "target": "ES2022",
18
+ "paths": {
19
+ "@/*": ["${configDir}/src/*"]
20
+ },
18
21
  "plugins": [
19
22
  {
20
23
  "name": "next"
21
24
  }
22
25
  ]
23
26
  },
24
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
- "exclude": ["node_modules"]
27
+ "include": [
28
+ "${configDir}/next-env.d.ts",
29
+ "${configDir}/**/*.ts",
30
+ "${configDir}/**/*.tsx",
31
+ "${configDir}/.next/types/**/*.ts"
32
+ ],
33
+ "exclude": ["${configDir}/**/node_modules"]
26
34
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "./tsconfig.node20.json"
3
+ "extends": "./tsconfig.node22.json"
4
4
  }
@@ -2,12 +2,9 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "extends": "./tsconfig.base.json",
4
4
  "compilerOptions": {
5
- "declaration": true,
6
- "lib": ["ES2023"],
7
- "module": "Node16",
8
- "moduleResolution": "nodenext",
9
- "resolveJsonModule": true,
10
- "sourceMap": true,
11
- "target": "ES2022"
5
+ "lib": ["es2023"],
6
+ "module": "node16",
7
+ "target": "es2022",
8
+ "moduleResolution": "node16"
12
9
  }
13
10
  }
@@ -2,12 +2,9 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "extends": "./tsconfig.base.json",
4
4
  "compilerOptions": {
5
- "declaration": true,
6
- "lib": ["ES2023"],
7
- "module": "Node16",
8
- "moduleResolution": "nodenext",
9
- "resolveJsonModule": true,
10
- "sourceMap": true,
11
- "target": "ES2022"
5
+ "lib": ["es2023"],
6
+ "module": "node16",
7
+ "target": "es2022",
8
+ "moduleResolution": "node16"
12
9
  }
13
10
  }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.base.json",
4
+ "compilerOptions": {
5
+ "lib": ["es2023"],
6
+ "module": "node16",
7
+ "target": "es2022",
8
+ "moduleResolution": "node16"
9
+ }
10
+ }
@@ -3,6 +3,6 @@
3
3
  "extends": "./tsconfig.base.json",
4
4
  "compilerOptions": {
5
5
  "module": "commonjs",
6
- "target": "ES2015"
6
+ "target": "es2020"
7
7
  }
8
8
  }
package/eslint/_base.js DELETED
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- const {
4
- configFiles,
5
- ecmaVersion,
6
- javascriptFiles,
7
- levels: { off },
8
- scriptFiles,
9
- commonJsOverrides
10
- } = require("./constants");
11
-
12
- // see https://github.com/eslint/eslint/issues/3458
13
- require("@rushstack/eslint-patch/modern-module-resolution");
14
-
15
- /**
16
- * This is the base for both our browser and Node ESLint config files.
17
- */
18
- module.exports = {
19
- extends: [
20
- "eslint:recommended",
21
- "plugin:import/recommended",
22
- "plugin:eslint-comments/recommended",
23
- "prettier",
24
- require.resolve("./rules/best-practice"),
25
- require.resolve("./rules/es2015"),
26
- require.resolve("./rules/import"),
27
- require.resolve("./rules/possible-errors"),
28
- require.resolve("./rules/simple-import-sort"),
29
- require.resolve("./rules/stylistic"),
30
- require.resolve("./rules/unicorn"),
31
- require.resolve("./rules/variables")
32
- ],
33
- env: {
34
- [`es${ecmaVersion}`]: true
35
- },
36
- // Report unused `eslint-disable` comments.
37
- reportUnusedDisableDirectives: true,
38
- // Tell ESLint not to ignore dot-files, which are ignored by default.
39
- ignorePatterns: ["!.*.js"],
40
- // Global settings used by all overrides.
41
- settings: {
42
- // Use the Node resolver by default.
43
- "import/resolver": { node: {} }
44
- },
45
- // Global parser options.
46
- parserOptions: {
47
- ecmaVersion,
48
- sourceType: "module"
49
- },
50
- overrides: [
51
- {
52
- files: javascriptFiles,
53
- parser: "@babel/eslint-parser",
54
- parserOptions: {
55
- requireConfigFile: false
56
- }
57
- },
58
-
59
- // config files for third-party tools likely require default exports
60
- // (e.g., next.config.mjs)
61
- {
62
- files: configFiles,
63
- rules: {
64
- "import/no-default-export": off
65
- }
66
- },
67
-
68
- // development-only helper scripts & prisma database scripts
69
- {
70
- files: scriptFiles,
71
- rules: {
72
- "no-console": "off",
73
- "unicorn/no-process-exit": "off"
74
- }
75
- },
76
-
77
- {
78
- files: ["**/*.cjs"],
79
- ...commonJsOverrides
80
- }
81
- ]
82
- };