js-style-kit 0.6.1 → 0.7.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 +5 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
- package/src/eslint/base/README.md +186 -0
- package/src/eslint/base/config.ts +37 -0
- package/src/eslint/base/rules.ts +444 -0
- package/src/eslint/base/types.ts +20 -0
- package/src/eslint/constants.ts +52 -0
- package/src/eslint/convex/README.md +30 -0
- package/src/eslint/convex/config.ts +34 -0
- package/src/eslint/convex/rules.ts +8 -0
- package/src/eslint/convex/types.ts +8 -0
- package/src/eslint/ignores.ts +31 -0
- package/src/eslint/import/README.md +397 -0
- package/src/eslint/import/config.ts +48 -0
- package/src/eslint/import/rules.ts +81 -0
- package/src/eslint/index.ts +259 -0
- package/src/eslint/jsdoc/README.md +399 -0
- package/src/eslint/jsdoc/config.ts +29 -0
- package/src/eslint/jsdoc/rules.ts +81 -0
- package/src/eslint/jsdoc/types.ts +56 -0
- package/src/eslint/nextjs/config.ts +25 -0
- package/src/eslint/nextjs/rules.ts +25 -0
- package/src/eslint/nextjs/types.ts +27 -0
- package/src/eslint/perfectionist/README.md +454 -0
- package/src/eslint/perfectionist/config.ts +25 -0
- package/src/eslint/perfectionist/rules.ts +39 -0
- package/src/eslint/prefer-arrow-function/config.ts +33 -0
- package/src/eslint/prefer-arrow-function/types.ts +13 -0
- package/src/eslint/process-custom-rules.ts +72 -0
- package/src/eslint/query/README.md +254 -0
- package/src/eslint/query/config.ts +27 -0
- package/src/eslint/query/rules.ts +11 -0
- package/src/eslint/query/types.ts +11 -0
- package/src/eslint/react/README.md +416 -0
- package/src/eslint/react/config.ts +65 -0
- package/src/eslint/react/rules.ts +188 -0
- package/src/eslint/react/types.ts +26 -0
- package/src/eslint/react-refresh/config.ts +28 -0
- package/src/eslint/react-refresh/rules.ts +48 -0
- package/src/eslint/storybook/README.md +424 -0
- package/src/eslint/storybook/config.ts +57 -0
- package/src/eslint/testing/README.md +436 -0
- package/src/eslint/testing/config.ts +90 -0
- package/src/eslint/testing/jest-rules.ts +47 -0
- package/src/eslint/testing/vitest-rules.ts +42 -0
- package/src/eslint/turbo/README.md +380 -0
- package/src/eslint/turbo/config.ts +26 -0
- package/src/eslint/turbo/types.ts +7 -0
- package/src/eslint/types.ts +29 -0
- package/src/eslint/typescript/README.md +229 -0
- package/src/eslint/typescript/config.ts +48 -0
- package/src/eslint/typescript/rules.ts +137 -0
- package/src/eslint/typescript/types.ts +35 -0
- package/src/eslint/unicorn/README.md +497 -0
- package/src/eslint/unicorn/config.ts +36 -0
- package/src/eslint/unicorn/rules.ts +86 -0
- package/src/index.ts +3 -0
- package/src/modules.d.ts +5 -0
- package/src/prettier/README.md +413 -0
- package/src/prettier/index.ts +110 -0
- package/src/utils/is-type.ts +60 -0
package/README.md
CHANGED
|
@@ -120,6 +120,8 @@ export default eslintConfig(
|
|
|
120
120
|
importPlugin: true, // Import/export validation
|
|
121
121
|
sorting: true, // Auto-sort imports, objects, etc.
|
|
122
122
|
unicorn: true, // Enforce file naming and best practices
|
|
123
|
+
// or configure filename case:
|
|
124
|
+
// unicorn: { filenameCase: "kebabCase" }, // "camelCase" | "kebabCase" | "pascalCase" | "snakeCase"
|
|
123
125
|
jsdoc: { requireJsdoc: false }, // JSDoc validation
|
|
124
126
|
|
|
125
127
|
// Framework & tools
|
|
@@ -127,6 +129,7 @@ export default eslintConfig(
|
|
|
127
129
|
testing: { framework: "vitest" }, // Test framework config
|
|
128
130
|
storybook: false, // Storybook rules
|
|
129
131
|
turbo: false, // Turborepo rules
|
|
132
|
+
convex: false, // Convex backend rules
|
|
130
133
|
|
|
131
134
|
// Advanced
|
|
132
135
|
ignores: [], // Additional ignore patterns
|
|
@@ -164,6 +167,7 @@ Each configuration has detailed documentation:
|
|
|
164
167
|
- [JSDoc](./src/eslint/jsdoc/README.md) - Documentation validation
|
|
165
168
|
- [Storybook](./src/eslint/storybook/README.md) - Component story rules
|
|
166
169
|
- [Turborepo](./src/eslint/turbo/README.md) - Monorepo rules
|
|
170
|
+
- [Convex](./src/eslint/convex/README.md) - Convex backend rules
|
|
167
171
|
|
|
168
172
|
### Prettier Options
|
|
169
173
|
|
|
@@ -281,6 +285,7 @@ export default eslintConfig(
|
|
|
281
285
|
- [`eslint-plugin-turbo`](https://www.npmjs.com/package/eslint-plugin-turbo) - Turborepo rules
|
|
282
286
|
- [`eslint-plugin-vitest`](https://www.npmjs.com/package/eslint-plugin-vitest) - Vitest rules
|
|
283
287
|
- [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest) - Jest rules
|
|
288
|
+
- [`@convex-dev/eslint-plugin`](https://docs.convex.dev/eslint) - Convex backend rules
|
|
284
289
|
|
|
285
290
|
### Prettier Plugins
|
|
286
291
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { PluginOptions } from 'prettier-plugin-tailwindcss';
|
|
|
10
10
|
*/
|
|
11
11
|
declare const configNames: {
|
|
12
12
|
readonly base: "base";
|
|
13
|
+
readonly convex: "convex";
|
|
13
14
|
readonly disableTypeChecked: "UserConfig[1] > typescript-eslint/disable-type-checked";
|
|
14
15
|
readonly ignores: "ignores";
|
|
15
16
|
readonly import: "import";
|
|
@@ -33,10 +34,11 @@ type ConfigName = (typeof configNames)[keyof typeof configNames];
|
|
|
33
34
|
|
|
34
35
|
type EslintSeverity = 0 | 1 | 2 | "error" | "off" | "warn";
|
|
35
36
|
type EslintRuleConfig<TOptions = Record<string, unknown>, TOptions2 = Record<string, unknown>> = [EslintSeverity, string | TOptions | undefined] | [EslintSeverity, string | undefined, TOptions2 | undefined] | [EslintSeverity, TOptions | undefined, TOptions2 | undefined] | [EslintSeverity] | EslintSeverity;
|
|
36
|
-
type FunctionStyle = "arrow" | "declaration" | "expression";
|
|
37
37
|
interface EslintConfigObject<Rules extends Linter.RulesRecord = Linter.RulesRecord> extends Linter.Config<Rules> {
|
|
38
38
|
name: ConfigName;
|
|
39
39
|
}
|
|
40
|
+
type FilenameCase = "camelCase" | "kebabCase" | "pascalCase" | "snakeCase";
|
|
41
|
+
type FunctionStyle = "arrow" | "declaration" | "expression";
|
|
40
42
|
|
|
41
43
|
interface TestingConfig {
|
|
42
44
|
filenamePattern?: "spec" | "test";
|
|
@@ -47,6 +49,7 @@ interface TestingConfig {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
interface EslintConfigOptions {
|
|
52
|
+
convex?: boolean;
|
|
50
53
|
functionStyle?: "off" | FunctionStyle;
|
|
51
54
|
ignores?: string[];
|
|
52
55
|
importPlugin?: boolean;
|
|
@@ -65,12 +68,15 @@ interface EslintConfigOptions {
|
|
|
65
68
|
testing?: false | TestingConfig;
|
|
66
69
|
turbo?: boolean;
|
|
67
70
|
typescript?: boolean | string;
|
|
68
|
-
unicorn?: boolean
|
|
71
|
+
unicorn?: boolean | {
|
|
72
|
+
filenameCase?: FilenameCase;
|
|
73
|
+
};
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
71
76
|
* Configures ESLint based on provided options.
|
|
72
77
|
*
|
|
73
78
|
* @param options - The optional configuration object.
|
|
79
|
+
* @param options.convex - Whether to include Convex rules.
|
|
74
80
|
* @param options.functionStyle - The function style to enforce. Defaults to "arrow".
|
|
75
81
|
* @param options.ignores - Additional paths to ignore. Already excludes `node_modules` and `dist`.
|
|
76
82
|
* @param options.importPlugin - Whether to include the import plugin. Defaults to true.
|
|
@@ -92,12 +98,12 @@ interface EslintConfigOptions {
|
|
|
92
98
|
* - `itOrTest`: One of "it" or "test" to determine which test function to use.
|
|
93
99
|
* @param options.typescript - Whether to include TypeScript rules. Can be a boolean or a string with path to tsconfig.
|
|
94
100
|
* @param options.turbo - Whether to include Turborepo rules. Defaults to false.
|
|
95
|
-
* @param options.unicorn - Whether to include Unicorn rules. Defaults to true.
|
|
101
|
+
* @param options.unicorn - Whether to include Unicorn rules. Defaults to true. Can be an object with filenameCase property.
|
|
96
102
|
* @param options.rules - This is for rules that you need to alter or turn off.
|
|
97
103
|
* @param additionalConfigs - Additional ESLint config objects to be merged into the final configuration.
|
|
98
104
|
* @returns An array of ESLint configuration objects.
|
|
99
105
|
*/
|
|
100
|
-
declare const eslintConfig: ({ functionStyle, ignores, importPlugin, jsdoc, query, react, rules, sorting, storybook, testing, turbo, typescript, unicorn, }?: EslintConfigOptions, ...additionalConfigs: Linter.Config[]) => Linter.Config[];
|
|
106
|
+
declare const eslintConfig: ({ convex, functionStyle, ignores, importPlugin, jsdoc, query, react, rules, sorting, storybook, testing, turbo, typescript, unicorn, }?: EslintConfigOptions, ...additionalConfigs: Linter.Config[]) => Linter.Config[];
|
|
101
107
|
|
|
102
108
|
interface PrettierConfigOptions extends Config {
|
|
103
109
|
cssOrderPlugin?: boolean;
|
|
@@ -131,4 +137,4 @@ interface PrettierConfigWithPlugins extends Config, SortJsonOptions, PluginOptio
|
|
|
131
137
|
*/
|
|
132
138
|
declare const prettierConfig: (options?: PrettierConfigOptions) => PrettierConfigWithPlugins;
|
|
133
139
|
|
|
134
|
-
export { type EslintConfigObject, type EslintConfigOptions, type EslintRuleConfig, type EslintSeverity, type FunctionStyle, type PrettierConfigOptions, type PrettierConfigWithPlugins, eslintConfig, prettierConfig };
|
|
140
|
+
export { type EslintConfigObject, type EslintConfigOptions, type EslintRuleConfig, type EslintSeverity, type FilenameCase, type FunctionStyle, type PrettierConfigOptions, type PrettierConfigWithPlugins, eslintConfig, prettierConfig };
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var isObject = (value) => {
|
|
|
9
9
|
// src/eslint/constants.ts
|
|
10
10
|
var configNames = {
|
|
11
11
|
base: "base",
|
|
12
|
+
convex: "convex",
|
|
12
13
|
disableTypeChecked: "UserConfig[1] > typescript-eslint/disable-type-checked",
|
|
13
14
|
ignores: "ignores",
|
|
14
15
|
import: "import",
|
|
@@ -29,6 +30,7 @@ var configNames = {
|
|
|
29
30
|
unicorn: "unicorn"
|
|
30
31
|
};
|
|
31
32
|
var pluginPrefixMap = /* @__PURE__ */ new Map([
|
|
33
|
+
["@convex-dev", configNames.convex],
|
|
32
34
|
["@tanstack/query", configNames.query],
|
|
33
35
|
["@typescript-eslint", configNames.typescript],
|
|
34
36
|
["import", configNames.import],
|
|
@@ -484,6 +486,32 @@ var baseEslintConfig = (functionStyle, typescript, customRules) => ({
|
|
|
484
486
|
}
|
|
485
487
|
});
|
|
486
488
|
|
|
489
|
+
// src/eslint/convex/config.ts
|
|
490
|
+
import { createRequire } from "module";
|
|
491
|
+
|
|
492
|
+
// src/eslint/convex/rules.ts
|
|
493
|
+
var convexRules = {
|
|
494
|
+
"@convex-dev/import-wrong-runtime": "warn",
|
|
495
|
+
"@convex-dev/no-args-without-validator": "warn",
|
|
496
|
+
"@convex-dev/no-missing-args-validator": "warn",
|
|
497
|
+
"@convex-dev/no-old-registered-function-syntax": "warn"
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// src/eslint/convex/config.ts
|
|
501
|
+
var require2 = createRequire(import.meta.url);
|
|
502
|
+
var convexPlugin = require2("@convex-dev/eslint-plugin");
|
|
503
|
+
var convexConfig = (customRules) => ({
|
|
504
|
+
files: ["**/convex/**/*.{ts,js}"],
|
|
505
|
+
name: configNames.convex,
|
|
506
|
+
plugins: {
|
|
507
|
+
"@convex-dev": convexPlugin
|
|
508
|
+
},
|
|
509
|
+
rules: {
|
|
510
|
+
...convexRules,
|
|
511
|
+
...customRules ?? {}
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
487
515
|
// src/eslint/ignores.ts
|
|
488
516
|
var ignoresConfig = ({
|
|
489
517
|
next = false,
|
|
@@ -1457,7 +1485,7 @@ var tseslintConfig = (tsconfigPath, customRules) => {
|
|
|
1457
1485
|
import unicorn from "eslint-plugin-unicorn";
|
|
1458
1486
|
|
|
1459
1487
|
// src/eslint/unicorn/rules.ts
|
|
1460
|
-
var rules = {
|
|
1488
|
+
var rules = (filenameCase = "kebabCase") => ({
|
|
1461
1489
|
/**
|
|
1462
1490
|
* Enforce better string content.
|
|
1463
1491
|
*
|
|
@@ -1478,7 +1506,7 @@ var rules = {
|
|
|
1478
1506
|
"unicorn/filename-case": [
|
|
1479
1507
|
"warn",
|
|
1480
1508
|
{
|
|
1481
|
-
case:
|
|
1509
|
+
case: filenameCase
|
|
1482
1510
|
}
|
|
1483
1511
|
],
|
|
1484
1512
|
/**
|
|
@@ -1530,16 +1558,19 @@ var rules = {
|
|
|
1530
1558
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/text-encoding-identifier-case.md
|
|
1531
1559
|
*/
|
|
1532
1560
|
"unicorn/text-encoding-identifier-case": "warn"
|
|
1533
|
-
};
|
|
1561
|
+
});
|
|
1534
1562
|
|
|
1535
1563
|
// src/eslint/unicorn/config.ts
|
|
1536
|
-
var unicornConfig = (
|
|
1564
|
+
var unicornConfig = ({
|
|
1565
|
+
customRules,
|
|
1566
|
+
filenameCase = "kebabCase"
|
|
1567
|
+
}) => ({
|
|
1537
1568
|
name: configNames.unicorn,
|
|
1538
1569
|
plugins: {
|
|
1539
1570
|
unicorn
|
|
1540
1571
|
},
|
|
1541
1572
|
rules: {
|
|
1542
|
-
...rules,
|
|
1573
|
+
...rules(filenameCase),
|
|
1543
1574
|
...customRules ?? {}
|
|
1544
1575
|
}
|
|
1545
1576
|
});
|
|
@@ -1553,6 +1584,7 @@ var defaultTestingConfig = {
|
|
|
1553
1584
|
itOrTest: "it"
|
|
1554
1585
|
};
|
|
1555
1586
|
var eslintConfig = ({
|
|
1587
|
+
convex = false,
|
|
1556
1588
|
functionStyle = "arrow",
|
|
1557
1589
|
ignores = [],
|
|
1558
1590
|
importPlugin = true,
|
|
@@ -1565,7 +1597,7 @@ var eslintConfig = ({
|
|
|
1565
1597
|
testing = defaultTestingConfig,
|
|
1566
1598
|
turbo: turbo2 = false,
|
|
1567
1599
|
typescript = true,
|
|
1568
|
-
unicorn: unicorn2 =
|
|
1600
|
+
unicorn: unicorn2 = { filenameCase: "kebabCase" }
|
|
1569
1601
|
} = {}, ...additionalConfigs) => {
|
|
1570
1602
|
const categorizedRules = rules2 === void 0 ? {} : processCustomRules(rules2);
|
|
1571
1603
|
const usingNextjs = isObject(react2) && react2.framework === "next";
|
|
@@ -1629,6 +1661,9 @@ var eslintConfig = ({
|
|
|
1629
1661
|
if (query) {
|
|
1630
1662
|
configs.push(queryConfig(categorizedRules[configNames.query]));
|
|
1631
1663
|
}
|
|
1664
|
+
if (convex) {
|
|
1665
|
+
configs.push(convexConfig(categorizedRules[configNames.convex]));
|
|
1666
|
+
}
|
|
1632
1667
|
if (testing !== false) {
|
|
1633
1668
|
const mergedTestingConfig = isObject(testing) ? { ...defaultTestingConfig, ...testing } : defaultTestingConfig;
|
|
1634
1669
|
const { filenamePattern, files, formattingRules, framework, itOrTest } = mergedTestingConfig;
|
|
@@ -1651,7 +1686,13 @@ var eslintConfig = ({
|
|
|
1651
1686
|
);
|
|
1652
1687
|
}
|
|
1653
1688
|
if (unicorn2) {
|
|
1654
|
-
|
|
1689
|
+
const filenameCase = isObject(unicorn2) ? unicorn2.filenameCase : void 0;
|
|
1690
|
+
configs.push(
|
|
1691
|
+
unicornConfig({
|
|
1692
|
+
customRules: categorizedRules[configNames.unicorn],
|
|
1693
|
+
filenameCase
|
|
1694
|
+
})
|
|
1695
|
+
);
|
|
1655
1696
|
}
|
|
1656
1697
|
if (functionStyle === "arrow") {
|
|
1657
1698
|
configs.push(
|