js-style-kit 0.2.12 → 0.3.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 CHANGED
@@ -43,7 +43,7 @@ bun add js-style-kit --dev
43
43
 
44
44
  ## ESLint Configuration
45
45
 
46
- ### Basic Usage
46
+ ### ESLint Usage
47
47
 
48
48
  Create an `eslint.config.js` file in your project root:
49
49
 
@@ -79,11 +79,18 @@ export default eslintConfig({
79
79
  // All options shown with their default values
80
80
  functionStyle: "arrow", // Controls function style: "arrow", "declaration", "expression", or "off"
81
81
  ignores: [], // Additional paths to ignore (node_modules and dist already excluded)
82
+ importPlugin: true, // Whether to include import plugin rules
82
83
  jsdoc: { requireJsdoc: false }, // JSDoc configuration or false to disable
83
84
  react: false, // Whether to include React rules, see below for options
85
+ rules: {}, // Custom rules to override or configure specific ESLint rules
84
86
  sorting: true, // Whether to include sorting rules from Perfectionist
85
87
  storybook: false, // Whether to include Storybook rules
88
+ testing: {
89
+ /* see Testing Configuration section */
90
+ }, // Testing configuration or false to disable
91
+ turbo: false, // Whether to include Turborepo rules
86
92
  typescript: true, // Boolean or string path to tsconfig.json
93
+ unicorn: true, // Whether to include Unicorn rules
87
94
  });
88
95
  ```
89
96
 
@@ -120,6 +127,32 @@ typescript: false;
120
127
  typescript: "./tsconfig.json";
121
128
  ```
122
129
 
130
+ #### Import Plugin Configuration
131
+
132
+ The import plugin rules are enabled by default. These rules help maintain proper import/export syntax and detect issues with imports.
133
+
134
+ ```js
135
+ // Enable import plugin (default)
136
+ importPlugin: true;
137
+
138
+ // Disable import plugin
139
+ importPlugin: false;
140
+ ```
141
+
142
+ #### Custom Rules Configuration
143
+
144
+ You can override or configure specific ESLint rules using the `rules` option:
145
+
146
+ ```js
147
+ // Add custom rule configurations
148
+ rules: {
149
+ // Format is the same as standard ESLint rule configuration
150
+ "no-console": ["error", { allow: ["warn", "error"] }],
151
+ "@typescript-eslint/no-explicit-any": "off",
152
+ // Any valid ESLint rule can be configured here
153
+ }
154
+ ```
155
+
123
156
  #### React Configuration
124
157
 
125
158
  React support is disabled by default.
@@ -128,13 +161,33 @@ React support is disabled by default.
128
161
  // `true` enables standard react rules, react hook rules, and react compiler
129
162
  react: true
130
163
 
131
- // you can also pass an object to control react compiler and next support
164
+ // you can also pass an object to control react compiler, framework, and refresh support
132
165
  react: {
133
166
  reactCompiler: false,
134
- reactRefresh: false, // Controls React Fast Refresh validation (disabled by default)
135
- next: true
167
+ reactRefresh: false, // Controls React Fast Refresh validation
168
+ framework: "next" // "next", "vite", or "none" to control related configurations
136
169
  }
137
- // next simply adds ".next" to the ignores array, but I plan add the next plugin in the future
170
+ // Using the framework option configures related features:
171
+ // - "next": Includes Next.js config, excludes React Refresh by default
172
+ // - "vite" or "none": Includes React Refresh by default, excludes Next.js
173
+ ```
174
+
175
+ #### Testing Configuration
176
+
177
+ Testing rules are enabled by default with smart defaults. You can customize them or disable them entirely:
178
+
179
+ ```js
180
+ // Disable testing rules
181
+ testing: false;
182
+
183
+ // Customize testing rules
184
+ testing: {
185
+ filenamePattern: "test", // "test" or "spec" for filename patterns
186
+ files: ["**/*.{test,spec}.{ts,tsx,js,jsx}"], // File patterns to match
187
+ formattingRules: true, // Whether to include formatting rules
188
+ framework: "vitest", // "vitest" or "jest"
189
+ itOrTest: "it", // Whether to use "it" or "test" as the test function
190
+ };
138
191
  ```
139
192
 
140
193
  #### JSDoc Configuration
@@ -151,7 +204,7 @@ jsdoc: {
151
204
  }
152
205
  ```
153
206
 
154
- #### Testing Configuration
207
+ #### Additional Testing Options
155
208
 
156
209
  Testing support is enabled by default with Vitest configuration. You can customize it or disable it completely:
157
210
 
@@ -231,7 +284,7 @@ export default eslintConfig(
231
284
 
232
285
  ## Prettier Configuration
233
286
 
234
- ### Basic Usage
287
+ ### Prettier Usage
235
288
 
236
289
  Create a `prettier.config.js` file in your project root:
237
290
 
@@ -254,7 +307,7 @@ Setup your `package.json` commands:
254
307
  }
255
308
  ```
256
309
 
257
- ### Configuration Options
310
+ ### Prettier Configuration
258
311
 
259
312
  The `prettierConfig()` function accepts a configuration object with the following options:
260
313
 
@@ -294,7 +347,7 @@ tailwindPlugin: {
294
347
  }
295
348
  ```
296
349
 
297
- #### CSS Order Plugin
350
+ #### CSS Properties Order
298
351
 
299
352
  The CSS order plugin is enabled by default. It sorts CSS properties in a consistent order. You can disable it:
300
353
 
@@ -374,11 +427,21 @@ export default eslintConfig(
374
427
  react: true,
375
428
  jsdoc: { requireJsdoc: true },
376
429
  functionStyle: "arrow",
430
+ // Use the built-in rules parameter for custom rules
431
+ rules: {
432
+ "no-console": ["error", { allow: ["warn", "error"] }],
433
+ },
434
+ // Configure testing
435
+ testing: {
436
+ framework: "jest",
437
+ itOrTest: "test",
438
+ },
377
439
  },
440
+ // You can still add additional config objects
378
441
  {
379
- name: "project-specific-rules",
442
+ name: "additional-config",
380
443
  rules: {
381
- "no-console": ["error", { allow: ["warn", "error"] }],
444
+ // More custom rules
382
445
  },
383
446
  },
384
447
  );
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 styleConfigContent = `import { eslintConfig, prettierConfig } from "js-style-kit";
3436
+ const prettierConfigContent = `
3437
+ import { prettierConfig } from "js-style-kit";
3437
3438
 
3438
- export const eslint = eslintConfig({});
3439
+ export default prettierConfig({});
3440
+ `;
3441
+ const eslintConfigContent = `
3442
+ import { eslintConfig } from "js-style-kit";
3439
3443
 
3440
- export const prettier = prettierConfig({});
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 = (extension) => {
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
- "explorer.fileNesting.enabled": true
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
- const extension = setupConfigFiles();
3504
- setupVSCodeSettings(extension);
3499
+ setupConfigFiles();
3500
+ setupVSCodeSettings();
3505
3501
  const runCmd = {
3506
3502
  bun: "bun run",
3507
3503
  npm: "npm run",