eslint-plugin-nextjs 0.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/LICENSE +21 -0
- package/README.md +402 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Nathan Drake
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,402 @@
|
|
1
|
+
# `js-style-kit`
|
2
|
+
|
3
|
+
A zero-configuration style guide for ESLint and Prettier that provides sensible default settings and flexible configuration options.
|
4
|
+
|
5
|
+
[](https://github.com/drake-nathan/js-style-kit/actions/workflows/ci.yaml)
|
6
|
+
[](https://github.com/drake-nathan/js-style-kit/actions/workflows/release.yaml)
|
7
|
+
[](https://www.npmjs.com/package/js-style-kit)
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
9
|
+
[](https://codecov.io/gh/drake-nathan/js-style-kit)
|
10
|
+

|
11
|
+
|
12
|
+
## Overview
|
13
|
+
|
14
|
+
JS Style Kit is a comprehensive, batteries-included linting and formatting solution for modern JavaScript and TypeScript projects.
|
15
|
+
|
16
|
+
- ✅ All dependencies included (ESLint, Prettier, plugins) - no need to install extras
|
17
|
+
- ✅ ESLint v9 flat config
|
18
|
+
- ✅ TypeScript support out of the box
|
19
|
+
- ✅ Optional React and React Compiler support
|
20
|
+
- ✅ JSDoc validation with configurable requirements for libraries
|
21
|
+
- ✅ Automatic import, prop, and object sorting with Perfectionist
|
22
|
+
- ✅ Tailwind CSS support for Prettier
|
23
|
+
- ✅ Modern ESM-only package
|
24
|
+
|
25
|
+
> **Note:** This is very much a work in progress. I want to know what configuration changes you make, so please open an issue!
|
26
|
+
|
27
|
+
## Requirements
|
28
|
+
|
29
|
+
- Node.js v20.11.0 or higher
|
30
|
+
- TypeScript (for TypeScript projects, not bundled)
|
31
|
+
|
32
|
+
## Installation
|
33
|
+
|
34
|
+
```bash
|
35
|
+
npm install js-style-kit --save-dev
|
36
|
+
# or
|
37
|
+
yarn add js-style-kit --dev
|
38
|
+
# or
|
39
|
+
pnpm add js-style-kit --save-dev
|
40
|
+
# or
|
41
|
+
bun add js-style-kit --dev
|
42
|
+
```
|
43
|
+
|
44
|
+
## ESLint Configuration
|
45
|
+
|
46
|
+
### Basic Usage
|
47
|
+
|
48
|
+
Create an `eslint.config.js` file in your project root:
|
49
|
+
|
50
|
+
```js
|
51
|
+
import { eslintConfig } from "js-style-kit";
|
52
|
+
|
53
|
+
export default eslintConfig();
|
54
|
+
```
|
55
|
+
|
56
|
+
> **Note:** If you're not using `"type": "module"` in your package.json, name your file `eslint.config.mjs` instead.
|
57
|
+
|
58
|
+
Setup your `package.json` commands:
|
59
|
+
|
60
|
+
```json
|
61
|
+
{
|
62
|
+
"scripts": {
|
63
|
+
"lint": "eslint . --max-warnings 0",
|
64
|
+
"lint:fix": "eslint . --fix --max-warnings 0"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
```
|
68
|
+
|
69
|
+
> **Note:** The `--max-warnings 0` option is important because all rules are set to warning by default.
|
70
|
+
|
71
|
+
### Configuration Options
|
72
|
+
|
73
|
+
The `eslintConfig()` function accepts a configuration object with the following options:
|
74
|
+
|
75
|
+
```js
|
76
|
+
import { eslintConfig } from "js-style-kit";
|
77
|
+
|
78
|
+
export default eslintConfig({
|
79
|
+
// All options shown with their default values
|
80
|
+
functionStyle: "arrow", // Controls function style: "arrow", "declaration", "expression", or "off"
|
81
|
+
ignores: [], // Additional paths to ignore (node_modules and dist already excluded)
|
82
|
+
jsdoc: { requireJsdoc: false }, // JSDoc configuration or false to disable
|
83
|
+
react: false, // Whether to include React rules, see below for options
|
84
|
+
sorting: true, // Whether to include sorting rules from Perfectionist
|
85
|
+
storybook: false, // Whether to include Storybook rules
|
86
|
+
typescript: true, // Boolean or string path to tsconfig.json
|
87
|
+
});
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Function Style Configuration
|
91
|
+
|
92
|
+
Controls how functions should be written. Some configurations are auto-fixable, but some require manual adjustment.
|
93
|
+
|
94
|
+
```js
|
95
|
+
// Enforce arrow functions (default)
|
96
|
+
functionStyle: "arrow";
|
97
|
+
|
98
|
+
// Enforce function declarations
|
99
|
+
functionStyle: "declaration";
|
100
|
+
|
101
|
+
// Enforce function expressions
|
102
|
+
functionStyle: "expression";
|
103
|
+
|
104
|
+
// Disable function style enforcement
|
105
|
+
functionStyle: "off";
|
106
|
+
```
|
107
|
+
|
108
|
+
#### TypeScript Configuration
|
109
|
+
|
110
|
+
TypeScript support is enabled by default. You can:
|
111
|
+
|
112
|
+
```js
|
113
|
+
// Enable with automatic project detection
|
114
|
+
typescript: true;
|
115
|
+
|
116
|
+
// Disable TypeScript rules
|
117
|
+
typescript: false;
|
118
|
+
|
119
|
+
// Specify path to your tsconfig.json
|
120
|
+
typescript: "./tsconfig.json";
|
121
|
+
```
|
122
|
+
|
123
|
+
#### React Configuration
|
124
|
+
|
125
|
+
React support is disabled by default.
|
126
|
+
|
127
|
+
```js
|
128
|
+
// `true` enables standard react rules, react hook rules, and react compiler
|
129
|
+
react: true
|
130
|
+
|
131
|
+
// you can also pass an object to control react compiler and next support
|
132
|
+
react: {
|
133
|
+
reactCompiler: false,
|
134
|
+
reactRefresh: false, // Controls React Fast Refresh validation (disabled by default)
|
135
|
+
next: true
|
136
|
+
}
|
137
|
+
// next simply adds ".next" to the ignores array, but I plan add the next plugin in the future
|
138
|
+
```
|
139
|
+
|
140
|
+
#### JSDoc Configuration
|
141
|
+
|
142
|
+
JSDoc validation is enabled by default, but requirement rules are off:
|
143
|
+
|
144
|
+
```js
|
145
|
+
// Disable JSDoc validation completely
|
146
|
+
jsdoc: false;
|
147
|
+
|
148
|
+
// Enable JSDoc with requirement rules, ideal for libraries
|
149
|
+
jsdoc: {
|
150
|
+
requireJsdoc: true;
|
151
|
+
}
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Testing Configuration
|
155
|
+
|
156
|
+
Testing support is enabled by default with Vitest configuration. You can customize it or disable it completely:
|
157
|
+
|
158
|
+
```js
|
159
|
+
// Disable testing configuration
|
160
|
+
testing: false;
|
161
|
+
|
162
|
+
// Enable with custom options
|
163
|
+
testing: {
|
164
|
+
filenamePattern: "spec", // "test" (.test, default) or "spec" (.spec)
|
165
|
+
files: ["**/*.{test,spec}.{ts,tsx,js,jsx}"], // Override file patterns
|
166
|
+
formattingRules: true, // Whether to include formatting rules like padding around blocks
|
167
|
+
framework: "vitest", // "vitest" (default), "jest", "node", or "bun"
|
168
|
+
itOrTest: "test", // "it" (default) or "test"
|
169
|
+
}
|
170
|
+
```
|
171
|
+
|
172
|
+
#### Perfectionist (Code Organization)
|
173
|
+
|
174
|
+
Sorting/organization rules from the Perfectionist plugin are enabled by default:
|
175
|
+
|
176
|
+
```js
|
177
|
+
// Disable sorting rules
|
178
|
+
sorting: false;
|
179
|
+
```
|
180
|
+
|
181
|
+
#### Storybook Configuration
|
182
|
+
|
183
|
+
Storybook support is disabled by default, but can be enabled to provide linting rules specifically for Storybook files:
|
184
|
+
|
185
|
+
```js
|
186
|
+
// Enable Storybook rules
|
187
|
+
storybook: true;
|
188
|
+
```
|
189
|
+
|
190
|
+
When enabled, this configuration:
|
191
|
+
|
192
|
+
- Applies best practices for Storybook files (_.stories._ and _.story._)
|
193
|
+
- Includes rules for Storybook configuration files (.storybook/main.\*)
|
194
|
+
- Ensures the .storybook directory is not ignored by ESLint (adds a negation pattern to ignores)
|
195
|
+
|
196
|
+
### Adding Custom ESLint Configurations
|
197
|
+
|
198
|
+
You can extend the base configuration by providing additional ESLint config objects as rest parameters:
|
199
|
+
|
200
|
+
```js
|
201
|
+
import { eslintConfig } from "js-style-kit";
|
202
|
+
|
203
|
+
export default eslintConfig(
|
204
|
+
{
|
205
|
+
// Base configuration options
|
206
|
+
typescript: "tsconfig.eslint.json",
|
207
|
+
react: true,
|
208
|
+
},
|
209
|
+
// Additional custom ESLint configuration objects
|
210
|
+
{
|
211
|
+
name: "custom-globals",
|
212
|
+
languageOptions: {
|
213
|
+
globals: {
|
214
|
+
process: "readonly",
|
215
|
+
__dirname: "readonly",
|
216
|
+
},
|
217
|
+
},
|
218
|
+
},
|
219
|
+
{
|
220
|
+
name: "custom-rules",
|
221
|
+
rules: {
|
222
|
+
// Override or add specific rules
|
223
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
224
|
+
"max-len": ["warn", { code: 100 }],
|
225
|
+
quotes: ["error", "single"],
|
226
|
+
},
|
227
|
+
},
|
228
|
+
// Add as many additional configs as needed
|
229
|
+
);
|
230
|
+
```
|
231
|
+
|
232
|
+
## Prettier Configuration
|
233
|
+
|
234
|
+
### Basic Usage
|
235
|
+
|
236
|
+
Create a `prettier.config.js` file in your project root:
|
237
|
+
|
238
|
+
```js
|
239
|
+
import { prettierConfig } from "js-style-kit";
|
240
|
+
|
241
|
+
export default prettierConfig();
|
242
|
+
```
|
243
|
+
|
244
|
+
> **Note:** If you're not using `"type": "module"` in your package.json, name your file `prettier.config.mjs` instead.
|
245
|
+
|
246
|
+
Setup your `package.json` commands:
|
247
|
+
|
248
|
+
```json
|
249
|
+
{
|
250
|
+
"scripts": {
|
251
|
+
"format": "prettier --write .",
|
252
|
+
"format:check": "prettier --check ." // run this one in your CI
|
253
|
+
}
|
254
|
+
}
|
255
|
+
```
|
256
|
+
|
257
|
+
### Configuration Options
|
258
|
+
|
259
|
+
The `prettierConfig()` function accepts a configuration object with the following options:
|
260
|
+
|
261
|
+
```js
|
262
|
+
import { prettierConfig } from "js-style-kit";
|
263
|
+
|
264
|
+
export default prettierConfig({
|
265
|
+
// All options shown with their default values
|
266
|
+
cssOrderPlugin: true, // Enable CSS order plugin
|
267
|
+
curlyPlugin: true, // Enable curly braces enforcement for all control statements
|
268
|
+
jsonSortPlugin: true, // Enable JSON sorting plugin
|
269
|
+
packageJsonPlugin: true, // Enable package.json sorting plugin
|
270
|
+
tailwindPlugin: false, // Enable Tailwind CSS plugin (boolean, string[], or options object)
|
271
|
+
|
272
|
+
// You can also pass any standard Prettier options
|
273
|
+
printWidth: 80,
|
274
|
+
tabWidth: 2,
|
275
|
+
// etc.
|
276
|
+
});
|
277
|
+
```
|
278
|
+
|
279
|
+
#### Tailwind CSS Support
|
280
|
+
|
281
|
+
Tailwind CSS formatting is disabled by default. You can enable it in different ways:
|
282
|
+
|
283
|
+
```js
|
284
|
+
// Enable Tailwind with default utility functions (clsx, cva, cn)
|
285
|
+
tailwindPlugin: true
|
286
|
+
|
287
|
+
// Enable Tailwind with custom utility functions
|
288
|
+
tailwindPlugin: ["clsx", "cva", "cn", "myCustomFunction"]
|
289
|
+
|
290
|
+
// Enable Tailwind with custom options
|
291
|
+
tailwindPlugin: {
|
292
|
+
tailwindFunctions: ["clsx", "cva", "myCustomFunction"],
|
293
|
+
tailwindAttributes: ["tw"]
|
294
|
+
}
|
295
|
+
```
|
296
|
+
|
297
|
+
#### CSS Order Plugin
|
298
|
+
|
299
|
+
The CSS order plugin is enabled by default. It sorts CSS properties in a consistent order. You can disable it:
|
300
|
+
|
301
|
+
```js
|
302
|
+
// Disable CSS order plugin
|
303
|
+
cssOrderPlugin: false;
|
304
|
+
```
|
305
|
+
|
306
|
+
#### Curly Braces Enforcement
|
307
|
+
|
308
|
+
The curly braces plugin is disabled by default. It enforces consistent use of curly braces for all control flow statements (`if`, `for`, `while`, etc.), even for single-line statements. This is equivalent to ESLint's `curly` rule with the `all` option, but applied at the Prettier formatting level:
|
309
|
+
|
310
|
+
```diff
|
311
|
+
- if (abc) def;
|
312
|
+
+ if (abc) {
|
313
|
+
+ def;
|
314
|
+
+ }
|
315
|
+
```
|
316
|
+
|
317
|
+
You can disable it:
|
318
|
+
|
319
|
+
```js
|
320
|
+
// Disable curly braces enforcement
|
321
|
+
curlyPlugin: false;
|
322
|
+
```
|
323
|
+
|
324
|
+
#### JSON Sorting
|
325
|
+
|
326
|
+
The JSON sorting plugin is enabled by default. You can disable it or configure it:
|
327
|
+
|
328
|
+
```js
|
329
|
+
// Disable JSON sorting
|
330
|
+
jsonSortPlugin: false;
|
331
|
+
|
332
|
+
// Configure JSON sorting
|
333
|
+
jsonSortPlugin: {
|
334
|
+
jsonRecursiveSort: true;
|
335
|
+
// other plugin options...
|
336
|
+
}
|
337
|
+
```
|
338
|
+
|
339
|
+
#### Standard Prettier Options
|
340
|
+
|
341
|
+
You can pass any standard Prettier options directly:
|
342
|
+
|
343
|
+
```js
|
344
|
+
import { prettierConfig } from "js-style-kit";
|
345
|
+
|
346
|
+
export default prettierConfig({
|
347
|
+
// Enable Tailwind
|
348
|
+
tailwindPlugin: true,
|
349
|
+
|
350
|
+
// Standard Prettier options
|
351
|
+
printWidth: 100,
|
352
|
+
tabWidth: 2,
|
353
|
+
useTabs: false,
|
354
|
+
semi: true,
|
355
|
+
singleQuote: false,
|
356
|
+
trailingComma: "all",
|
357
|
+
bracketSpacing: true,
|
358
|
+
endOfLine: "lf",
|
359
|
+
});
|
360
|
+
```
|
361
|
+
|
362
|
+
## Complete Example
|
363
|
+
|
364
|
+
Here's a complete example with both ESLint and Prettier configurations:
|
365
|
+
|
366
|
+
### eslint.config.js
|
367
|
+
|
368
|
+
```js
|
369
|
+
import { eslintConfig } from "js-style-kit";
|
370
|
+
|
371
|
+
export default eslintConfig(
|
372
|
+
{
|
373
|
+
typescript: "tsconfig.eslint.json",
|
374
|
+
react: true,
|
375
|
+
jsdoc: { requireJsdoc: true },
|
376
|
+
functionStyle: "arrow",
|
377
|
+
},
|
378
|
+
{
|
379
|
+
name: "project-specific-rules",
|
380
|
+
rules: {
|
381
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
382
|
+
},
|
383
|
+
},
|
384
|
+
);
|
385
|
+
```
|
386
|
+
|
387
|
+
### prettier.config.js
|
388
|
+
|
389
|
+
```js
|
390
|
+
import { prettierConfig } from "js-style-kit";
|
391
|
+
|
392
|
+
export default prettierConfig({
|
393
|
+
tailwindPlugin: true,
|
394
|
+
cssOrderPlugin: true,
|
395
|
+
printWidth: 100,
|
396
|
+
singleQuote: true,
|
397
|
+
});
|
398
|
+
```
|
399
|
+
|
400
|
+
## License
|
401
|
+
|
402
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["console.info(\"eslint-plugin-nextjs\");\n"],"mappings":";AAAA,QAAQ,KAAK,sBAAsB;","names":[]}
|
package/package.json
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"name": "eslint-plugin-nextjs",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"description": "A fork of @next/eslint-plugin-next that's been upgraded for TypeScript and ESLint V9.",
|
5
|
+
"keywords": [
|
6
|
+
"eslint",
|
7
|
+
"nextjs"
|
8
|
+
],
|
9
|
+
"homepage": "https://github.com/drake-nathan/js-style-kit#readme",
|
10
|
+
"bugs": {
|
11
|
+
"url": "https://github.com/drake-nathan/js-style-kit/issues"
|
12
|
+
},
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+https://github.com/drake-nathan/js-style-kit.git"
|
16
|
+
},
|
17
|
+
"license": "MIT",
|
18
|
+
"author": "Nathan Drake <nathan@drakewest.dev>",
|
19
|
+
"type": "module",
|
20
|
+
"exports": {
|
21
|
+
".": "./dist/index.js"
|
22
|
+
},
|
23
|
+
"main": "./dist/index.js",
|
24
|
+
"types": "./dist/index.d.ts",
|
25
|
+
"files": [
|
26
|
+
"dist"
|
27
|
+
],
|
28
|
+
"scripts": {
|
29
|
+
"build": "tsup",
|
30
|
+
"dev": "tsup --watch",
|
31
|
+
"format": "prettier --write . --ignore-path .prettierignore.ci --cache",
|
32
|
+
"format:check": "prettier --check . --ignore-path .prettierignore.ci --cache",
|
33
|
+
"lint": "eslint .",
|
34
|
+
"lint:fix": "eslint . --fix",
|
35
|
+
"lint:inspect": "eslint --inspect-config",
|
36
|
+
"test": "bun test",
|
37
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov"
|
38
|
+
},
|
39
|
+
"devDependencies": {
|
40
|
+
"@repo/typescript-config": "workspace:*",
|
41
|
+
"@types/bun": "^1.2.8",
|
42
|
+
"@types/node": "^22.13.14",
|
43
|
+
"tsup": "^8.4.0",
|
44
|
+
"typescript": "^5.8.2"
|
45
|
+
},
|
46
|
+
"engines": {
|
47
|
+
"node": "^20.11.0 || >=21.2.0"
|
48
|
+
},
|
49
|
+
"publishConfig": {
|
50
|
+
"access": "public"
|
51
|
+
}
|
52
|
+
}
|