eslint-plugin-nextfriday 3.2.1 → 4.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-nextfriday",
3
- "version": "3.2.1",
3
+ "version": "4.0.0",
4
4
  "description": "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -1,55 +0,0 @@
1
- # enforce-curly-newline
2
-
3
- Enforce curly braces for multi-line if statements and forbid them for single-line.
4
-
5
- ## Rule Details
6
-
7
- This rule manages curly braces for `IfStatement` based on visual layout (line breaks). Designed to work seamlessly with Prettier's line wrapping.
8
-
9
- ### Logic
10
-
11
- 1. **Single-line** (`startLine === endLine`): Braces are **forbidden**
12
- 2. **Multi-line** (`startLine !== endLine`): Braces are **required**
13
-
14
- ## Examples
15
-
16
- ### Incorrect
17
-
18
- ```ts
19
- if (!data) {
20
- return [];
21
- }
22
- if (x > 0) {
23
- doSomething();
24
- }
25
- ```
26
-
27
- ```ts
28
- if (veryLongCondition && anotherCondition) return [];
29
- ```
30
-
31
- ### Correct
32
-
33
- ```ts
34
- if (!data) return [];
35
- if (x > 0) doSomething();
36
- ```
37
-
38
- ```ts
39
- if (veryLongCondition && anotherCondition) {
40
- return [];
41
- }
42
- ```
43
-
44
- ## Auto-Fix
45
-
46
- This rule provides automatic fixes:
47
-
48
- - **Single-line with braces** → Removes braces (only when block contains single statement)
49
- - **Multi-line without braces** → Adds braces with proper indentation
50
-
51
- ## When Not To Use It
52
-
53
- - If you prefer always using braces regardless of line count
54
- - If you prefer never using braces
55
- - If using a formatter that conflicts with this rule
@@ -1,70 +0,0 @@
1
- # file-kebab-case
2
-
3
- Enforce kebab-case filenames for .ts and .js files.
4
-
5
- ## Rule Details
6
-
7
- This rule enforces that all TypeScript (.ts) and JavaScript (.js) files use kebab-case naming convention for their **filenames**. Kebab-case uses lowercase letters and hyphens to separate words, making filenames more consistent and URL-friendly. Single word filenames are considered valid kebab-case.
8
-
9
- **This rule checks the filename, not the code content.** Only `.ts` and `.js` files are checked; other file types are ignored.
10
-
11
- ## Examples
12
-
13
- ### Incorrect
14
-
15
- - `MyFile.ts` (PascalCase)
16
- - `camelCase.js` (camelCase)
17
- - `PascalCase.ts` (PascalCase)
18
- - `snake_case.js` (snake_case)
19
- - `UPPERCASE.ts` (UPPERCASE)
20
- - `My File.js` (contains spaces)
21
-
22
- ### Correct
23
-
24
- - `my-file.ts`
25
- - `kebab-case.js`
26
- - `single.ts`
27
- - `file-with-numbers-123.js`
28
- - `user-service.ts`
29
- - `api-utils.ts`
30
-
31
- ## Allowed Patterns and Edge Cases
32
-
33
- - **Only `.ts` and `.js` are checked.** `.tsx` and `.jsx` files are ignored — use [`jsx-pascal-case`](./JSX_PASCAL_CASE.md) for React component filenames.
34
- - **Compound extensions are allowed when each segment is kebab-case.** Both the basename and the trailing token before the file extension are validated independently. This pattern is useful for config, setup, spec, test, and rc files:
35
- - `next.config.ts` ✓
36
- - `vitest.setup.ts` ✓
37
- - `user-service.test.ts` ✓
38
- - `auth.spec.ts` ✓
39
- - `eslint.rc.ts` ✓
40
- - **Numbers are allowed inside segments.** `file-with-numbers-123.ts` ✓
41
- - **Single-word filenames are valid.** `single.ts` ✓ (no hyphens needed)
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
-
49
- ## Disabling the Rule
50
-
51
- To opt out for additional directories or file patterns, add an override in your flat config:
52
-
53
- ```js
54
- import nextfriday from "eslint-plugin-nextfriday";
55
-
56
- export default [
57
- nextfriday.configs["base/recommended"],
58
-
59
- {
60
- files: ["src/legacy/**/*.ts", "src/vendor/**/*.js"],
61
- rules: {
62
- "nextfriday/file-kebab-case": "off",
63
- },
64
- },
65
- ];
66
- ```
67
-
68
- ## When Not To Use It
69
-
70
- If your project has established naming conventions that conflict with kebab-case, or if you're working with frameworks that require specific filename patterns, you may want to disable this rule.
@@ -1,71 +0,0 @@
1
- # jsx-pascal-case
2
-
3
- Enforce PascalCase filenames for .jsx and .tsx files.
4
-
5
- ## Rule Details
6
-
7
- This rule enforces that JSX and TSX files use PascalCase naming convention for their **filenames**. This is a common pattern in React applications where components are typically named with PascalCase.
8
-
9
- **This rule checks the filename, not the code content.**
10
-
11
- ## Examples
12
-
13
- ### Incorrect
14
-
15
- - `my-component.jsx` (kebab-case)
16
- - `userProfile.jsx` (camelCase)
17
- - `user_profile.tsx` (snake_case)
18
- - `component.jsx` (lowercase)
19
- - `MYCOMPONENT.tsx` (UPPERCASE)
20
- - `My Component.jsx` (contains spaces)
21
- - `My.Component.tsx` (contains dots)
22
-
23
- ### Correct
24
-
25
- - `MyComponent.jsx`
26
- - `UserProfile.tsx`
27
- - `App.jsx`
28
- - `LoginForm.tsx`
29
- - `UserProfile2.jsx` (PascalCase with numbers)
30
-
31
- ## Scoping the Rule
32
-
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:
38
-
39
- ```js
40
- import nextfriday from "eslint-plugin-nextfriday";
41
-
42
- export default [
43
- nextfriday.configs.react,
44
-
45
- {
46
- files: ["src/components/**/*.{jsx,tsx}", "components/**/*.{jsx,tsx}"],
47
- rules: {
48
- "nextfriday/jsx-pascal-case": "error",
49
- },
50
- },
51
-
52
- {
53
- files: ["src/app/**/*.{jsx,tsx}", "app/**/*.{jsx,tsx}", "src/pages/**/*.{jsx,tsx}", "pages/**/*.{jsx,tsx}"],
54
- rules: {
55
- "nextfriday/jsx-pascal-case": "off",
56
- },
57
- },
58
- ];
59
- ```
60
-
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.
62
-
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.
64
-
65
- ## When Not To Use It
66
-
67
- If your project uses different naming conventions for JSX/TSX files, you can disable this rule.
68
-
69
- ## Related Rules
70
-
71
- - [file-kebab-case](./FILE_KEBAB_CASE.md) - For regular TypeScript and JavaScript files
@@ -1,44 +0,0 @@
1
- # nextjs-require-public-env
2
-
3
- Require `NEXT_PUBLIC_` prefix for environment variables in client components.
4
-
5
- ## Rule Details
6
-
7
- This rule ensures that environment variables accessed in Next.js client components (files with `"use client"` directive) use the `NEXT_PUBLIC_` prefix. In Next.js, only environment variables prefixed with `NEXT_PUBLIC_` are exposed to the browser. Only files with `"use client"` directive are checked. `NODE_ENV` is always allowed.
8
-
9
- ## Examples
10
-
11
- ### Incorrect
12
-
13
- ```tsx
14
- "use client";
15
-
16
- // These will be undefined at runtime!
17
- const url = process.env.API_URL;
18
- const secret = process.env.DATABASE_SECRET;
19
- const key = process.env.PRIVATE_API_KEY;
20
- ```
21
-
22
- ### Correct
23
-
24
- ```tsx
25
- "use client";
26
-
27
- // Properly prefixed for client-side access
28
- const url = process.env.NEXT_PUBLIC_API_URL;
29
- const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;
30
-
31
- // NODE_ENV is always available
32
- const isDev = process.env.NODE_ENV === "development";
33
- ```
34
-
35
- ```tsx
36
- // Server component (no "use client") - any env var is allowed
37
- const dbUrl = process.env.DATABASE_URL;
38
- const secret = process.env.API_SECRET;
39
- ```
40
-
41
- ## When Not To Use It
42
-
43
- - If you're not using Next.js
44
- - If you have a custom build setup that exposes env vars differently