js-style-kit 0.2.12 → 0.4.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 +103 -19
- package/dist/bin/index.js +12 -16
- package/dist/bin/index.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +289 -90
- package/dist/index.js.map +1 -1
- package/package.json +18 -14
package/README.md
CHANGED
|
@@ -13,14 +13,36 @@ A zero-configuration style guide for ESLint and Prettier that provides sensible
|
|
|
13
13
|
|
|
14
14
|
JS Style Kit is a comprehensive, batteries-included linting and formatting solution for modern JavaScript and TypeScript projects.
|
|
15
15
|
|
|
16
|
-
- ✅ All dependencies included (ESLint, Prettier, plugins) - no need to install
|
|
16
|
+
- ✅ All dependencies included (ESLint, Prettier, plugins) - no need to install peer deps
|
|
17
17
|
- ✅ ESLint v9 flat config
|
|
18
|
-
- ✅
|
|
19
|
-
- ✅
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
- ✅ ESM-only package
|
|
19
|
+
- ✅ All rules configured as warnings
|
|
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
|
|
24
46
|
|
|
25
47
|
> **Note:** This is very much a work in progress. I want to know what configuration changes you make, so please open an issue!
|
|
26
48
|
|
|
@@ -43,7 +65,7 @@ bun add js-style-kit --dev
|
|
|
43
65
|
|
|
44
66
|
## ESLint Configuration
|
|
45
67
|
|
|
46
|
-
###
|
|
68
|
+
### ESLint Usage
|
|
47
69
|
|
|
48
70
|
Create an `eslint.config.js` file in your project root:
|
|
49
71
|
|
|
@@ -79,11 +101,18 @@ export default eslintConfig({
|
|
|
79
101
|
// All options shown with their default values
|
|
80
102
|
functionStyle: "arrow", // Controls function style: "arrow", "declaration", "expression", or "off"
|
|
81
103
|
ignores: [], // Additional paths to ignore (node_modules and dist already excluded)
|
|
104
|
+
importPlugin: true, // Whether to include import plugin rules
|
|
82
105
|
jsdoc: { requireJsdoc: false }, // JSDoc configuration or false to disable
|
|
83
106
|
react: false, // Whether to include React rules, see below for options
|
|
107
|
+
rules: {}, // Custom rules to override or configure specific ESLint rules
|
|
84
108
|
sorting: true, // Whether to include sorting rules from Perfectionist
|
|
85
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
|
|
86
114
|
typescript: true, // Boolean or string path to tsconfig.json
|
|
115
|
+
unicorn: true, // Whether to include Unicorn rules
|
|
87
116
|
});
|
|
88
117
|
```
|
|
89
118
|
|
|
@@ -120,6 +149,32 @@ typescript: false;
|
|
|
120
149
|
typescript: "./tsconfig.json";
|
|
121
150
|
```
|
|
122
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
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
123
178
|
#### React Configuration
|
|
124
179
|
|
|
125
180
|
React support is disabled by default.
|
|
@@ -128,13 +183,32 @@ React support is disabled by default.
|
|
|
128
183
|
// `true` enables standard react rules, react hook rules, and react compiler
|
|
129
184
|
react: true
|
|
130
185
|
|
|
131
|
-
// you can also pass an object to control react compiler and
|
|
186
|
+
// you can also pass an object to control react compiler, framework, and refresh support
|
|
132
187
|
react: {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
next: true
|
|
188
|
+
reactRefresh: false, // Controls React Fast Refresh validation
|
|
189
|
+
framework: "next" // "next", "vite", or "none" to control related configurations
|
|
136
190
|
}
|
|
137
|
-
//
|
|
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
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Testing Configuration
|
|
197
|
+
|
|
198
|
+
Testing rules are enabled by default with smart defaults. You can customize them or disable them entirely:
|
|
199
|
+
|
|
200
|
+
```js
|
|
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
|
+
};
|
|
138
212
|
```
|
|
139
213
|
|
|
140
214
|
#### JSDoc Configuration
|
|
@@ -151,7 +225,7 @@ jsdoc: {
|
|
|
151
225
|
}
|
|
152
226
|
```
|
|
153
227
|
|
|
154
|
-
#### Testing
|
|
228
|
+
#### Additional Testing Options
|
|
155
229
|
|
|
156
230
|
Testing support is enabled by default with Vitest configuration. You can customize it or disable it completely:
|
|
157
231
|
|
|
@@ -231,7 +305,7 @@ export default eslintConfig(
|
|
|
231
305
|
|
|
232
306
|
## Prettier Configuration
|
|
233
307
|
|
|
234
|
-
###
|
|
308
|
+
### Prettier Usage
|
|
235
309
|
|
|
236
310
|
Create a `prettier.config.js` file in your project root:
|
|
237
311
|
|
|
@@ -254,7 +328,7 @@ Setup your `package.json` commands:
|
|
|
254
328
|
}
|
|
255
329
|
```
|
|
256
330
|
|
|
257
|
-
### Configuration
|
|
331
|
+
### Prettier Configuration
|
|
258
332
|
|
|
259
333
|
The `prettierConfig()` function accepts a configuration object with the following options:
|
|
260
334
|
|
|
@@ -294,7 +368,7 @@ tailwindPlugin: {
|
|
|
294
368
|
}
|
|
295
369
|
```
|
|
296
370
|
|
|
297
|
-
#### CSS Order
|
|
371
|
+
#### CSS Properties Order
|
|
298
372
|
|
|
299
373
|
The CSS order plugin is enabled by default. It sorts CSS properties in a consistent order. You can disable it:
|
|
300
374
|
|
|
@@ -374,11 +448,21 @@ export default eslintConfig(
|
|
|
374
448
|
react: true,
|
|
375
449
|
jsdoc: { requireJsdoc: true },
|
|
376
450
|
functionStyle: "arrow",
|
|
451
|
+
// Use the built-in rules parameter for custom rules
|
|
452
|
+
rules: {
|
|
453
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
454
|
+
},
|
|
455
|
+
// Configure testing
|
|
456
|
+
testing: {
|
|
457
|
+
framework: "jest",
|
|
458
|
+
itOrTest: "test",
|
|
459
|
+
},
|
|
377
460
|
},
|
|
461
|
+
// You can still add additional config objects
|
|
378
462
|
{
|
|
379
|
-
name: "
|
|
463
|
+
name: "additional-config",
|
|
380
464
|
rules: {
|
|
381
|
-
|
|
465
|
+
// More custom rules
|
|
382
466
|
},
|
|
383
467
|
},
|
|
384
468
|
);
|
package/dist/bin/index.js
CHANGED
|
@@ -3433,17 +3433,16 @@ var setupConfigFiles = () => {
|
|
|
3433
3433
|
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
3434
3434
|
const isEsm = packageJson.type === "module";
|
|
3435
3435
|
extension = isEsm ? ".js" : ".mjs";
|
|
3436
|
-
const
|
|
3436
|
+
const prettierConfigContent = `
|
|
3437
|
+
import { prettierConfig } from "js-style-kit";
|
|
3437
3438
|
|
|
3438
|
-
export
|
|
3439
|
+
export default prettierConfig({});
|
|
3440
|
+
`;
|
|
3441
|
+
const eslintConfigContent = `
|
|
3442
|
+
import { eslintConfig } from "js-style-kit";
|
|
3439
3443
|
|
|
3440
|
-
export
|
|
3441
|
-
`;
|
|
3442
|
-
const prettierConfigContent = `export { prettier as default } from "./style-kit.config${extension}";
|
|
3443
|
-
`;
|
|
3444
|
-
const eslintConfigContent = `export { eslint as default } from "./style-kit.config${extension}";
|
|
3445
|
-
`;
|
|
3446
|
-
fs.writeFileSync(`style-kit.config${extension}`, styleConfigContent);
|
|
3444
|
+
export default eslintConfig({});
|
|
3445
|
+
`;
|
|
3447
3446
|
fs.writeFileSync(`prettier.config${extension}`, prettierConfigContent);
|
|
3448
3447
|
fs.writeFileSync(`eslint.config${extension}`, eslintConfigContent);
|
|
3449
3448
|
console.info(`Created configuration files with ${extension} extension`);
|
|
@@ -3453,7 +3452,7 @@ export const prettier = prettierConfig({});
|
|
|
3453
3452
|
}
|
|
3454
3453
|
return extension;
|
|
3455
3454
|
};
|
|
3456
|
-
var setupVSCodeSettings = (
|
|
3455
|
+
var setupVSCodeSettings = () => {
|
|
3457
3456
|
console.info("Setting up VS Code settings...");
|
|
3458
3457
|
try {
|
|
3459
3458
|
const vscodeDir = path.join(process.cwd(), ".vscode");
|
|
@@ -3473,11 +3472,8 @@ var setupVSCodeSettings = (extension) => {
|
|
|
3473
3472
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
3474
3473
|
"editor.formatOnSave": true,
|
|
3475
3474
|
"eslint.runtime": "node",
|
|
3476
|
-
"
|
|
3475
|
+
"tailwindCSS.classFunctions": ["cn", "cva", "clsx"]
|
|
3477
3476
|
};
|
|
3478
|
-
settings["explorer.fileNesting.patterns"] ??= {};
|
|
3479
|
-
const nestingPatterns = settings["explorer.fileNesting.patterns"];
|
|
3480
|
-
nestingPatterns[`style-kit.config${extension}`] = `eslint.config${extension}, prettier.config${extension}`;
|
|
3481
3477
|
fs.writeFileSync(
|
|
3482
3478
|
settingsPath,
|
|
3483
3479
|
JSON.stringify(settings, null, 2).concat("\n")
|
|
@@ -3500,8 +3496,8 @@ program2.command("init").description("Initialize project with js-style-kit confi
|
|
|
3500
3496
|
}
|
|
3501
3497
|
setupDependencies(packageManager);
|
|
3502
3498
|
setupScripts();
|
|
3503
|
-
|
|
3504
|
-
setupVSCodeSettings(
|
|
3499
|
+
setupConfigFiles();
|
|
3500
|
+
setupVSCodeSettings();
|
|
3505
3501
|
const runCmd = {
|
|
3506
3502
|
bun: "bun run",
|
|
3507
3503
|
npm: "npm run",
|