js-style-kit 0.5.2 → 0.6.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 +169 -355
- package/dist/index.d.ts +7 -3
- package/dist/index.js +84 -17
- package/dist/index.js.map +1 -1
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -7,49 +7,21 @@ A zero-configuration style guide for ESLint and Prettier that provides sensible
|
|
|
7
7
|
[](https://www.npmjs.com/package/js-style-kit)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://codecov.io/gh/drake-nathan/js-style-kit)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- ✅
|
|
17
|
-
- ✅
|
|
18
|
-
- ✅
|
|
19
|
-
- ✅
|
|
20
|
-
|
|
21
|
-
### Configs Included
|
|
22
|
-
|
|
23
|
-
> **Note:** All configs are optional and can be disabled or configured.
|
|
24
|
-
|
|
25
|
-
- ESlint
|
|
26
|
-
- Base config - Tweaked version of "recommended" config
|
|
27
|
-
- typescript-eslint - Falls somewhere between "recommended" and "strict"
|
|
28
|
-
- eslint-plugin-perfectionist - automatically sort all imports, objects, props, etc.
|
|
29
|
-
- eslint-plugin-import-x - faster version of eslint-plugin-import
|
|
30
|
-
- eslint-plugin-unicorn - enforce consistent file names (kebab-case will save you so many headaches)
|
|
31
|
-
- eslint-plugin-react - React rules
|
|
32
|
-
- eslint-plugin-react-hooks - React hooks rules
|
|
33
|
-
- eslint-plugin-react-refresh - React Fast Refresh validation for Vite
|
|
34
|
-
- eslint-plugin-nextjs - Next.js rules
|
|
35
|
-
- eslint-plugin-storybook - Storybook rules
|
|
36
|
-
- eslint-plugin-turbo - Turborepo rules
|
|
37
|
-
- eslint-plugin-jest - Jest rules
|
|
38
|
-
- eslint-plugin-vitest - Vitest rules
|
|
39
|
-
- Prettier
|
|
40
|
-
- Default config
|
|
41
|
-
- prettier-plugin-css-order
|
|
42
|
-
- prettier-plugin-curly
|
|
43
|
-
- prettier-plugin-packagejson
|
|
44
|
-
- prettier-plugin-sort-json
|
|
45
|
-
- prettier-plugin-tailwindcss
|
|
46
|
-
|
|
47
|
-
> **Note:** This is very much a work in progress. I want to know what configuration changes you make, so please open an issue!
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✅ **Batteries included** - ESLint, Prettier, and all plugins bundled (no peer dependency headaches)
|
|
14
|
+
- ✅ **ESLint v9** flat config format
|
|
15
|
+
- ✅ **TypeScript** first with automatic project detection
|
|
16
|
+
- ✅ **Framework support** - React, Next.js, Vite, Remix, React Router
|
|
17
|
+
- ✅ **Auto-sorting** - Imports, objects, properties, and more
|
|
18
|
+
- ✅ **Smart defaults** - All rules configured as warnings (not errors)
|
|
19
|
+
- ✅ **Highly configurable** - Enable only what you need, what you don't use is left out of the config for efficiency
|
|
20
|
+
- ✅ **ESM-only** - For modern JavaScript projects
|
|
48
21
|
|
|
49
22
|
## Requirements
|
|
50
23
|
|
|
51
24
|
- Node.js v20.11.0 or higher
|
|
52
|
-
- TypeScript (for TypeScript projects, not bundled)
|
|
53
25
|
|
|
54
26
|
## Installation
|
|
55
27
|
|
|
@@ -63,424 +35,266 @@ pnpm add js-style-kit --save-dev
|
|
|
63
35
|
bun add js-style-kit --dev
|
|
64
36
|
```
|
|
65
37
|
|
|
66
|
-
##
|
|
67
|
-
|
|
68
|
-
### ESLint Usage
|
|
38
|
+
## Quick Start
|
|
69
39
|
|
|
70
|
-
|
|
40
|
+
### Option 1: CLI (Recommended)
|
|
71
41
|
|
|
72
|
-
|
|
73
|
-
import { eslintConfig } from "js-style-kit";
|
|
42
|
+
The fastest way to get started is with our CLI tool:
|
|
74
43
|
|
|
75
|
-
|
|
44
|
+
```bash
|
|
45
|
+
npx js-style-kit init
|
|
76
46
|
```
|
|
77
47
|
|
|
78
|
-
|
|
48
|
+
This will:
|
|
79
49
|
|
|
80
|
-
|
|
50
|
+
1. Install dependencies
|
|
51
|
+
2. Create `style-kit.config.js`, `eslint.config.js`, and `prettier.config.js`
|
|
52
|
+
3. Add npm scripts to your `package.json`
|
|
53
|
+
4. Configure VS Code settings
|
|
81
54
|
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
"scripts": {
|
|
85
|
-
"lint": "eslint . --max-warnings 0",
|
|
86
|
-
"lint:fix": "eslint . --fix --max-warnings 0"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
55
|
+
[→ Learn more about the CLI](./bin/README.md)
|
|
90
56
|
|
|
91
|
-
|
|
57
|
+
### Option 2: Manual Setup
|
|
92
58
|
|
|
93
|
-
|
|
59
|
+
#### ESLint
|
|
94
60
|
|
|
95
|
-
|
|
61
|
+
Create `eslint.config.js` (or `eslint.config.mjs` if not using `"type": "module"`):
|
|
96
62
|
|
|
97
63
|
```js
|
|
64
|
+
// @ts-check
|
|
98
65
|
import { eslintConfig } from "js-style-kit";
|
|
99
66
|
|
|
100
|
-
export default eslintConfig(
|
|
101
|
-
// All options shown with their default values
|
|
102
|
-
functionStyle: "arrow", // Controls function style: "arrow", "declaration", "expression", or "off"
|
|
103
|
-
ignores: [], // Additional paths to ignore (node_modules and dist already excluded)
|
|
104
|
-
importPlugin: true, // Whether to include import plugin rules
|
|
105
|
-
jsdoc: { requireJsdoc: false }, // JSDoc configuration or false to disable
|
|
106
|
-
react: false, // Whether to include React rules, see below for options
|
|
107
|
-
rules: {}, // Custom rules to override or configure specific ESLint rules
|
|
108
|
-
sorting: true, // Whether to include sorting rules from Perfectionist
|
|
109
|
-
storybook: false, // Whether to include Storybook rules
|
|
110
|
-
testing: {
|
|
111
|
-
/* see Testing Configuration section */
|
|
112
|
-
}, // Testing configuration or false to disable
|
|
113
|
-
turbo: false, // Whether to include Turborepo rules
|
|
114
|
-
typescript: true, // Boolean or string path to tsconfig.json
|
|
115
|
-
unicorn: true, // Whether to include Unicorn rules
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
#### Function Style Configuration
|
|
120
|
-
|
|
121
|
-
Controls how functions should be written. Some configurations are auto-fixable, but some require manual adjustment.
|
|
122
|
-
|
|
123
|
-
```js
|
|
124
|
-
// Enforce arrow functions (default)
|
|
125
|
-
functionStyle: "arrow";
|
|
126
|
-
|
|
127
|
-
// Enforce function declarations
|
|
128
|
-
functionStyle: "declaration";
|
|
129
|
-
|
|
130
|
-
// Enforce function expressions
|
|
131
|
-
functionStyle: "expression";
|
|
132
|
-
|
|
133
|
-
// Disable function style enforcement
|
|
134
|
-
functionStyle: "off";
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
#### TypeScript Configuration
|
|
138
|
-
|
|
139
|
-
TypeScript support is enabled by default. You can:
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
// Enable with automatic project detection
|
|
143
|
-
typescript: true;
|
|
144
|
-
|
|
145
|
-
// Disable TypeScript rules
|
|
146
|
-
typescript: false;
|
|
147
|
-
|
|
148
|
-
// Specify path to your tsconfig.json
|
|
149
|
-
typescript: "./tsconfig.json";
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
#### Import Plugin Configuration
|
|
153
|
-
|
|
154
|
-
The import plugin rules are enabled by default. These rules help maintain proper import/export syntax and detect issues with imports.
|
|
155
|
-
|
|
156
|
-
```js
|
|
157
|
-
// Enable import plugin (default)
|
|
158
|
-
importPlugin: true;
|
|
159
|
-
|
|
160
|
-
// Disable import plugin
|
|
161
|
-
importPlugin: false;
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
#### Custom Rules Configuration
|
|
165
|
-
|
|
166
|
-
You can override or configure specific ESLint rules using the `rules` option:
|
|
167
|
-
|
|
168
|
-
```js
|
|
169
|
-
// Add custom rule configurations
|
|
170
|
-
rules: {
|
|
171
|
-
// Format is the same as standard ESLint rule configuration
|
|
172
|
-
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
173
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
174
|
-
// Any valid ESLint rule can be configured here
|
|
175
|
-
}
|
|
67
|
+
export default eslintConfig();
|
|
176
68
|
```
|
|
177
69
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
React support is disabled by default.
|
|
70
|
+
Add scripts to `package.json`:
|
|
181
71
|
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
reactRefresh: false, // Controls React Fast Refresh validation
|
|
189
|
-
framework: "next" // "next", "vite", or "none" to control related configurations
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"scripts": {
|
|
75
|
+
"lint": "eslint . --max-warnings=0 --cache",
|
|
76
|
+
"lint:fix": "eslint . --fix --max-warnings=0 --cache"
|
|
77
|
+
}
|
|
190
78
|
}
|
|
191
|
-
// Using the framework option configures related features:
|
|
192
|
-
// - "next": Includes Next.js config, excludes React Refresh by default
|
|
193
|
-
// - "vite" or "none": Includes React Refresh by default, excludes Next.js
|
|
194
79
|
```
|
|
195
80
|
|
|
196
|
-
|
|
81
|
+
> **Note:** The `--max-warnings=0` flag is important since all rules are warnings by default.
|
|
197
82
|
|
|
198
|
-
|
|
83
|
+
#### Prettier
|
|
199
84
|
|
|
200
|
-
|
|
201
|
-
// Disable testing rules
|
|
202
|
-
testing: false;
|
|
203
|
-
|
|
204
|
-
// Customize testing rules
|
|
205
|
-
testing: {
|
|
206
|
-
filenamePattern: "test", // "test" or "spec" for filename patterns
|
|
207
|
-
files: ["**/*.{test,spec}.{ts,tsx,js,jsx}"], // File patterns to match
|
|
208
|
-
formattingRules: true, // Whether to include formatting rules
|
|
209
|
-
framework: "vitest", // "vitest" or "jest"
|
|
210
|
-
itOrTest: "it", // Whether to use "it" or "test" as the test function
|
|
211
|
-
};
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
#### JSDoc Configuration
|
|
215
|
-
|
|
216
|
-
JSDoc validation is enabled by default, but requirement rules are off:
|
|
85
|
+
Create `prettier.config.js` (or `prettier.config.mjs` if not using `"type": "module"`):
|
|
217
86
|
|
|
218
87
|
```js
|
|
219
|
-
//
|
|
220
|
-
|
|
88
|
+
// @ts-check
|
|
89
|
+
import { prettierConfig } from "js-style-kit";
|
|
221
90
|
|
|
222
|
-
|
|
223
|
-
jsdoc: {
|
|
224
|
-
requireJsdoc: true;
|
|
225
|
-
}
|
|
91
|
+
export default prettierConfig();
|
|
226
92
|
```
|
|
227
93
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Testing support is enabled by default with Vitest configuration. You can customize it or disable it completely:
|
|
94
|
+
Add scripts to `package.json`:
|
|
231
95
|
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
filenamePattern: "spec", // "test" (.test, default) or "spec" (.spec)
|
|
239
|
-
files: ["**/*.{test,spec}.{ts,tsx,js,jsx}"], // Override file patterns
|
|
240
|
-
formattingRules: true, // Whether to include formatting rules like padding around blocks
|
|
241
|
-
framework: "vitest", // "vitest" (default), "jest", "node", or "bun"
|
|
242
|
-
itOrTest: "test", // "it" (default) or "test"
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"scripts": {
|
|
99
|
+
"format": "prettier . --write --cache",
|
|
100
|
+
"format:check": "prettier . --check --cache"
|
|
101
|
+
}
|
|
243
102
|
}
|
|
244
103
|
```
|
|
245
104
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
Sorting/organization rules from the Perfectionist plugin are enabled by default:
|
|
249
|
-
|
|
250
|
-
```js
|
|
251
|
-
// Disable sorting rules
|
|
252
|
-
sorting: false;
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
#### Storybook Configuration
|
|
105
|
+
## Configuration
|
|
256
106
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```js
|
|
260
|
-
// Enable Storybook rules
|
|
261
|
-
storybook: true;
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
When enabled, this configuration:
|
|
265
|
-
|
|
266
|
-
- Applies best practices for Storybook files (_.stories._ and _.story._)
|
|
267
|
-
- Includes rules for Storybook configuration files (.storybook/main.\*)
|
|
268
|
-
- Ensures the .storybook directory is not ignored by ESLint (adds a negation pattern to ignores)
|
|
269
|
-
|
|
270
|
-
### Adding Custom ESLint Configurations
|
|
271
|
-
|
|
272
|
-
You can extend the base configuration by providing additional ESLint config objects as rest parameters:
|
|
107
|
+
### ESLint Options
|
|
273
108
|
|
|
274
109
|
```js
|
|
275
110
|
import { eslintConfig } from "js-style-kit";
|
|
276
111
|
|
|
277
112
|
export default eslintConfig(
|
|
278
113
|
{
|
|
279
|
-
//
|
|
280
|
-
typescript:
|
|
281
|
-
react:
|
|
114
|
+
// Core options
|
|
115
|
+
typescript: true, // Boolean or path to tsconfig.json
|
|
116
|
+
react: false, // React support (see React config docs)
|
|
117
|
+
functionStyle: "arrow", // "arrow" | "declaration" | "expression" | "off"
|
|
118
|
+
|
|
119
|
+
// Plugin toggles
|
|
120
|
+
importPlugin: true, // Import/export validation
|
|
121
|
+
sorting: true, // Auto-sort imports, objects, etc.
|
|
122
|
+
unicorn: true, // Enforce file naming and best practices
|
|
123
|
+
jsdoc: { requireJsdoc: false }, // JSDoc validation
|
|
124
|
+
|
|
125
|
+
// Framework & tools
|
|
126
|
+
query: false, // TanStack Query rules
|
|
127
|
+
testing: { framework: "vitest" }, // Test framework config
|
|
128
|
+
storybook: false, // Storybook rules
|
|
129
|
+
turbo: false, // Turborepo rules
|
|
130
|
+
|
|
131
|
+
// Advanced
|
|
132
|
+
ignores: [], // Additional ignore patterns
|
|
133
|
+
rules: {}, // Custom rule overrides
|
|
282
134
|
},
|
|
283
|
-
// Additional
|
|
135
|
+
// Additional ESLint config objects
|
|
284
136
|
{
|
|
285
137
|
name: "custom-globals",
|
|
286
138
|
languageOptions: {
|
|
287
139
|
globals: {
|
|
288
140
|
process: "readonly",
|
|
289
|
-
__dirname: "readonly",
|
|
290
141
|
},
|
|
291
142
|
},
|
|
292
143
|
},
|
|
293
|
-
{
|
|
294
|
-
name: "custom-rules",
|
|
295
|
-
rules: {
|
|
296
|
-
// Override or add specific rules
|
|
297
|
-
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
298
|
-
"max-len": ["warn", { code: 100 }],
|
|
299
|
-
quotes: ["error", "single"],
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
// Add as many additional configs as needed
|
|
303
144
|
);
|
|
304
145
|
```
|
|
305
146
|
|
|
306
|
-
|
|
147
|
+
### Configuration Guides
|
|
307
148
|
|
|
308
|
-
|
|
149
|
+
Each configuration has detailed documentation:
|
|
309
150
|
|
|
310
|
-
|
|
151
|
+
- **Core Configs**
|
|
152
|
+
- [Base ESLint Rules](./src/eslint/base/README.md)
|
|
153
|
+
- [TypeScript](./src/eslint/typescript/README.md)
|
|
154
|
+
- [Sorting (Perfectionist)](./src/eslint/perfectionist/README.md)
|
|
155
|
+
- [Import Plugin](./src/eslint/import/README.md)
|
|
156
|
+
- [Unicorn](./src/eslint/unicorn/README.md)
|
|
311
157
|
|
|
312
|
-
|
|
313
|
-
|
|
158
|
+
- **Framework Configs**
|
|
159
|
+
- [React](./src/eslint/react/README.md) - React, hooks, compiler, and refresh support
|
|
160
|
+
- [TanStack Query](./src/eslint/query/README.md) - Query best practices
|
|
314
161
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
Setup your `package.json` commands:
|
|
162
|
+
- **Tool Configs**
|
|
163
|
+
- [Testing](./src/eslint/testing/README.md) - Vitest, Jest, Bun, Node
|
|
164
|
+
- [JSDoc](./src/eslint/jsdoc/README.md) - Documentation validation
|
|
165
|
+
- [Storybook](./src/eslint/storybook/README.md) - Component story rules
|
|
166
|
+
- [Turborepo](./src/eslint/turbo/README.md) - Monorepo rules
|
|
321
167
|
|
|
322
|
-
|
|
323
|
-
{
|
|
324
|
-
"scripts": {
|
|
325
|
-
"format": "prettier --write .",
|
|
326
|
-
"format:check": "prettier --check ." // run this one in your CI
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Prettier Configuration
|
|
332
|
-
|
|
333
|
-
The `prettierConfig()` function accepts a configuration object with the following options:
|
|
168
|
+
### Prettier Options
|
|
334
169
|
|
|
335
170
|
```js
|
|
336
171
|
import { prettierConfig } from "js-style-kit";
|
|
337
172
|
|
|
338
173
|
export default prettierConfig({
|
|
339
|
-
//
|
|
340
|
-
cssOrderPlugin: true, //
|
|
341
|
-
curlyPlugin: true, //
|
|
342
|
-
jsonSortPlugin: true, //
|
|
343
|
-
packageJsonPlugin: true, //
|
|
344
|
-
tailwindPlugin: false, //
|
|
345
|
-
|
|
346
|
-
|
|
174
|
+
// Plugin options
|
|
175
|
+
cssOrderPlugin: true, // Sort CSS properties
|
|
176
|
+
curlyPlugin: true, // Enforce curly braces
|
|
177
|
+
jsonSortPlugin: true, // Sort JSON keys
|
|
178
|
+
packageJsonPlugin: true, // Sort package.json
|
|
179
|
+
tailwindPlugin: false, // Boolean, path to global css file, or config object
|
|
180
|
+
parser: "oxc", // "oxc" (faster) or "default"
|
|
181
|
+
|
|
182
|
+
// Standard Prettier options
|
|
347
183
|
printWidth: 80,
|
|
348
184
|
tabWidth: 2,
|
|
349
|
-
//
|
|
185
|
+
// ... any Prettier option
|
|
350
186
|
});
|
|
351
187
|
```
|
|
352
188
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
Tailwind CSS formatting is disabled by default. You can enable it in different ways:
|
|
356
|
-
|
|
357
|
-
```js
|
|
358
|
-
// Enable Tailwind with default utility functions (clsx, cva, cn)
|
|
359
|
-
tailwindPlugin: true
|
|
360
|
-
|
|
361
|
-
// Enable Tailwind with custom utility functions
|
|
362
|
-
tailwindPlugin: ["clsx", "cva", "cn", "myCustomFunction"]
|
|
363
|
-
|
|
364
|
-
// Enable Tailwind with custom options
|
|
365
|
-
tailwindPlugin: {
|
|
366
|
-
tailwindFunctions: ["clsx", "cva", "myCustomFunction"],
|
|
367
|
-
tailwindAttributes: ["tw"]
|
|
368
|
-
}
|
|
369
|
-
```
|
|
189
|
+
[→ Full Prettier documentation](./src/prettier/README.md)
|
|
370
190
|
|
|
371
|
-
|
|
191
|
+
## Framework Examples
|
|
372
192
|
|
|
373
|
-
|
|
193
|
+
### React with Next.js
|
|
374
194
|
|
|
375
195
|
```js
|
|
376
|
-
|
|
377
|
-
cssOrderPlugin: false;
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
#### Curly Braces Enforcement
|
|
381
|
-
|
|
382
|
-
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:
|
|
383
|
-
|
|
384
|
-
```diff
|
|
385
|
-
- if (abc) def;
|
|
386
|
-
+ if (abc) {
|
|
387
|
-
+ def;
|
|
388
|
-
+ }
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
You can disable it:
|
|
196
|
+
import { eslintConfig } from "js-style-kit";
|
|
392
197
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
198
|
+
export default eslintConfig({
|
|
199
|
+
typescript: "./tsconfig.json",
|
|
200
|
+
react: {
|
|
201
|
+
framework: "next",
|
|
202
|
+
reactCompiler: true, // React 19 compiler rules (enabled by default)
|
|
203
|
+
},
|
|
204
|
+
testing: {
|
|
205
|
+
framework: "vitest",
|
|
206
|
+
itOrTest: "it",
|
|
207
|
+
},
|
|
208
|
+
});
|
|
396
209
|
```
|
|
397
210
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
The JSON sorting plugin is enabled by default. You can disable it or configure it:
|
|
211
|
+
### React with Vite
|
|
401
212
|
|
|
402
213
|
```js
|
|
403
|
-
|
|
404
|
-
jsonSortPlugin: false;
|
|
214
|
+
import { eslintConfig } from "js-style-kit";
|
|
405
215
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
216
|
+
export default eslintConfig({
|
|
217
|
+
react: {
|
|
218
|
+
framework: "vite",
|
|
219
|
+
reactRefresh: true, // Fast Refresh validation (enabled by default with vite)
|
|
220
|
+
},
|
|
221
|
+
testing: { framework: "vitest" },
|
|
222
|
+
});
|
|
411
223
|
```
|
|
412
224
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
You can pass any standard Prettier options directly:
|
|
225
|
+
### TypeScript Library
|
|
416
226
|
|
|
417
227
|
```js
|
|
418
|
-
import {
|
|
419
|
-
|
|
420
|
-
export default prettierConfig({
|
|
421
|
-
// Enable Tailwind
|
|
422
|
-
tailwindPlugin: true,
|
|
228
|
+
import { eslintConfig } from "js-style-kit";
|
|
423
229
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
semi: true,
|
|
429
|
-
singleQuote: false,
|
|
430
|
-
trailingComma: "all",
|
|
431
|
-
bracketSpacing: true,
|
|
432
|
-
endOfLine: "lf",
|
|
230
|
+
export default eslintConfig({
|
|
231
|
+
typescript: "./tsconfig.json",
|
|
232
|
+
jsdoc: { requireJsdoc: true }, // Enforce JSDoc for public APIs
|
|
233
|
+
testing: { framework: "bun" },
|
|
433
234
|
});
|
|
434
235
|
```
|
|
435
236
|
|
|
436
|
-
##
|
|
437
|
-
|
|
438
|
-
Here's a complete example with both ESLint and Prettier configurations:
|
|
237
|
+
## Adding Custom Rules
|
|
439
238
|
|
|
440
|
-
|
|
239
|
+
You can override any rule or add custom configurations. If you disable a rule in the `rules` object, it will be removed from the config for efficiency.
|
|
441
240
|
|
|
442
241
|
```js
|
|
443
242
|
import { eslintConfig } from "js-style-kit";
|
|
444
243
|
|
|
445
244
|
export default eslintConfig(
|
|
446
245
|
{
|
|
447
|
-
typescript:
|
|
246
|
+
typescript: true,
|
|
448
247
|
react: true,
|
|
449
|
-
jsdoc: { requireJsdoc: true },
|
|
450
|
-
functionStyle: "arrow",
|
|
451
|
-
// Use the built-in rules parameter for custom rules
|
|
452
248
|
rules: {
|
|
249
|
+
// Override built-in rules
|
|
453
250
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
454
|
-
|
|
455
|
-
// Configure testing
|
|
456
|
-
testing: {
|
|
457
|
-
framework: "jest",
|
|
458
|
-
itOrTest: "test",
|
|
251
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
459
252
|
},
|
|
460
253
|
},
|
|
461
|
-
//
|
|
254
|
+
// Additional ESLint config objects
|
|
462
255
|
{
|
|
463
|
-
name: "
|
|
464
|
-
|
|
465
|
-
|
|
256
|
+
name: "custom-globals",
|
|
257
|
+
languageOptions: {
|
|
258
|
+
globals: {
|
|
259
|
+
process: "readonly",
|
|
260
|
+
},
|
|
466
261
|
},
|
|
467
262
|
},
|
|
468
263
|
);
|
|
469
264
|
```
|
|
470
265
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
266
|
+
## What's Included
|
|
267
|
+
|
|
268
|
+
### ESLint Plugins
|
|
269
|
+
|
|
270
|
+
- [`typescript-eslint`](https://typescript-eslint.io) - TypeScript linting
|
|
271
|
+
- [`eslint-plugin-perfectionist`](https://perfectionist.dev) - Auto-sorting
|
|
272
|
+
- [`eslint-plugin-import-x`](https://www.npmjs.com/package/eslint-plugin-import-x) - Import/export validation
|
|
273
|
+
- [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn) - Best practices & naming
|
|
274
|
+
- [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react) - React rules
|
|
275
|
+
- [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks) - React hooks rules
|
|
276
|
+
- [`eslint-plugin-react-refresh`](https://www.npmjs.com/package/eslint-plugin-react-refresh) - Fast Refresh validation
|
|
277
|
+
- [`eslint-plugin-nextjs`](../eslint-plugin-nextjs/README.md) - My fork of the Next.js plugin
|
|
278
|
+
- [`@tanstack/eslint-plugin-query`](https://tanstack.com/query/v4/docs/eslint/eslint-plugin-query) - TanStack Query rules
|
|
279
|
+
- [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) - JSDoc validation
|
|
280
|
+
- [`eslint-plugin-storybook`](https://www.npmjs.com/package/eslint-plugin-storybook) - Storybook rules
|
|
281
|
+
- [`eslint-plugin-turbo`](https://www.npmjs.com/package/eslint-plugin-turbo) - Turborepo rules
|
|
282
|
+
- [`eslint-plugin-vitest`](https://www.npmjs.com/package/eslint-plugin-vitest) - Vitest rules
|
|
283
|
+
- [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest) - Jest rules
|
|
284
|
+
|
|
285
|
+
### Prettier Plugins
|
|
286
|
+
|
|
287
|
+
- [`prettier-plugin-css-order`](https://www.npmjs.com/package/prettier-plugin-css-order) - CSS property ordering
|
|
288
|
+
- [`prettier-plugin-curly`](https://www.npmjs.com/package/prettier-plugin-curly) - Curly brace enforcement
|
|
289
|
+
- [`prettier-plugin-packagejson`](https://www.npmjs.com/package/prettier-plugin-packagejson) - package.json sorting
|
|
290
|
+
- [`prettier-plugin-sort-json`](https://www.npmjs.com/package/prettier-plugin-sort-json) - JSON sorting
|
|
291
|
+
- [`prettier-plugin-tailwindcss`](https://www.npmjs.com/package/prettier-plugin-tailwindcss) - Tailwind class sorting
|
|
292
|
+
- [`@prettier/plugin-oxc`](https://www.npmjs.com/package/@prettier/plugin-oxc) - Faster parser (optional)
|
|
483
293
|
|
|
484
294
|
## License
|
|
485
295
|
|
|
486
296
|
MIT
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
**Note:** This is a work in progress. Please [open an issue](https://github.com/drake-nathan/js-style-kit/issues) if you have suggestions or find any problems!
|