eslint-plugin-nextfriday 1.21.0 → 1.22.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 +6 -0
- package/README.md +21 -15
- package/docs/rules/ENFORCE_CURLY_NEWLINE.md +4 -10
- package/docs/rules/ENFORCE_SERVICE_NAMING.md +33 -21
- package/docs/rules/JSX_NO_TERNARY_NULL.md +1 -1
- package/docs/rules/NO_INLINE_NESTED_OBJECT.md +10 -4
- package/docs/rules/PREFER_INLINE_LITERAL_UNION.md +6 -6
- package/lib/index.cjs +330 -379
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +14 -56
- package/lib/index.d.ts +14 -56
- package/lib/index.js +126 -175
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/rules/MD_FILENAME_CASE_RESTRICTION.md +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eslint-plugin-nextfriday
|
|
2
2
|
|
|
3
|
+
## 1.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#92](https://github.com/next-friday/eslint-plugin-nextfriday/pull/92) [`432b4b4`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/432b4b49cabc0d6ea9289441b13e7442d328614f) Thanks [@joetakara](https://github.com/joetakara)! - Rework enforce-service-naming rule to ban misleading prefixes (set, delete, do, handle) instead of forcing fetch prefix. Allow single-property inline nested objects in no-inline-nested-object rule. Fix documentation inconsistencies across README, rule docs, and configuration presets. Update dependencies to resolve security vulnerabilities.
|
|
8
|
+
|
|
3
9
|
## 1.21.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -78,12 +78,14 @@ export default [
|
|
|
78
78
|
"nextfriday/no-single-char-variables": "error",
|
|
79
79
|
"nextfriday/no-lazy-identifiers": "error",
|
|
80
80
|
"nextfriday/boolean-naming-prefix": "error",
|
|
81
|
+
"nextfriday/enforce-camel-case": "error",
|
|
81
82
|
"nextfriday/enforce-constant-case": "error",
|
|
83
|
+
"nextfriday/enforce-property-case": "error",
|
|
84
|
+
"nextfriday/no-misleading-constant-case": "error",
|
|
82
85
|
|
|
83
86
|
// File Naming
|
|
84
87
|
"nextfriday/file-kebab-case": "error",
|
|
85
88
|
"nextfriday/jsx-pascal-case": "error",
|
|
86
|
-
"nextfriday/md-filename-case-restriction": "error",
|
|
87
89
|
|
|
88
90
|
// Code Style
|
|
89
91
|
"nextfriday/no-emoji": "error",
|
|
@@ -97,9 +99,11 @@ export default [
|
|
|
97
99
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
98
100
|
"nextfriday/no-env-fallback": "error",
|
|
99
101
|
"nextfriday/no-inline-default-export": "error",
|
|
102
|
+
"nextfriday/no-direct-date": "error",
|
|
100
103
|
"nextfriday/newline-after-multiline-block": "error",
|
|
101
104
|
"nextfriday/newline-before-return": "error",
|
|
102
105
|
"nextfriday/no-inline-nested-object": "error",
|
|
106
|
+
"nextfriday/no-inline-return-properties": "error",
|
|
103
107
|
"nextfriday/prefer-async-await": "error",
|
|
104
108
|
"nextfriday/enforce-curly-newline": "error",
|
|
105
109
|
"nextfriday/no-nested-ternary": "error",
|
|
@@ -162,11 +166,10 @@ export default [
|
|
|
162
166
|
|
|
163
167
|
### File Naming Rules
|
|
164
168
|
|
|
165
|
-
| Rule
|
|
166
|
-
|
|
|
167
|
-
| [file-kebab-case](docs/rules/FILE_KEBAB_CASE.md)
|
|
168
|
-
| [jsx-pascal-case](docs/rules/JSX_PASCAL_CASE.md)
|
|
169
|
-
| [md-filename-case-restriction](docs/rules/MD_FILENAME_CASE_RESTRICTION.md) | Enforce SNAKE_CASE filenames for .md files | ❌ |
|
|
169
|
+
| Rule | Description | Fixable |
|
|
170
|
+
| ------------------------------------------------ | ---------------------------------------------------- | ------- |
|
|
171
|
+
| [file-kebab-case](docs/rules/FILE_KEBAB_CASE.md) | Enforce kebab-case filenames for .ts and .js files | ❌ |
|
|
172
|
+
| [jsx-pascal-case](docs/rules/JSX_PASCAL_CASE.md) | Enforce PascalCase filenames for .jsx and .tsx files | ❌ |
|
|
170
173
|
|
|
171
174
|
### Code Style Rules
|
|
172
175
|
|
|
@@ -246,26 +249,27 @@ export default [
|
|
|
246
249
|
|
|
247
250
|
| Preset | Severity | Base Rules | JSX Rules | Next.js Rules | Total Rules |
|
|
248
251
|
| -------------------- | -------- | ---------- | --------- | ------------- | ----------- |
|
|
249
|
-
| `base` | warn |
|
|
250
|
-
| `base/recommended` | error |
|
|
251
|
-
| `react` | warn |
|
|
252
|
-
| `react/recommended` | error |
|
|
253
|
-
| `nextjs` | warn |
|
|
254
|
-
| `nextjs/recommended` | error |
|
|
252
|
+
| `base` | warn | 40 | 0 | 0 | 40 |
|
|
253
|
+
| `base/recommended` | error | 40 | 0 | 0 | 40 |
|
|
254
|
+
| `react` | warn | 40 | 15 | 0 | 55 |
|
|
255
|
+
| `react/recommended` | error | 40 | 15 | 0 | 55 |
|
|
256
|
+
| `nextjs` | warn | 40 | 15 | 1 | 56 |
|
|
257
|
+
| `nextjs/recommended` | error | 40 | 15 | 1 | 56 |
|
|
255
258
|
|
|
256
|
-
### Base Configuration Rules (
|
|
259
|
+
### Base Configuration Rules (40 rules)
|
|
257
260
|
|
|
258
261
|
Included in `base`, `base/recommended`, and all other presets:
|
|
259
262
|
|
|
260
263
|
- `nextfriday/boolean-naming-prefix`
|
|
264
|
+
- `nextfriday/enforce-camel-case`
|
|
261
265
|
- `nextfriday/enforce-constant-case`
|
|
262
266
|
- `nextfriday/enforce-curly-newline`
|
|
263
267
|
- `nextfriday/enforce-hook-naming`
|
|
268
|
+
- `nextfriday/enforce-property-case`
|
|
264
269
|
- `nextfriday/enforce-service-naming`
|
|
265
270
|
- `nextfriday/enforce-sorted-destructuring`
|
|
266
271
|
- `nextfriday/enforce-type-declaration-order`
|
|
267
272
|
- `nextfriday/file-kebab-case`
|
|
268
|
-
- `nextfriday/md-filename-case-restriction`
|
|
269
273
|
- `nextfriday/newline-after-multiline-block`
|
|
270
274
|
- `nextfriday/newline-before-return`
|
|
271
275
|
- `nextfriday/no-complex-inline-return`
|
|
@@ -274,8 +278,10 @@ Included in `base`, `base/recommended`, and all other presets:
|
|
|
274
278
|
- `nextfriday/no-env-fallback`
|
|
275
279
|
- `nextfriday/no-inline-default-export`
|
|
276
280
|
- `nextfriday/no-inline-nested-object`
|
|
281
|
+
- `nextfriday/no-inline-return-properties`
|
|
277
282
|
- `nextfriday/no-lazy-identifiers`
|
|
278
283
|
- `nextfriday/no-logic-in-params`
|
|
284
|
+
- `nextfriday/no-misleading-constant-case`
|
|
279
285
|
- `nextfriday/no-nested-interface-declaration`
|
|
280
286
|
- `nextfriday/no-nested-ternary`
|
|
281
287
|
- `nextfriday/no-relative-imports`
|
|
@@ -339,7 +345,7 @@ Additionally included in `nextjs`, `nextjs/recommended` only:
|
|
|
339
345
|
|
|
340
346
|
## Agent Skill
|
|
341
347
|
|
|
342
|
-
This plugin ships with an [Agent Skill](https://github.com/anthropics/skills) that teaches AI coding assistants (Claude Code, Cursor, etc.) all
|
|
348
|
+
This plugin ships with an [Agent Skill](https://github.com/anthropics/skills) that teaches AI coding assistants (Claude Code, Cursor, etc.) all 56 rules so they generate compliant code from the start.
|
|
343
349
|
|
|
344
350
|
```bash
|
|
345
351
|
npx skills add next-friday/eslint-plugin-nextfriday --skill eslint-plugin-nextfriday
|
|
@@ -16,35 +16,29 @@ This rule manages curly braces for `IfStatement` based on visual layout (line br
|
|
|
16
16
|
### Incorrect
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
// Single-line with braces (BAD)
|
|
20
19
|
if (!data) {
|
|
21
20
|
return [];
|
|
22
21
|
}
|
|
23
22
|
if (x > 0) {
|
|
24
23
|
doSomething();
|
|
25
24
|
}
|
|
25
|
+
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
```ts
|
|
28
28
|
if (veryLongCondition && anotherCondition) return [];
|
|
29
|
-
|
|
30
|
-
if (condition) doSomething();
|
|
31
29
|
```
|
|
32
30
|
|
|
33
31
|
### Correct
|
|
34
32
|
|
|
35
33
|
```ts
|
|
36
|
-
// Single-line without braces (GOOD)
|
|
37
34
|
if (!data) return [];
|
|
38
35
|
if (x > 0) doSomething();
|
|
36
|
+
```
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
```ts
|
|
41
39
|
if (veryLongCondition && anotherCondition) {
|
|
42
40
|
return [];
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
if (condition) {
|
|
46
|
-
doSomething();
|
|
47
|
-
}
|
|
48
42
|
```
|
|
49
43
|
|
|
50
44
|
## Auto-Fix
|
|
@@ -1,48 +1,60 @@
|
|
|
1
1
|
# enforce-service-naming
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ban misleading function name prefixes in `*.service.ts` files.
|
|
4
4
|
|
|
5
5
|
## Rule Details
|
|
6
6
|
|
|
7
|
-
This rule
|
|
7
|
+
This rule flags misleading prefixes on async exported functions in `*.service.ts` files. It does not force a specific prefix — developers choose based on intent.
|
|
8
8
|
|
|
9
9
|
### Why?
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
11
|
+
Service functions represent API/network calls. Certain prefixes are misleading in this context:
|
|
12
|
+
|
|
13
|
+
- `set` implies a local setter, not an API call
|
|
14
|
+
- `delete` is a JS reserved word that may conflict
|
|
15
|
+
- `do` is vague and conveys no intent
|
|
16
|
+
- `handle` is typically for UI event handlers, not service operations
|
|
17
|
+
|
|
18
|
+
### Banned Prefixes
|
|
19
|
+
|
|
20
|
+
| Prefix | Why banned | Suggested alternatives |
|
|
21
|
+
| -------- | ----------------------------------------- | ------------------------- |
|
|
22
|
+
| `set` | Implies local setter, not API call | `update`, `save`, `patch` |
|
|
23
|
+
| `delete` | JS reserved word, may conflict | `remove`, `archive` |
|
|
24
|
+
| `do` | Vague, no intent | `submit`, `process` |
|
|
25
|
+
| `handle` | Vague, typically for event handlers in UI | `create`, `verify` |
|
|
14
26
|
|
|
15
27
|
## Examples
|
|
16
28
|
|
|
17
29
|
### Incorrect
|
|
18
30
|
|
|
19
31
|
```ts
|
|
20
|
-
//
|
|
21
|
-
export async function
|
|
22
|
-
export async function
|
|
23
|
-
export async function
|
|
24
|
-
export
|
|
32
|
+
// profile.service.ts
|
|
33
|
+
export async function setProfile(data: ProfileRequest) {}
|
|
34
|
+
export async function deleteComment(id: string) {}
|
|
35
|
+
export async function doLogin(credentials: LoginRequest) {}
|
|
36
|
+
export async function handlePayment(data: PaymentRequest) {}
|
|
25
37
|
```
|
|
26
38
|
|
|
27
39
|
### Correct
|
|
28
40
|
|
|
29
41
|
```ts
|
|
30
|
-
//
|
|
42
|
+
// profile.service.ts
|
|
43
|
+
export async function getArticles() {}
|
|
31
44
|
export async function fetchArticles() {}
|
|
32
|
-
export async function
|
|
33
|
-
export async function
|
|
34
|
-
export
|
|
45
|
+
export async function searchArticles(query: string) {}
|
|
46
|
+
export async function createOrder(data: OrderRequest) {}
|
|
47
|
+
export async function updateProfile(id: string, data: ProfileRequest) {}
|
|
48
|
+
export async function removeComment(id: string) {}
|
|
49
|
+
export async function verifyEmail(token: string) {}
|
|
35
50
|
|
|
36
51
|
// Non-async functions can use any prefix
|
|
37
|
-
export function
|
|
52
|
+
export function setLocalState(value: string) {}
|
|
38
53
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
export async function updateArticle() {}
|
|
42
|
-
export async function deleteComment() {}
|
|
54
|
+
// Non-exported functions are not checked
|
|
55
|
+
async function handleInternal() {}
|
|
43
56
|
```
|
|
44
57
|
|
|
45
58
|
## When Not To Use It
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
- If you prefer `get`/`load` prefixes for data-fetching operations
|
|
60
|
+
If your project does not follow a service layer pattern or has different naming conventions for service functions.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# no-inline-nested-object
|
|
2
2
|
|
|
3
|
-
Require nested objects and arrays to span multiple lines.
|
|
3
|
+
Require nested objects and arrays with multiple properties to span multiple lines.
|
|
4
4
|
|
|
5
5
|
## Rule Details
|
|
6
6
|
|
|
7
|
-
This rule enforces that when an object property's value is another object or array, it should span multiple lines rather than being written inline. This improves readability and makes diffs cleaner when properties are added or removed.
|
|
7
|
+
This rule enforces that when an object property's value is another object or array with more than one element, it should span multiple lines rather than being written inline. Single-property nested objects are allowed inline. This improves readability and makes diffs cleaner when properties are added or removed.
|
|
8
8
|
|
|
9
9
|
## Examples
|
|
10
10
|
|
|
@@ -25,6 +25,12 @@ const routes = {
|
|
|
25
25
|
|
|
26
26
|
### Correct
|
|
27
27
|
|
|
28
|
+
```ts
|
|
29
|
+
const config = {
|
|
30
|
+
database: { host: "localhost" },
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
28
34
|
```ts
|
|
29
35
|
const config = {
|
|
30
36
|
database: {
|
|
@@ -65,8 +71,8 @@ const initialState = {
|
|
|
65
71
|
|
|
66
72
|
## When Not To Use It
|
|
67
73
|
|
|
68
|
-
If you prefer compact inline nested objects for
|
|
74
|
+
If you prefer compact inline nested objects for all cases, or if your team has different formatting preferences.
|
|
69
75
|
|
|
70
76
|
## Fixable
|
|
71
77
|
|
|
72
|
-
This rule is auto-fixable. Running ESLint with the `--fix` flag will automatically expand inline nested objects and arrays to multiple lines.
|
|
78
|
+
This rule is auto-fixable. Running ESLint with the `--fix` flag will automatically expand inline nested objects and arrays with multiple properties to multiple lines.
|
|
@@ -10,17 +10,17 @@ This rule detects type aliases that are unions of only literal values (strings,
|
|
|
10
10
|
|
|
11
11
|
### Why?
|
|
12
12
|
|
|
13
|
-
When you hover over a prop in your IDE, a type alias shows the alias name (e.g., `
|
|
13
|
+
When you hover over a prop in your IDE, a type alias shows the alias name (e.g., `Theme`) instead of the actual values (`"light" | "dark" | "system"`). Inlining literal unions gives immediate visibility into the allowed values without needing to jump to the type definition.
|
|
14
14
|
|
|
15
15
|
## Examples
|
|
16
16
|
|
|
17
17
|
### Incorrect
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
type
|
|
20
|
+
type Theme = "light" | "dark" | "system";
|
|
21
21
|
|
|
22
|
-
interface
|
|
23
|
-
|
|
22
|
+
interface SettingsProps {
|
|
23
|
+
theme?: Theme;
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -43,8 +43,8 @@ interface Props {
|
|
|
43
43
|
### Correct
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
|
-
interface
|
|
47
|
-
|
|
46
|
+
interface SettingsProps {
|
|
47
|
+
theme?: "light" | "dark" | "system";
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|