@vllnt/eslint-config 2.1.0-canary.e107250 → 2.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 +130 -6
- package/flat/convex-rules/_utils.js +1 -0
- package/flat/convex-rules/namespace-separation.js +3 -3
- package/flat/convex-rules/standard-filenames.js +2 -2
- package/flat/core/typescript.js +60 -50
- package/flat/ignores.d.ts +4 -0
- package/flat/ignores.js +21 -0
- package/flat/index.d.ts +2 -0
- package/flat/index.js +2 -0
- package/flat/nextjs.js +39 -6
- package/flat/playwright.d.ts +4 -0
- package/flat/playwright.js +33 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Every rule enforces `error` — no warnings, no compromises.
|
|
|
20
20
|
- **ESLint v9+ flat config only** — no legacy `.eslintrc`
|
|
21
21
|
- **TypeScript-first** with `strictTypeChecked` + `stylisticTypeChecked`
|
|
22
22
|
- **Prettier built-in** — formatting as lint errors, zero config
|
|
23
|
-
- **
|
|
23
|
+
- **8 presets** — Base, React, Next.js, Node.js, Convex, Turbo, Boundaries, Playwright — plus a shared `ignores` list
|
|
24
24
|
- **Composable** — spread arrays, override anything
|
|
25
25
|
|
|
26
26
|
## Install
|
|
@@ -45,8 +45,8 @@ export default [...nextjs];
|
|
|
45
45
|
|
|
46
46
|
Each preset is an array — spread it into your flat config. Base and its React,
|
|
47
47
|
Next.js, and Node.js variants enable `projectService: true` for type-aware linting.
|
|
48
|
-
Convex also enables it; Turbo and
|
|
49
|
-
for a language preset.
|
|
48
|
+
Convex also enables it; Turbo, Boundaries and Playwright are opt-in additions, not
|
|
49
|
+
replacements for a language preset.
|
|
50
50
|
|
|
51
51
|
## Presets
|
|
52
52
|
|
|
@@ -59,6 +59,8 @@ for a language preset.
|
|
|
59
59
|
| `@vllnt/eslint-config/convex` | Convex backends (4 official + 7 custom rules) |
|
|
60
60
|
| `@vllnt/eslint-config/turbo` | Turborepo cache rules (opt-in) |
|
|
61
61
|
| `@vllnt/eslint-config/boundaries` | Architecture boundary enforcement (opt-in) |
|
|
62
|
+
| `@vllnt/eslint-config/playwright` | Playwright test and config files (opt-in) |
|
|
63
|
+
| `@vllnt/eslint-config/ignores` | Shared ignores for build and test output (opt-in) |
|
|
62
64
|
|
|
63
65
|
## Composing presets
|
|
64
66
|
|
|
@@ -86,6 +88,113 @@ export default [
|
|
|
86
88
|
];
|
|
87
89
|
```
|
|
88
90
|
|
|
91
|
+
## Playwright
|
|
92
|
+
|
|
93
|
+
An opt-in addition, like Turbo and Boundaries: spread it after a language preset, which
|
|
94
|
+
registers the plugins and rules it adjusts.
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { nextjs } from "@vllnt/eslint-config/nextjs";
|
|
98
|
+
import { playwright } from "@vllnt/eslint-config/playwright";
|
|
99
|
+
|
|
100
|
+
export default [...nextjs, ...playwright];
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
It applies to `**/tests/e2e/**/*.{spec,setup}.ts`, `**/e2e/**/*.spec.ts` and
|
|
104
|
+
`**/playwright.config.{ts,mts}`, and relaxes three rules there:
|
|
105
|
+
|
|
106
|
+
| Rule | Change | Why |
|
|
107
|
+
| -------------------------------------- | ----------------------------- | ---------------------------------------------------------------------------- |
|
|
108
|
+
| `functional/no-loop-statements` | off | Tests and projects are generated per viewport, locale or route |
|
|
109
|
+
| `max-lines-per-function` | off | A `describe` block or setup step covers a whole page or sign-in flow |
|
|
110
|
+
| `@typescript-eslint/naming-convention` | object literal keys unchecked | Expected-data tables use the page's labels and the API's field names as keys |
|
|
111
|
+
|
|
112
|
+
Everything else stays on, including `write-good-comments` and
|
|
113
|
+
`unicorn/prevent-abbreviations`: comments and names in tests follow the same rules as
|
|
114
|
+
app code. Variable and function names are still checked, and so are helpers in
|
|
115
|
+
`tests/e2e/` that are not `*.spec.ts` or `*.setup.ts`.
|
|
116
|
+
|
|
117
|
+
## Shared ignores
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
import { ignores } from "@vllnt/eslint-config/ignores";
|
|
121
|
+
import { nextjs } from "@vllnt/eslint-config/nextjs";
|
|
122
|
+
|
|
123
|
+
export default [...ignores, ...nextjs];
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`ignores` covers `coverage/`, `playwright-report/`, `test-results/`, `.turbo/` and
|
|
127
|
+
`.worktrees/` at any depth, and `dist/` and `build/` at the config root, so a source
|
|
128
|
+
folder with one of those names deeper in the tree is still linted. ESLint already
|
|
129
|
+
ignores `node_modules/` and `.git/`, and the Next.js preset adds its own output. Tool
|
|
130
|
+
config files such as `next.config.*` or `postcss.config.*` stay yours to ignore,
|
|
131
|
+
because whether they sit inside your `tsconfig.json` is a project decision.
|
|
132
|
+
|
|
133
|
+
## Inspecting and profiling ESLint
|
|
134
|
+
|
|
135
|
+
Run these commands from the consuming project's root so they use its local ESLint,
|
|
136
|
+
configuration, TypeScript project, and installed version of this package. No extra
|
|
137
|
+
inspector dependency is required.
|
|
138
|
+
|
|
139
|
+
### Inspect the effective configuration
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
pnpm exec eslint --inspect-config
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
ESLint downloads on demand (via `npx`) and launches the Config Inspector for the
|
|
146
|
+
project's config file; it takes no file argument. Use its file-matching view to see
|
|
147
|
+
which config objects match a path, where a rule was defined, and the final rule
|
|
148
|
+
options. Check representative files from each environment (for example,
|
|
149
|
+
application code, tests, generated code, and Convex code) because flat config is
|
|
150
|
+
resolved per file.
|
|
151
|
+
|
|
152
|
+
The inspector explains configuration; it does **not** profile lint performance.
|
|
153
|
+
|
|
154
|
+
### Find slow rules
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
TIMING=1 pnpm exec eslint .
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`TIMING=1` prints the ten rules with the highest aggregate execution time after a
|
|
161
|
+
normal lint run. Set `TIMING=all` to display every rule. Treat the percentages as
|
|
162
|
+
directional: type-aware rules often share the one-time cost of creating a
|
|
163
|
+
TypeScript program, so one cold run does not prove that the highest-ranked rule is
|
|
164
|
+
the root cause.
|
|
165
|
+
|
|
166
|
+
### Find slow files and collect granular stats
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
pnpm exec eslint . \
|
|
170
|
+
--stats \
|
|
171
|
+
--format json-with-metadata \
|
|
172
|
+
--output-file eslint-stats.json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The built-in `json-with-metadata` formatter preserves each file's `stats`,
|
|
176
|
+
including parse, fix, and per-rule lint timings. Use the resulting JSON with a
|
|
177
|
+
stats-aware analyzer or a small script to group by `filePath` and rule ID. Delete
|
|
178
|
+
or gitignore the generated report; it can contain local paths and lint messages.
|
|
179
|
+
|
|
180
|
+
### Profiling best practices
|
|
181
|
+
|
|
182
|
+
1. Profile the same file set and command used by CI, without `--fix`.
|
|
183
|
+
2. Run once to warm the operating system's file cache, then compare several runs.
|
|
184
|
+
Each CLI run is a fresh process, so TypeScript program setup is part of every timing.
|
|
185
|
+
3. Disable ESLint's result cache while benchmarking; cached files have no useful
|
|
186
|
+
rule timings.
|
|
187
|
+
4. Separate parse time from rule time. High parse time usually points to typed
|
|
188
|
+
linting or TypeScript project scope rather than an individual rule.
|
|
189
|
+
5. Use Config Inspector on the slowest representative files to confirm which
|
|
190
|
+
presets and type-aware rules actually apply before changing configuration.
|
|
191
|
+
6. Prefer narrowing ignores, file globs, or TypeScript project scope over disabling
|
|
192
|
+
correctness rules. Re-run the same baseline after every change.
|
|
193
|
+
|
|
194
|
+
See ESLint's official documentation for [Config Inspector](https://eslint.org/docs/latest/use/configure/debug#use-the-config-inspector),
|
|
195
|
+
[rule profiling](https://eslint.org/docs/latest/extend/custom-rules#profile-rule-performance),
|
|
196
|
+
and [stats data](https://eslint.org/docs/latest/extend/stats).
|
|
197
|
+
|
|
89
198
|
---
|
|
90
199
|
|
|
91
200
|
## What's included
|
|
@@ -97,7 +206,6 @@ export default [
|
|
|
97
206
|
| [@eslint/js](https://eslint.org/docs/latest/rules/) | ESLint recommended rules |
|
|
98
207
|
| [typescript-eslint](https://typescript-eslint.io/) | `strictTypeChecked` + `stylisticTypeChecked` |
|
|
99
208
|
| [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) | Prettier as ESLint errors |
|
|
100
|
-
| [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) | Disables conflicting rules |
|
|
101
209
|
| [eslint-plugin-perfectionist](https://perfectionist.dev/) | Import/object/type sorting |
|
|
102
210
|
| [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) | Modern JS best practices |
|
|
103
211
|
| [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) | Import ordering |
|
|
@@ -123,7 +231,22 @@ Everything in React, plus:
|
|
|
123
231
|
| ----------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
124
232
|
| [@next/eslint-plugin-next](https://nextjs.org/docs/app/api-reference/config/eslint) | Recommended + core web vitals (all `error`) |
|
|
125
233
|
|
|
126
|
-
Route
|
|
234
|
+
- **Route handlers** (`app/**/route.{js,jsx,ts}`) may export `GET`, `HEAD`, `POST`,
|
|
235
|
+
`PUT`, `PATCH`, `DELETE` and `OPTIONS` as functions. Any other name keeps the base
|
|
236
|
+
naming rule, so `FETCH`, `Get`, a non-exported `GET`, or `GET` outside a route file
|
|
237
|
+
still fail. Config exports such as `dynamic`, `revalidate` and `runtime` are
|
|
238
|
+
camelCase and already pass. `route.tsx` follows the `.tsx` rule, which accepts
|
|
239
|
+
PascalCase functions, so `GET` and JSX helpers pass there.
|
|
240
|
+
- Under `app/api/**/route.*`, the naming rule stays off, and only those methods and
|
|
241
|
+
`generateStaticParams` may be exported as functions.
|
|
242
|
+
- `functional/no-loop-statements` stays on in route handlers; build the response with
|
|
243
|
+
`map` or `reduce`.
|
|
244
|
+
- `.next/`, `out/`, `build/` and `next-env.d.ts` are ignored.
|
|
245
|
+
- Pages and layouts get a `max-lines-per-function` override.
|
|
246
|
+
|
|
247
|
+
In every preset, object and type property names that need quotes (`'content-type'`,
|
|
248
|
+
`'@type'`, `'x-default'`) are exempt from the naming convention, because an external
|
|
249
|
+
format fixes their spelling. Names that do not need quotes (`user_id`) are still checked.
|
|
127
250
|
|
|
128
251
|
### Opt-in
|
|
129
252
|
|
|
@@ -209,6 +332,7 @@ convex/
|
|
|
209
332
|
queries.ts query(), internalQuery()
|
|
210
333
|
mutations.ts mutation(), internalMutation()
|
|
211
334
|
actions.ts action(), internalAction()
|
|
335
|
+
node_actions.ts action(), internalAction() in the Node.js runtime ("use node")
|
|
212
336
|
internal_mutations.ts internalMutation() (optional split)
|
|
213
337
|
validators.ts v.* validators + types
|
|
214
338
|
schema.ts table definitions
|
|
@@ -247,7 +371,7 @@ Add to `.vscode/settings.json` for monorepo support:
|
|
|
247
371
|
- [Contributing](CONTRIBUTING.md) · [Issues](https://github.com/vllnt/eslint-config/issues)
|
|
248
372
|
- [Security policy and private vulnerability reporting](SECURITY.md)
|
|
249
373
|
|
|
250
|
-
npm `latest` is stable `2.
|
|
374
|
+
npm `latest` is stable `2.1.0` at this audit. `@canary` selects moving prerelease
|
|
251
375
|
builds; pin and test them before adoption.
|
|
252
376
|
|
|
253
377
|
## Author
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Enforces that Convex factory functions only appear in their designated files:
|
|
4
4
|
* - query / internalQuery -> queries.ts
|
|
5
5
|
* - mutation / internalMutation -> mutations.ts or internal_mutations.ts
|
|
6
|
-
* - action / internalAction -> actions.ts
|
|
6
|
+
* - action / internalAction -> actions.ts or node_actions.ts
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { getConvexFactory, getBasename, getFilename } from './_utils.js'
|
|
@@ -29,8 +29,8 @@ function getAllowedFile(factoryType) {
|
|
|
29
29
|
case 'action':
|
|
30
30
|
case 'internalAction':
|
|
31
31
|
return {
|
|
32
|
-
expectedFile: 'actions.ts',
|
|
33
|
-
isAllowed: (b) => b === 'actions.ts',
|
|
32
|
+
expectedFile: 'actions.ts or node_actions.ts',
|
|
33
|
+
isAllowed: (b) => b === 'actions.ts' || b === 'node_actions.ts',
|
|
34
34
|
}
|
|
35
35
|
default:
|
|
36
36
|
return null
|
|
@@ -17,11 +17,11 @@ const rule = {
|
|
|
17
17
|
type: 'problem',
|
|
18
18
|
docs: {
|
|
19
19
|
description:
|
|
20
|
-
'Convex factory exports must be in standard-named files (queries.ts, mutations.ts, actions.ts, internal_mutations.ts)',
|
|
20
|
+
'Convex factory exports must be in standard-named files (queries.ts, mutations.ts, actions.ts, internal_mutations.ts, node_actions.ts)',
|
|
21
21
|
},
|
|
22
22
|
messages: {
|
|
23
23
|
wrongFilename:
|
|
24
|
-
'Convex {{factoryType}}() exports must be in a standard-named file (queries.ts, mutations.ts, actions.ts, or
|
|
24
|
+
'Convex {{factoryType}}() exports must be in a standard-named file (queries.ts, mutations.ts, actions.ts, internal_mutations.ts, or node_actions.ts). Found in "{{filename}}".',
|
|
25
25
|
},
|
|
26
26
|
schema: [],
|
|
27
27
|
},
|
package/flat/core/typescript.js
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
export const namingConvention = [
|
|
2
|
+
{
|
|
3
|
+
selector: 'default',
|
|
4
|
+
format: ['camelCase'],
|
|
5
|
+
leadingUnderscore: 'allow',
|
|
6
|
+
trailingUnderscore: 'allow',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
selector: 'import',
|
|
10
|
+
format: ['camelCase', 'PascalCase'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
selector: 'variable',
|
|
14
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
15
|
+
leadingUnderscore: 'allow',
|
|
16
|
+
trailingUnderscore: 'allow',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
selector: ['variableLike'],
|
|
20
|
+
format: ['camelCase'],
|
|
21
|
+
leadingUnderscore: 'allow',
|
|
22
|
+
trailingUnderscore: 'allow',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
selector: 'typeLike',
|
|
26
|
+
format: ['PascalCase'],
|
|
27
|
+
custom: {
|
|
28
|
+
regex: '^(I|T)[A-Z]',
|
|
29
|
+
match: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
selector: 'typeParameter',
|
|
34
|
+
format: ['PascalCase'],
|
|
35
|
+
prefix: ['T'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
selector: 'enumMember',
|
|
39
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
selector: 'objectLiteralProperty',
|
|
43
|
+
format: null,
|
|
44
|
+
filter: {
|
|
45
|
+
regex: '^/',
|
|
46
|
+
match: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
// Keys that need quotes (`content-type`, `@type`, `x-default`) come from an
|
|
51
|
+
// external format, so their spelling is not ours to rename.
|
|
52
|
+
selector: ['objectLiteralProperty', 'typeProperty'],
|
|
53
|
+
modifiers: ['requiresQuotes'],
|
|
54
|
+
format: null,
|
|
55
|
+
},
|
|
56
|
+
]
|
|
57
|
+
|
|
1
58
|
export const typescriptConfig = {
|
|
2
59
|
rules: {
|
|
3
60
|
'no-restricted-syntax': [
|
|
@@ -19,56 +76,7 @@ export const typescriptConfig = {
|
|
|
19
76
|
'Use optional properties instead of unions with `undefined` (e.g. `email?: string`).',
|
|
20
77
|
},
|
|
21
78
|
],
|
|
22
|
-
'@typescript-eslint/naming-convention': [
|
|
23
|
-
'error',
|
|
24
|
-
{
|
|
25
|
-
selector: 'default',
|
|
26
|
-
format: ['camelCase'],
|
|
27
|
-
leadingUnderscore: 'allow',
|
|
28
|
-
trailingUnderscore: 'allow',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
selector: 'import',
|
|
32
|
-
format: ['camelCase', 'PascalCase'],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
selector: 'variable',
|
|
36
|
-
format: ['camelCase', 'UPPER_CASE'],
|
|
37
|
-
leadingUnderscore: 'allow',
|
|
38
|
-
trailingUnderscore: 'allow',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
selector: ['variableLike'],
|
|
42
|
-
format: ['camelCase'],
|
|
43
|
-
leadingUnderscore: 'allow',
|
|
44
|
-
trailingUnderscore: 'allow',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
selector: 'typeLike',
|
|
48
|
-
format: ['PascalCase'],
|
|
49
|
-
custom: {
|
|
50
|
-
regex: '^(I|T)[A-Z]',
|
|
51
|
-
match: false,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
selector: 'typeParameter',
|
|
56
|
-
format: ['PascalCase'],
|
|
57
|
-
prefix: ['T'],
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
selector: 'enumMember',
|
|
61
|
-
format: ['camelCase', 'UPPER_CASE'],
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
selector: 'objectLiteralProperty',
|
|
65
|
-
format: null,
|
|
66
|
-
filter: {
|
|
67
|
-
regex: '^/',
|
|
68
|
-
match: true,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
],
|
|
79
|
+
'@typescript-eslint/naming-convention': ['error', ...namingConvention],
|
|
72
80
|
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
73
81
|
'@typescript-eslint/prefer-readonly': 'error',
|
|
74
82
|
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
@@ -96,6 +104,8 @@ export const typescriptConfig = {
|
|
|
96
104
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
97
105
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
98
106
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
107
|
+
// New in typescript-eslint 8.73.0 `strictTypeChecked`; enabling it is a breaking change (#31).
|
|
108
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': 'off',
|
|
99
109
|
'@typescript-eslint/no-extraneous-class': 'off',
|
|
100
110
|
'@typescript-eslint/no-base-to-string': 'off',
|
|
101
111
|
'@typescript-eslint/no-unnecessary-condition': 'off',
|
package/flat/ignores.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Generated and tool-owned output that is never worth linting, shared so each
|
|
2
|
+
// repo stops copying (and drifting from) the same list. Tool-specific names
|
|
3
|
+
// match at any depth; generic names (`dist`, `build`) match only at the config
|
|
4
|
+
// root so a source folder with that name deeper in the tree stays linted.
|
|
5
|
+
// ESLint already ignores `**/node_modules/` and `.git/`. The Next.js preset
|
|
6
|
+
// adds `.next`, `out` and `next-env.d.ts` itself.
|
|
7
|
+
export const ignores = [
|
|
8
|
+
{
|
|
9
|
+
ignores: [
|
|
10
|
+
'**/.turbo/**',
|
|
11
|
+
'**/.worktrees/**',
|
|
12
|
+
'**/coverage/**',
|
|
13
|
+
'**/playwright-report/**',
|
|
14
|
+
'**/test-results/**',
|
|
15
|
+
'build/**',
|
|
16
|
+
'dist/**',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
export default ignores
|
package/flat/index.d.ts
CHANGED
package/flat/index.js
CHANGED
package/flat/nextjs.js
CHANGED
|
@@ -6,6 +6,7 @@ import { imports } from './core/imports.js'
|
|
|
6
6
|
import { format } from './core/format.js'
|
|
7
7
|
import { unicornConfig, unicornTsx, unicornFilename } from './core/unicorn.js'
|
|
8
8
|
import {
|
|
9
|
+
namingConvention,
|
|
9
10
|
typescriptConfig,
|
|
10
11
|
typescriptTsx,
|
|
11
12
|
typescriptTest,
|
|
@@ -13,7 +14,22 @@ import {
|
|
|
13
14
|
} from './core/typescript.js'
|
|
14
15
|
import { reactConfig } from './core/react.js'
|
|
15
16
|
|
|
17
|
+
// The methods Next.js 16 accepts as route handler exports (route.md).
|
|
18
|
+
const HTTP_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
|
|
19
|
+
const httpMethodPattern = HTTP_METHODS.join('|')
|
|
20
|
+
// `generateStaticParams` is the one other function a route file may export;
|
|
21
|
+
// the segment config exports (`dynamic`, `revalidate`, `runtime`, ...) are
|
|
22
|
+
// camelCase constants, so the base naming rule already accepts them.
|
|
23
|
+
const routeFunctionPattern = [...HTTP_METHODS, 'generateStaticParams'].join('|')
|
|
24
|
+
const routeExportMessage = `Only the HTTP method handlers (${HTTP_METHODS.join(', ')}) and generateStaticParams may be exported as functions from route.ts`
|
|
25
|
+
|
|
16
26
|
export const nextjs = tseslint.config(
|
|
27
|
+
{
|
|
28
|
+
// Next.js build output and generated files: the defaults of `eslint-config-next`.
|
|
29
|
+
// Generic names match only at the config root so a source folder called
|
|
30
|
+
// `build` or `out` deeper in the tree stays linted.
|
|
31
|
+
ignores: ['**/.next/**', '**/next-env.d.ts', 'build/**', 'out/**'],
|
|
32
|
+
},
|
|
17
33
|
eslint.configs.recommended,
|
|
18
34
|
...tseslint.configs.strictTypeChecked,
|
|
19
35
|
...tseslint.configs.stylisticTypeChecked,
|
|
@@ -59,6 +75,25 @@ export const nextjs = tseslint.config(
|
|
|
59
75
|
'max-lines-per-function': 'off',
|
|
60
76
|
},
|
|
61
77
|
},
|
|
78
|
+
{
|
|
79
|
+
// Route handlers are named after the HTTP method, so accept exactly those
|
|
80
|
+
// exported function names; every other name keeps the base convention.
|
|
81
|
+
// Not `.tsx`: `typescriptTsx` already accepts PascalCase functions there
|
|
82
|
+
// (so `GET` passes), and a rule here would replace it, not add to it.
|
|
83
|
+
files: ['**/app/**/route.{js,jsx,ts}'],
|
|
84
|
+
rules: {
|
|
85
|
+
'@typescript-eslint/naming-convention': [
|
|
86
|
+
'error',
|
|
87
|
+
...namingConvention,
|
|
88
|
+
{
|
|
89
|
+
selector: 'function',
|
|
90
|
+
modifiers: ['exported'],
|
|
91
|
+
format: null,
|
|
92
|
+
filter: { regex: `^(${httpMethodPattern})$`, match: true },
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
62
97
|
{
|
|
63
98
|
files: ['**/app/api/**/route.{js,jsx,ts,tsx}'],
|
|
64
99
|
rules: {
|
|
@@ -66,14 +101,12 @@ export const nextjs = tseslint.config(
|
|
|
66
101
|
'no-restricted-syntax': [
|
|
67
102
|
'error',
|
|
68
103
|
{
|
|
69
|
-
selector:
|
|
70
|
-
|
|
71
|
-
message: 'Only GET, POST, PUT, DELETE are allowed as exported route handlers in route.ts',
|
|
104
|
+
selector: `ExportNamedDeclaration > FunctionDeclaration:not([id.name=/^(${routeFunctionPattern})$/])`,
|
|
105
|
+
message: routeExportMessage,
|
|
72
106
|
},
|
|
73
107
|
{
|
|
74
|
-
selector:
|
|
75
|
-
|
|
76
|
-
message: 'Only GET, POST, PUT, DELETE are allowed as exported route handlers in route.ts',
|
|
108
|
+
selector: `ExportNamedDeclaration > VariableDeclaration > VariableDeclarator[init.type=/^(ArrowFunctionExpression|FunctionExpression)$/]:not([id.name=/^(${routeFunctionPattern})$/])`,
|
|
109
|
+
message: routeExportMessage,
|
|
77
110
|
},
|
|
78
111
|
],
|
|
79
112
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { namingConvention } from './core/typescript.js'
|
|
2
|
+
|
|
3
|
+
// An opt-in addition for Playwright files, like Turbo and Boundaries: spread it
|
|
4
|
+
// after a language preset (`base`, `nextjs`, ...), which registers the plugins
|
|
5
|
+
// and rules these overrides adjust. Every rule it does not name stays as the
|
|
6
|
+
// language preset sets it, including `write-good-comments` and
|
|
7
|
+
// `unicorn/prevent-abbreviations`.
|
|
8
|
+
export const playwright = [
|
|
9
|
+
{
|
|
10
|
+
files: [
|
|
11
|
+
'**/tests/e2e/**/*.{spec,setup}.ts',
|
|
12
|
+
'**/e2e/**/*.spec.ts',
|
|
13
|
+
'**/playwright.config.{ts,mts}',
|
|
14
|
+
],
|
|
15
|
+
rules: {
|
|
16
|
+
// Tests and projects are generated per viewport, locale or route, and
|
|
17
|
+
// locator checks run in order inside a test.
|
|
18
|
+
'functional/no-loop-statements': 'off',
|
|
19
|
+
// A `describe` block or setup step covers a whole page or sign-in flow,
|
|
20
|
+
// so its length follows the page, not its complexity.
|
|
21
|
+
'max-lines-per-function': 'off',
|
|
22
|
+
// Expected-data tables use the page's labels and the API's field names
|
|
23
|
+
// as keys (`Browse`, `release_notes`), which a test cannot rename.
|
|
24
|
+
'@typescript-eslint/naming-convention': [
|
|
25
|
+
'error',
|
|
26
|
+
...namingConvention,
|
|
27
|
+
{ selector: 'objectLiteralProperty', format: null },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
export default playwright
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vllnt/eslint-config",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Strict ESLint config for TypeScript projects. All rules enforce error — no warnings.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"./react": "./flat/react.js",
|
|
33
33
|
"./turbo": "./flat/turbo.js",
|
|
34
34
|
"./boundaries": "./flat/boundaries.js",
|
|
35
|
+
"./playwright": "./flat/playwright.js",
|
|
36
|
+
"./ignores": "./flat/ignores.js",
|
|
35
37
|
"./package.json": "./package.json"
|
|
36
38
|
},
|
|
37
39
|
"scripts": {
|
|
@@ -42,7 +44,6 @@
|
|
|
42
44
|
"@convex-dev/eslint-plugin": "^5.0.0",
|
|
43
45
|
"@eslint/js": "^9.39.5",
|
|
44
46
|
"@next/eslint-plugin-next": "^16.4.3",
|
|
45
|
-
"eslint-config-prettier": "^10.1.8",
|
|
46
47
|
"eslint-plugin-boundaries": "^5.4.0",
|
|
47
48
|
"eslint-plugin-css-modules": "^2.12.0",
|
|
48
49
|
"eslint-plugin-functional": "^10.0.1",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"eslint-plugin-turbo": "^2.11.10",
|
|
56
57
|
"eslint-plugin-unicorn": "^65.0.1",
|
|
57
58
|
"eslint-plugin-write-good-comments": "^0.2.0",
|
|
58
|
-
"typescript-eslint": "8.
|
|
59
|
+
"typescript-eslint": "8.73.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"eslint": ">=9",
|
|
@@ -87,7 +88,8 @@
|
|
|
87
88
|
],
|
|
88
89
|
"overrides": {
|
|
89
90
|
"handlebars": ">=4.7.9",
|
|
90
|
-
"deepmerge-ts@<8.0.0": "^8.0.2"
|
|
91
|
+
"deepmerge-ts@<8.0.0": "^8.0.2",
|
|
92
|
+
"minimatch@>=7.0.0 <11.0.1": "^11.0.1"
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
}
|