eslint-plugin-nextfriday 3.0.0 → 3.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/CHANGELOG.md +15 -0
- package/README.md +146 -23
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +65 -3
- package/docs/rules/FILE_KEBAB_CASE.md +7 -1
- package/docs/rules/JSX_PASCAL_CASE.md +6 -2
- package/lib/index.cjs +6 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +4 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +6 -5
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# eslint-plugin-nextfriday
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#116](https://github.com/next-friday/eslint-plugin-nextfriday/pull/116) [`64ced55`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/64ced556b4099a40ca2f4750523c7a079d2c81d8) Thanks [@joetakara](https://github.com/joetakara)! - `nextjs` and `nextjs/recommended` presets now also disable `nextfriday/file-kebab-case` (in addition to `nextfriday/jsx-pascal-case`) for files under `app/**`, `src/app/**`, `pages/**`, and `src/pages/**`. The override globs are expanded from `*.{jsx,tsx}` to `*.{js,jsx,ts,tsx}` so `route.ts`, `middleware.ts`, and other framework-named `.ts`/`.js` files in those directories are no longer flagged by either filename rule. Filename conventions in routing directories are owned by the framework, not by this plugin.
|
|
8
|
+
|
|
9
|
+
The `react` and `react/recommended` presets are unchanged — projects using them still enforce `file-kebab-case` on every `.ts`/`.js` and `jsx-pascal-case` on every `.tsx`/`.jsx`.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#116](https://github.com/next-friday/eslint-plugin-nextfriday/pull/116) [`64ced55`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/64ced556b4099a40ca2f4750523c7a079d2c81d8) Thanks [@joetakara](https://github.com/joetakara)! - Documentation quality improvements targeting Context7 scoring gaps:
|
|
14
|
+
- `README.md` — "Per-Directory Configuration" section now explains how flat config resolves rules (config-array order, `files`/`ignores` precedence, why flat replaces `.eslintrc` overrides), adds a preset-tier-per-directory table, and lists common edge cases (glob ordering, top-level vs scoped `ignores`, spreading array-shaped presets, `--print-config` for debugging).
|
|
15
|
+
- `README.md` — "Migration Strategy" section is restructured around six concrete phases: surveying violations with `eslint --format json | jq`, isolating the auto-fix pass into its own PR, adopting the warn-level preset, ratcheting clean directories to `/recommended`, managing exceptions (severity override → directory override → disable comment, in that order of preference), and tracking violation count over time. The "Prioritize rules by impact" table is unchanged.
|
|
16
|
+
- `docs/rules/ENFORCE_CONSTANT_CASE.md` — Configuration section split into install / enable-just-this-rule / enable-with-related-rules / enable-via-preset / scope-to-directory subsections, plus a "Severity-only — no rule options" callout clarifying that the legacy `["error", { ... }]` array form is not accepted because no rule in this plugin has options.
|
|
17
|
+
|
|
3
18
|
## 3.0.0
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -178,44 +178,115 @@ export default [
|
|
|
178
178
|
|
|
179
179
|
### Per-Directory Configuration
|
|
180
180
|
|
|
181
|
-
ESLint flat config
|
|
181
|
+
#### How ESLint flat config resolves rules
|
|
182
|
+
|
|
183
|
+
Flat config (the only format this plugin supports) is an **array of config objects** evaluated in order. For every file ESLint lints, it walks the array and merges every object whose `files` glob matches and whose `ignores` glob does not. Later objects override earlier ones rule-by-rule, so the **last matching object wins** for any given rule. Objects with no `files` field apply globally; objects with only `ignores` at the top level remove files from the entire run.
|
|
184
|
+
|
|
185
|
+
This is why per-directory configuration works: you stack a global default first, then layer narrower `files`-scoped objects on top. ESLint 9+ also flattens nested arrays automatically, so spreading a preset that ships as an array (like `nextfriday.configs.nextjs`) works the same as spreading a single object.
|
|
186
|
+
|
|
187
|
+
The legacy `.eslintrc` format used `overrides` and an inheritance tree to express the same thing. Flat config replaces that tree with a flat, deterministic array — easier to reason about, no implicit merging across `extends`, and no `parserOptions` plumbing per directory. The plugin does not ship `.eslintrc` shims, so projects on ESLint 8 or below cannot consume it without upgrading.
|
|
188
|
+
|
|
189
|
+
#### Layering strict and loose presets
|
|
190
|
+
|
|
191
|
+
Apply different rule severities to different directories by stacking config objects:
|
|
182
192
|
|
|
183
193
|
```js
|
|
184
194
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
185
195
|
|
|
186
196
|
export default [
|
|
187
197
|
{
|
|
188
|
-
|
|
189
|
-
...nextfriday.configs["react/recommended"],
|
|
198
|
+
ignores: ["src/legacy/**", "dist/**", "build/**", "**/*.generated.ts"],
|
|
190
199
|
},
|
|
191
200
|
|
|
201
|
+
nextfriday.configs.react,
|
|
202
|
+
|
|
192
203
|
{
|
|
193
|
-
files: ["src/
|
|
194
|
-
...nextfriday.configs
|
|
204
|
+
files: ["src/components/**/*.{ts,tsx}", "src/hooks/**/*.{ts,tsx}"],
|
|
205
|
+
...nextfriday.configs["react/recommended"],
|
|
195
206
|
},
|
|
196
207
|
|
|
197
208
|
{
|
|
198
|
-
files: ["src/
|
|
199
|
-
|
|
209
|
+
files: ["src/utils/**/*.ts", "src/lib/**/*.ts"],
|
|
210
|
+
rules: {
|
|
211
|
+
"nextfriday/require-explicit-return-type": "error",
|
|
212
|
+
"nextfriday/no-relative-imports": "error",
|
|
213
|
+
},
|
|
200
214
|
},
|
|
201
215
|
|
|
202
216
|
{
|
|
203
|
-
files: ["**/*.test.{ts,tsx}"],
|
|
217
|
+
files: ["**/*.{test,spec}.{ts,tsx}"],
|
|
204
218
|
rules: {
|
|
205
219
|
"nextfriday/require-explicit-return-type": "off",
|
|
206
220
|
"nextfriday/no-single-char-variables": "off",
|
|
221
|
+
"nextfriday/no-direct-date": "off",
|
|
207
222
|
},
|
|
208
223
|
},
|
|
209
224
|
];
|
|
210
225
|
```
|
|
211
226
|
|
|
212
|
-
|
|
227
|
+
Reading top to bottom:
|
|
228
|
+
|
|
229
|
+
1. **Top-level `ignores`** removes legacy and build artifacts from the entire run. A config object containing _only_ `ignores` is treated as a global ignore — narrower `ignores` inside a `files`-scoped object only affect that object.
|
|
230
|
+
2. **`nextfriday.configs.react`** applies as the warn-level baseline to every file ESLint sees (no `files` glob).
|
|
231
|
+
3. **Component and hook directories** get promoted to `react/recommended` (errors). Because this object comes after the baseline, its severities win.
|
|
232
|
+
4. **Utility directories** keep the warn-level baseline but selectively promote two correctness rules to `error`. Use this pattern when you don't want the full `/recommended` preset but do want specific rules treated as blocking.
|
|
233
|
+
5. **Test files** keep most rules but turn off rules that conflict with common test patterns (single-letter loop counters, frozen `Date.now()` mocks, void-returning `it()` callbacks).
|
|
234
|
+
|
|
235
|
+
#### Choosing a preset tier per directory
|
|
236
|
+
|
|
237
|
+
| Code area | Suggested preset | Why |
|
|
238
|
+
| --------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------- |
|
|
239
|
+
| Library / SDK code | `base/recommended` or `react/recommended` | Public surface should be tightest. `error` blocks regressions at PR time. |
|
|
240
|
+
| New product code | `react/recommended` or `nextjs/recommended` | New code starts clean; lock the conventions in immediately. |
|
|
241
|
+
| Mature product code mid-migration | `react` or `nextjs` (warn) | Ship while migrating. Switch to `/recommended` after a clean run. |
|
|
242
|
+
| Tests, scripts, fixtures | preset + targeted overrides | Keep the core lint signal; turn off rules that mismatch test/CLI patterns. |
|
|
243
|
+
| Legacy / vendored / generated | top-level `ignores` | No lint signal at all. Don't waste reviewer attention or CI time. |
|
|
244
|
+
|
|
245
|
+
#### Edge cases and troubleshooting
|
|
246
|
+
|
|
247
|
+
- **Glob precedence is order-dependent, not specificity-based.** A more specific glob later in the array wins; a more specific glob _earlier_ in the array does not. If `files: ["src/**"]` appears after `files: ["src/components/**"]`, the broader rule set wins for components. Put broader configs first.
|
|
248
|
+
- **`files` and `ignores` are anchored to the project root** (the directory containing `eslint.config.{js,mjs,ts}`), not the file's directory. Use `**/` prefixes for matches anywhere in the tree (e.g., `**/*.test.ts`).
|
|
249
|
+
- **Top-level `ignores` ≠ `ignores` inside a config object.** A standalone object `{ ignores: [...] }` removes files from the entire run; an `ignores` field next to `files` and `rules` only narrows that one config object's match.
|
|
250
|
+
- **Spreading a preset replaces, not merges, the `plugins` field.** If you spread `...nextfriday.configs.react` and then a different config later, the later object's `plugins` wins. Re-declare `plugins: { nextfriday }` if you add rules in a later object.
|
|
251
|
+
- **`nextfriday.configs.nextjs` is an array, not a single object.** Spreading it inline with `...nextfriday.configs.nextjs` only spreads array indices, not the inner objects. Use it as an array entry (`nextfriday.configs.nextjs,`) instead, so ESLint 9+ flattens it.
|
|
252
|
+
- **Two presets in one project.** Use scoped `files` rather than two unscoped presets — unscoped presets stack and the later one's rule severities win for every file, which is rarely what you want.
|
|
253
|
+
- **Verifying the resolved config for a file:** `pnpm eslint --print-config path/to/file.tsx` prints the merged config ESLint would actually use. Reach for this when a rule fires (or doesn't) and you can't tell why.
|
|
213
254
|
|
|
214
255
|
### Migration Strategy
|
|
215
256
|
|
|
216
|
-
For an existing codebase with many violations,
|
|
257
|
+
For an existing codebase with many violations, treat the migration as a phased rollout — survey, fix, lock in, repeat.
|
|
258
|
+
|
|
259
|
+
#### 1. Survey violations before changing anything
|
|
260
|
+
|
|
261
|
+
Install the plugin as a dev dependency, drop a warn-level preset into `eslint.config.mjs`, and run a read-only lint. Don't `--fix` yet — you want to see the raw shape of the codebase first.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
pnpm add -D eslint-plugin-nextfriday eslint
|
|
265
|
+
pnpm eslint . --no-fix
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Group violations by rule so you can plan the work. Most CI dashboards do this for you, but a one-liner works locally:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
pnpm eslint . --no-fix --format json | jq -r '.[].messages[].ruleId' | sort | uniq -c | sort -rn
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The output tells you which rules account for most of the noise. A rule with 3 violations is a 10-minute fix; a rule with 800 is a multi-week project. Plan accordingly.
|
|
275
|
+
|
|
276
|
+
#### 2. Run the auto-fixers in an isolated PR
|
|
277
|
+
|
|
278
|
+
Roughly a third of this plugin's rules are auto-fixable (the `Fixable ✅` column in the [Rules](#rules) table). Run them in a dedicated commit so the diff is purely mechanical and reviewers don't have to read every line:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
pnpm eslint . --fix
|
|
282
|
+
git add -u && git commit -m "style(lint): autofix nextfriday rules"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Open this as its own PR. Mixing auto-fix output with hand-written changes in the same diff makes review almost impossible.
|
|
286
|
+
|
|
287
|
+
#### 3. Adopt the warn-level preset
|
|
217
288
|
|
|
218
|
-
|
|
289
|
+
After the auto-fix pass, drop in the warn-level preset so the remaining violations surface during local dev and CI without breaking the build:
|
|
219
290
|
|
|
220
291
|
```js
|
|
221
292
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -223,7 +294,11 @@ import nextfriday from "eslint-plugin-nextfriday";
|
|
|
223
294
|
export default [nextfriday.configs.react];
|
|
224
295
|
```
|
|
225
296
|
|
|
226
|
-
|
|
297
|
+
Warnings don't fail `eslint --max-warnings=0`, so add that flag in CI only when you're ready to block on warnings. Until then, warnings are visible signal without pressure.
|
|
298
|
+
|
|
299
|
+
#### 4. Lock in clean directories one at a time
|
|
300
|
+
|
|
301
|
+
As individual directories or features reach zero violations, promote them to `/recommended` (errors) so regressions block at PR time. Everything else stays on the warn-level preset.
|
|
227
302
|
|
|
228
303
|
```js
|
|
229
304
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -238,11 +313,15 @@ export default [
|
|
|
238
313
|
];
|
|
239
314
|
```
|
|
240
315
|
|
|
241
|
-
|
|
316
|
+
Repeat per directory. This is how you ratchet without flag-day rewrites.
|
|
242
317
|
|
|
243
|
-
|
|
244
|
-
|
|
318
|
+
#### 5. Manage exceptions explicitly
|
|
319
|
+
|
|
320
|
+
Three ways to carve out an exception, in order of preference. Pick the narrowest one that solves the problem.
|
|
245
321
|
|
|
322
|
+
**Per-rule severity override** — turn off a single noisy rule globally until you can fix it at the codebase level:
|
|
323
|
+
|
|
324
|
+
```js
|
|
246
325
|
export default [
|
|
247
326
|
nextfriday.configs["react/recommended"],
|
|
248
327
|
|
|
@@ -255,14 +334,56 @@ export default [
|
|
|
255
334
|
];
|
|
256
335
|
```
|
|
257
336
|
|
|
258
|
-
|
|
337
|
+
**Per-directory exception** — keep the rule strict everywhere except one stubborn corner:
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
export default [
|
|
341
|
+
nextfriday.configs["react/recommended"],
|
|
342
|
+
|
|
343
|
+
{
|
|
344
|
+
files: ["src/legacy/**/*.{ts,tsx}"],
|
|
345
|
+
rules: {
|
|
346
|
+
"nextfriday/no-relative-imports": "off",
|
|
347
|
+
"nextfriday/enforce-camel-case": "off",
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
];
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Per-file or per-line disable comments** — last resort, for genuinely irreducible cases:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
// eslint-disable-next-line nextfriday/no-direct-date
|
|
357
|
+
const epochAnchor = new Date(0);
|
|
358
|
+
|
|
359
|
+
/* eslint-disable nextfriday/no-emoji */
|
|
360
|
+
export const FLAG_EMOJIS = ["🇹🇭", "🇯🇵", "🇺🇸"];
|
|
361
|
+
/* eslint-enable nextfriday/no-emoji */
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Always disable a _named_ rule, never blanket-disable ESLint. A blanket `// eslint-disable` mutes every rule including correctness ones, so legitimate bugs slip through later.
|
|
365
|
+
|
|
366
|
+
**Skip vendored or generated files entirely** with a top-level ignore — these aren't exceptions to manage, they're code you don't lint at all:
|
|
259
367
|
|
|
260
368
|
```js
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
369
|
+
export default [
|
|
370
|
+
{
|
|
371
|
+
ignores: ["dist/**", "build/**", "coverage/**", "**/*.generated.ts"],
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
nextfriday.configs["react/recommended"],
|
|
375
|
+
];
|
|
264
376
|
```
|
|
265
377
|
|
|
378
|
+
#### 6. Track progress so the migration actually lands
|
|
379
|
+
|
|
380
|
+
Migrations stall when nobody can see how close you are. Two cheap signals:
|
|
381
|
+
|
|
382
|
+
- **Violation count over time.** Pipe `pnpm eslint . --no-fix --format compact | wc -l` into your CI metrics or a daily Slack post. Trend it weekly. If the number stops dropping, the migration has stalled.
|
|
383
|
+
- **Verify a single file's resolved config.** When a contributor asks "why did this rule fire on my file?", run `pnpm eslint --print-config path/to/file.tsx`. The output shows exactly which severity ESLint resolved for every rule on that file — usually answers the question in seconds.
|
|
384
|
+
|
|
385
|
+
Once a directory hits zero, lock it in (step 4). Once the warn-level count hits zero across the whole repo, switch the global preset to `/recommended` and add `--max-warnings=0` to CI. The migration is done.
|
|
386
|
+
|
|
266
387
|
#### Prioritize rules by impact
|
|
267
388
|
|
|
268
389
|
When the warn-level preset surfaces hundreds of violations, fix them in this order — high-impact rules catch real bugs, while low-impact rules are style preferences that can wait.
|
|
@@ -379,10 +500,12 @@ In practice: turn the high tier on as `"error"` first, leave the medium tier as
|
|
|
379
500
|
| -------------------- | -------- | ---------- | --------- | ------------- | ----------- |
|
|
380
501
|
| `base` | warn | 40 | 0 | 0 | 40 |
|
|
381
502
|
| `base/recommended` | error | 40 | 0 | 0 | 40 |
|
|
382
|
-
| `react` | warn | 40 |
|
|
383
|
-
| `react/recommended` | error | 40 |
|
|
384
|
-
| `nextjs` | warn | 40 |
|
|
385
|
-
| `nextjs/recommended` | error | 40 |
|
|
503
|
+
| `react` | warn | 40 | 16 | 0 | 56 |
|
|
504
|
+
| `react/recommended` | error | 40 | 16 | 0 | 56 |
|
|
505
|
+
| `nextjs` | warn | 40 | 16 | 1 | 57 |
|
|
506
|
+
| `nextjs/recommended` | error | 40 | 16 | 1 | 57 |
|
|
507
|
+
|
|
508
|
+
The `nextjs` and `nextjs/recommended` presets ship as an array of two flat-config objects: the rule set above, plus a routing override that disables `nextfriday/file-kebab-case` and `nextfriday/jsx-pascal-case` for files matching `app/**/*.{js,jsx,ts,tsx}`, `src/app/**/*.{js,jsx,ts,tsx}`, `pages/**/*.{js,jsx,ts,tsx}`, and `src/pages/**/*.{js,jsx,ts,tsx}`. Next.js owns the filenames in those directories (`page.tsx`, `layout.tsx`, `route.ts`, `middleware.ts`, etc.), so the plugin steps out of the way. ESLint 9+ flattens nested config arrays automatically, so spreading the preset works as expected.
|
|
386
509
|
|
|
387
510
|
### Base Configuration Rules (40 rules)
|
|
388
511
|
|
|
@@ -58,7 +58,36 @@ function foo() {
|
|
|
58
58
|
|
|
59
59
|
## Configuration
|
|
60
60
|
|
|
61
|
-
This rule pairs with [`no-misleading-constant-case`](./NO_MISLEADING_CONSTANT_CASE.md) so that static globals use `SCREAMING_SNAKE_CASE` while local scopes and dynamic values keep `camelCase`.
|
|
61
|
+
This rule has no options — only severity is configurable (`"error"`, `"warn"`, `"off"`). It pairs with [`no-misleading-constant-case`](./NO_MISLEADING_CONSTANT_CASE.md) so that static globals use `SCREAMING_SNAKE_CASE` while local scopes and dynamic values keep `camelCase`.
|
|
62
|
+
|
|
63
|
+
### Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm add -D eslint-plugin-nextfriday eslint
|
|
67
|
+
# npm install --save-dev eslint-plugin-nextfriday eslint
|
|
68
|
+
# yarn add --dev eslint-plugin-nextfriday eslint
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Enable just this rule
|
|
72
|
+
|
|
73
|
+
Use this when you want the rule but not the rest of the preset (e.g., adopting one rule at a time during a migration). The `plugins` field registers the plugin under the `nextfriday` namespace; the `rules` field turns on the rule by name:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
import nextfriday from "eslint-plugin-nextfriday";
|
|
77
|
+
|
|
78
|
+
export default [
|
|
79
|
+
{
|
|
80
|
+
plugins: { nextfriday },
|
|
81
|
+
rules: {
|
|
82
|
+
"nextfriday/enforce-constant-case": "error",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Enable with related rules
|
|
89
|
+
|
|
90
|
+
Constants, locals, and dynamic values each need a different naming convention. Enable the trio together so violations from any direction surface:
|
|
62
91
|
|
|
63
92
|
```js
|
|
64
93
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -75,7 +104,9 @@ export default [
|
|
|
75
104
|
];
|
|
76
105
|
```
|
|
77
106
|
|
|
78
|
-
|
|
107
|
+
### Enable via a preset
|
|
108
|
+
|
|
109
|
+
Every preset includes this rule at the preset's severity (`warn` or `error`). This is the simplest setup and the recommended one for most projects:
|
|
79
110
|
|
|
80
111
|
```js
|
|
81
112
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -83,7 +114,38 @@ import nextfriday from "eslint-plugin-nextfriday";
|
|
|
83
114
|
export default [nextfriday.configs["base/recommended"]];
|
|
84
115
|
```
|
|
85
116
|
|
|
86
|
-
|
|
117
|
+
### Scope to a directory
|
|
118
|
+
|
|
119
|
+
If you're migrating an existing codebase, scope the rule to a clean directory first and leave the rest of the project on `"warn"` until you've fixed the violations there. ESLint 9+ flat config layers configs in array order; the later object's severity wins for any file matching its `files` glob:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import nextfriday from "eslint-plugin-nextfriday";
|
|
123
|
+
|
|
124
|
+
export default [
|
|
125
|
+
nextfriday.configs.base,
|
|
126
|
+
|
|
127
|
+
{
|
|
128
|
+
files: ["src/config/**/*.ts", "src/lib/**/*.ts"],
|
|
129
|
+
rules: {
|
|
130
|
+
"nextfriday/enforce-constant-case": "error",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Severity-only — no rule options
|
|
137
|
+
|
|
138
|
+
Each rule in this plugin uses `schema: []` and `defaultOptions: []` (no options). The flat-config value is **only** the severity string — `"error"`, `"warn"`, or `"off"`. The legacy `["error", { ... }]` array form is not accepted because there are no options to pass.
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
// Correct
|
|
142
|
+
"nextfriday/enforce-constant-case": "error"
|
|
143
|
+
|
|
144
|
+
// Won't apply — there are no options to override
|
|
145
|
+
"nextfriday/enforce-constant-case": ["error", { allowCamelCase: true }]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This plugin only supports ESLint 9+ flat config — legacy `.eslintrc` is not supported. Projects on ESLint 8 or below cannot consume it without upgrading.
|
|
87
149
|
|
|
88
150
|
## When Not To Use It
|
|
89
151
|
|
|
@@ -40,9 +40,15 @@ This rule enforces that all TypeScript (.ts) and JavaScript (.js) files use keba
|
|
|
40
40
|
- **Numbers are allowed inside segments.** `file-with-numbers-123.ts` ✓
|
|
41
41
|
- **Single-word filenames are valid.** `single.ts` ✓ (no hyphens needed)
|
|
42
42
|
|
|
43
|
+
## Scoping the Rule
|
|
44
|
+
|
|
45
|
+
This rule has **no built-in framework detection**. It checks every `.ts`/`.js` file it sees against kebab-case. In Next.js projects, routing directories (`app/`, `pages/`) contain framework-named files (`route.ts`, `middleware.ts`) that already happen to be kebab-case — but if you colocate helpers there with non-kebab names (`useThing.ts`, `MyHelper.ts`), the rule will flag them.
|
|
46
|
+
|
|
47
|
+
The `nextjs` and `nextjs/recommended` presets ship with an override that **automatically disables this rule** for files under `app/**`, `src/app/**`, `pages/**`, and `src/pages/**` (matched against `*.{js,jsx,ts,tsx}`). Filename conventions in those directories are owned by the framework, not by this plugin. The `base` and `react` presets do **not** include this override — they enforce `file-kebab-case` on every `.ts`/`.js` regardless of directory.
|
|
48
|
+
|
|
43
49
|
## Disabling the Rule
|
|
44
50
|
|
|
45
|
-
To opt out for
|
|
51
|
+
To opt out for additional directories or file patterns, add an override in your flat config:
|
|
46
52
|
|
|
47
53
|
```js
|
|
48
54
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -30,7 +30,11 @@ This rule enforces that JSX and TSX files use PascalCase naming convention for t
|
|
|
30
30
|
|
|
31
31
|
## Scoping the Rule
|
|
32
32
|
|
|
33
|
-
This rule has **no built-in framework detection** and no allowlist of "known" filenames. It checks every `.jsx`/`.tsx` it sees
|
|
33
|
+
This rule has **no built-in framework detection** and no allowlist of "known" filenames. It checks every `.jsx`/`.tsx` it sees against PascalCase.
|
|
34
|
+
|
|
35
|
+
The `nextjs` and `nextjs/recommended` presets ship with an override that **automatically disables this rule** for files under `app/**`, `src/app/**`, `pages/**`, and `src/pages/**` — Next.js owns those filenames (`page.tsx`, `layout.tsx`, `error.tsx`, etc.). If you use a `nextjs` preset, you do not need to add a routing override yourself.
|
|
36
|
+
|
|
37
|
+
The `base` and `react` presets do **not** include this override. If you use `react` on a Next.js project (or any project that mixes PascalCase component files with lowercase framework routing files), scope the rule explicitly via ESLint's `files` glob:
|
|
34
38
|
|
|
35
39
|
```js
|
|
36
40
|
import nextfriday from "eslint-plugin-nextfriday";
|
|
@@ -56,7 +60,7 @@ export default [
|
|
|
56
60
|
|
|
57
61
|
The first override turns the rule on only inside component directories where PascalCase is the convention. The second override explicitly disables the rule for Next.js routing directories where the framework owns the filename.
|
|
58
62
|
|
|
59
|
-
The plugin deliberately does not try to detect Next.js, Remix, or other framework conventions
|
|
63
|
+
The plugin deliberately does not try to detect Next.js, Remix, or other framework conventions outside of the `nextjs` preset — folder structures vary across projects (monorepos, custom `app` locations, hybrid Pages + App Router setups), and a built-in allowlist would inevitably go stale. ESLint's `files` glob is the deterministic way to express the scope you actually want.
|
|
60
64
|
|
|
61
65
|
## When Not To Use It
|
|
62
66
|
|
package/lib/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
40
40
|
// package.json
|
|
41
41
|
var package_default = {
|
|
42
42
|
name: "eslint-plugin-nextfriday",
|
|
43
|
-
version: "3.
|
|
43
|
+
version: "3.1.0",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -4747,14 +4747,15 @@ var createConfig = (configRules) => ({
|
|
|
4747
4747
|
rules: configRules
|
|
4748
4748
|
});
|
|
4749
4749
|
var NEXTJS_ROUTING_GLOBS = [
|
|
4750
|
-
"app/**/*.{jsx,tsx}",
|
|
4751
|
-
"src/app/**/*.{jsx,tsx}",
|
|
4752
|
-
"pages/**/*.{jsx,tsx}",
|
|
4753
|
-
"src/pages/**/*.{jsx,tsx}"
|
|
4750
|
+
"app/**/*.{js,jsx,ts,tsx}",
|
|
4751
|
+
"src/app/**/*.{js,jsx,ts,tsx}",
|
|
4752
|
+
"pages/**/*.{js,jsx,ts,tsx}",
|
|
4753
|
+
"src/pages/**/*.{js,jsx,ts,tsx}"
|
|
4754
4754
|
];
|
|
4755
4755
|
var nextjsRoutingOverride = {
|
|
4756
4756
|
files: NEXTJS_ROUTING_GLOBS,
|
|
4757
4757
|
rules: {
|
|
4758
|
+
"nextfriday/file-kebab-case": "off",
|
|
4758
4759
|
"nextfriday/jsx-pascal-case": "off"
|
|
4759
4760
|
}
|
|
4760
4761
|
};
|