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.
Files changed (64) hide show
  1. package/README.md +5 -0
  2. package/dist/index.d.ts +11 -5
  3. package/dist/index.js +48 -7
  4. package/dist/index.js.map +1 -1
  5. package/package.json +8 -5
  6. package/src/eslint/base/README.md +186 -0
  7. package/src/eslint/base/config.ts +37 -0
  8. package/src/eslint/base/rules.ts +444 -0
  9. package/src/eslint/base/types.ts +20 -0
  10. package/src/eslint/constants.ts +52 -0
  11. package/src/eslint/convex/README.md +30 -0
  12. package/src/eslint/convex/config.ts +34 -0
  13. package/src/eslint/convex/rules.ts +8 -0
  14. package/src/eslint/convex/types.ts +8 -0
  15. package/src/eslint/ignores.ts +31 -0
  16. package/src/eslint/import/README.md +397 -0
  17. package/src/eslint/import/config.ts +48 -0
  18. package/src/eslint/import/rules.ts +81 -0
  19. package/src/eslint/index.ts +259 -0
  20. package/src/eslint/jsdoc/README.md +399 -0
  21. package/src/eslint/jsdoc/config.ts +29 -0
  22. package/src/eslint/jsdoc/rules.ts +81 -0
  23. package/src/eslint/jsdoc/types.ts +56 -0
  24. package/src/eslint/nextjs/config.ts +25 -0
  25. package/src/eslint/nextjs/rules.ts +25 -0
  26. package/src/eslint/nextjs/types.ts +27 -0
  27. package/src/eslint/perfectionist/README.md +454 -0
  28. package/src/eslint/perfectionist/config.ts +25 -0
  29. package/src/eslint/perfectionist/rules.ts +39 -0
  30. package/src/eslint/prefer-arrow-function/config.ts +33 -0
  31. package/src/eslint/prefer-arrow-function/types.ts +13 -0
  32. package/src/eslint/process-custom-rules.ts +72 -0
  33. package/src/eslint/query/README.md +254 -0
  34. package/src/eslint/query/config.ts +27 -0
  35. package/src/eslint/query/rules.ts +11 -0
  36. package/src/eslint/query/types.ts +11 -0
  37. package/src/eslint/react/README.md +416 -0
  38. package/src/eslint/react/config.ts +65 -0
  39. package/src/eslint/react/rules.ts +188 -0
  40. package/src/eslint/react/types.ts +26 -0
  41. package/src/eslint/react-refresh/config.ts +28 -0
  42. package/src/eslint/react-refresh/rules.ts +48 -0
  43. package/src/eslint/storybook/README.md +424 -0
  44. package/src/eslint/storybook/config.ts +57 -0
  45. package/src/eslint/testing/README.md +436 -0
  46. package/src/eslint/testing/config.ts +90 -0
  47. package/src/eslint/testing/jest-rules.ts +47 -0
  48. package/src/eslint/testing/vitest-rules.ts +42 -0
  49. package/src/eslint/turbo/README.md +380 -0
  50. package/src/eslint/turbo/config.ts +26 -0
  51. package/src/eslint/turbo/types.ts +7 -0
  52. package/src/eslint/types.ts +29 -0
  53. package/src/eslint/typescript/README.md +229 -0
  54. package/src/eslint/typescript/config.ts +48 -0
  55. package/src/eslint/typescript/rules.ts +137 -0
  56. package/src/eslint/typescript/types.ts +35 -0
  57. package/src/eslint/unicorn/README.md +497 -0
  58. package/src/eslint/unicorn/config.ts +36 -0
  59. package/src/eslint/unicorn/rules.ts +86 -0
  60. package/src/index.ts +3 -0
  61. package/src/modules.d.ts +5 -0
  62. package/src/prettier/README.md +413 -0
  63. package/src/prettier/index.ts +110 -0
  64. package/src/utils/is-type.ts +60 -0
@@ -0,0 +1,444 @@
1
+ import type { FunctionStyle } from "../types.js";
2
+ import type { BaseRules } from "./types.js";
3
+
4
+ /**
5
+ * Generates the base set of ESLint rules with configurable function style enforcement.
6
+ *
7
+ * @param functionStyle - Controls how functions should be written. Can be:
8
+ * - "off": Disables function style enforcement
9
+ * - "arrow": Enforces arrow function expressions
10
+ * - "declaration": Enforces function declarations
11
+ * - "expression": Enforces function expressions
12
+ * @param typescript - Whether TypeScript is being used in the project. When true, some rules are adjusted to be more TypeScript-friendly.
13
+ * @returns An object containing ESLint rule configurations
14
+ */
15
+ export const baseEslintRules = (
16
+ functionStyle: "off" | FunctionStyle,
17
+ typescript: boolean,
18
+ ): BaseRules => ({
19
+ ...(!typescript ?
20
+ {
21
+ "no-unused-expressions": "warn",
22
+ "no-unused-vars": "warn",
23
+ }
24
+ : {}),
25
+ /**
26
+ * Require return statements in array methods callbacks.
27
+ *
28
+ * 🚫 Not fixable -https://eslint.org/docs/rules/array-callback-return
29
+ */
30
+ "array-callback-return": [
31
+ "warn",
32
+ { allowImplicit: true, checkForEach: true },
33
+ ],
34
+ /**
35
+ * Treat `var` statements as if they were block scoped.
36
+ *
37
+ * 🚫 Not fixable - https://eslint.org/docs/rules/block-scoped-var
38
+ */
39
+ "block-scoped-var": "warn",
40
+ /**
41
+ * Require camel case names.
42
+ *
43
+ * 🚫 Not fixable - https://eslint.org/docs/rules/camelcase
44
+ */
45
+ camelcase: [
46
+ "warn",
47
+ {
48
+ allow: ["^UNSAFE_"],
49
+ ignoreDestructuring: false,
50
+ ignoreImports: true,
51
+ properties: "never",
52
+ },
53
+ ],
54
+ /**
55
+ * Require curly braces for multiline blocks.
56
+ *
57
+ * 🔧 Fixable - https://eslint.org/docs/rules/curly
58
+ */
59
+ curly: ["warn", "multi-line"],
60
+ /**
61
+ * Require default clauses in switch statements to be last (if used).
62
+ *
63
+ * 🚫 Not fixable - https://eslint.org/docs/rules/default-case-last
64
+ */
65
+ "default-case-last": "warn",
66
+ /**
67
+ * Require triple equals (`===` and `!==`).
68
+
69
+ * 🔧 Fixable - https://eslint.org/docs/rules/eqeqeq
70
+ */
71
+ eqeqeq: "warn",
72
+ "for-direction": "warn",
73
+ /**
74
+ * Require function expressions to have a name.
75
+ *
76
+ * 🚫 Not fixable - https://eslint.org/docs/rules/func-names
77
+ */
78
+ "func-names": ["warn", "as-needed"],
79
+ // if arrow function, we use the prefer-arrow-functions plugin
80
+ ...(functionStyle === "off" ? { "func-style": "off" }
81
+ : functionStyle === "arrow" ?
82
+ { "func-style": "off" } // When arrow, func-style is off and prefer-arrow-functions is used instead
83
+ : { "func-style": ["warn", functionStyle, { allowArrowFunctions: true }] }),
84
+ /**
85
+ * Require grouped accessor pairs in object literals and classes.
86
+ *
87
+ * 🚫 Not fixable - https://eslint.org/docs/rules/grouped-accessor-pairs
88
+ */
89
+ "grouped-accessor-pairs": "warn",
90
+ /**
91
+ * Require a capital letter for constructors.
92
+ *
93
+ * 🚫 Not fixable - https://eslint.org/docs/rules/new-cap
94
+ */
95
+ "new-cap": ["warn", { capIsNew: false }],
96
+ /**
97
+ * Disallow use of `alert()`.
98
+ *
99
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-alert
100
+ */
101
+ "no-alert": "warn",
102
+ "no-async-promise-executor": "warn",
103
+ /**
104
+ * Disallow use of bitwise operators.
105
+ *
106
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-bitwise
107
+ */
108
+ "no-bitwise": "warn",
109
+ /**
110
+ * Disallow use of `caller`/`callee`.
111
+ *
112
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-caller
113
+ */
114
+ "no-caller": "warn",
115
+ "no-case-declarations": "warn",
116
+ "no-compare-neg-zero": "warn",
117
+ "no-cond-assign": "warn",
118
+ /**
119
+ * Disallow the use of console.
120
+ *
121
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
122
+ */
123
+ "no-console": ["warn", { allow: ["info", "warn", "error"] }],
124
+ /**
125
+ * Disallow expressions where the operation doesn't affect the value.
126
+ *
127
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
128
+ */
129
+ "no-constant-binary-expression": "warn",
130
+ "no-constant-condition": "warn",
131
+ /**
132
+ * Disallow returning value in constructor.
133
+ *
134
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-constructor-return
135
+ */
136
+ "no-constructor-return": "warn",
137
+ "no-control-regex": "warn",
138
+ "no-debugger": "warn",
139
+ "no-delete-var": "warn",
140
+ "no-dupe-else-if": "warn",
141
+ "no-duplicate-case": "warn",
142
+ /**
143
+ * Disallow using an `else` if the `if` block contains a return.
144
+ *
145
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-else-return
146
+ */
147
+ "no-else-return": "warn",
148
+ "no-empty": "warn",
149
+ "no-empty-character-class": "warn",
150
+ "no-empty-pattern": "warn",
151
+ "no-empty-static-block": "warn",
152
+ /**
153
+ * Disallow `eval()`.
154
+ *
155
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-eval
156
+ */
157
+ "no-eval": "warn",
158
+ "no-ex-assign": "warn",
159
+ /**
160
+ * Disallow extending native objects.
161
+ *
162
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-extend-native
163
+ */
164
+ "no-extend-native": "warn",
165
+ /**
166
+ * Disallow unnecessary function binding.
167
+ *
168
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-extra-bind
169
+ */
170
+ "no-extra-bind": "warn",
171
+ "no-extra-boolean-cast": "warn",
172
+ /**
173
+ * Disallow unnecessary labels.
174
+ *
175
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-extra-label
176
+ */
177
+ "no-extra-label": "warn",
178
+ "no-fallthrough": "warn",
179
+ "no-global-assign": "warn",
180
+ /**
181
+ * Make people convert types explicitly e.g. `Boolean(foo)` instead of `!!foo`.
182
+ *
183
+ * 🔧 Partially Fixable - https://eslint.org/docs/rules/no-implicit-coercion
184
+ */
185
+ "no-implicit-coercion": "warn",
186
+ "no-invalid-regexp": "warn",
187
+ "no-irregular-whitespace": "warn",
188
+ /**
189
+ * Disallow usage of `__iterator__` property.
190
+ *
191
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-iterator
192
+ */
193
+ "no-iterator": "warn",
194
+ /**
195
+ * Disallow labels that share a name with a variable.
196
+ *
197
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-label-var
198
+ */
199
+ "no-label-var": "warn",
200
+ /**
201
+ * Disallow use of labels for anything other than loops and switches.
202
+ *
203
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-labels
204
+ */
205
+ "no-labels": ["warn"],
206
+ /**
207
+ * Disallow unnecessary nested blocks.
208
+ *
209
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-lone-blocks
210
+ */
211
+ "no-lone-blocks": "warn",
212
+ /**
213
+ * Disallow if as the only statement in an else block.
214
+ *
215
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-lonely-if
216
+ */
217
+ "no-lonely-if": "warn",
218
+ "no-loss-of-precision": "warn",
219
+ "no-misleading-character-class": "warn",
220
+ /**
221
+ * Disallow use of chained assignment expressions.
222
+ *
223
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-multi-assign
224
+ */
225
+ "no-multi-assign": ["warn"],
226
+ /**
227
+ * Disallow `new` for side effects.
228
+ *
229
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-new
230
+ */
231
+ "no-new": "warn",
232
+ /**
233
+ * Disallow function constructors.
234
+ *
235
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-new-func
236
+ */
237
+ "no-new-func": "warn",
238
+ /**
239
+ * Disallow primitive wrapper instances, such as `new String('foo')`.
240
+ *
241
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-new-wrappers
242
+ */
243
+ "no-new-wrappers": "warn",
244
+ "no-nonoctal-decimal-escape": "warn",
245
+ "no-octal": "warn",
246
+ /**
247
+ * Disallow use of octal escape sequences in string literals.
248
+ *
249
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-octal-escape
250
+ */
251
+ "no-octal-escape": "warn",
252
+ /**
253
+ * Disallow reassignment of function parameters.
254
+ *
255
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-param-reassign
256
+ */
257
+ "no-param-reassign": "warn",
258
+ /**
259
+ * Disallow returning values from Promise executor functions.
260
+ *
261
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-promise-executor-return
262
+ */
263
+ "no-promise-executor-return": "warn",
264
+ /**
265
+ * Disallow usage of the deprecated `__proto__` property.
266
+ *
267
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-proto
268
+ */
269
+ "no-proto": "warn",
270
+ "no-prototype-builtins": "warn",
271
+ "no-regex-spaces": "warn",
272
+ /**
273
+ * Disallow assignment in `return` statement.
274
+ *
275
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-return-assign
276
+ */
277
+ "no-return-assign": "warn",
278
+ /**
279
+ * Disallow use of `javascript:` urls.
280
+ *
281
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-script-url
282
+ */
283
+ "no-script-url": "warn",
284
+ "no-self-assign": "warn",
285
+ /**
286
+ * Disallow comparisons where both sides are exactly the same.
287
+ *
288
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-self-compare
289
+ */
290
+ "no-self-compare": "warn",
291
+ /**
292
+ * Disallow use of comma operator.
293
+ *
294
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-sequences
295
+ */
296
+ "no-sequences": "warn",
297
+ "no-shadow-restricted-names": "warn",
298
+ "no-sparse-arrays": "warn",
299
+ /**
300
+ * Disallow template literal placeholder syntax in regular strings, as
301
+ * these are likely errors.
302
+ *
303
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-template-curly-in-string
304
+ */
305
+ "no-template-curly-in-string": "warn",
306
+ /**
307
+ * Disallow initializing variables to `undefined`.
308
+ *
309
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-undef-init
310
+ */
311
+ "no-undef-init": "warn",
312
+ "no-unexpected-multiline": "warn",
313
+ /**
314
+ * Disallow ternary operators when simpler alternatives exist.
315
+ *
316
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-unneeded-ternary
317
+ */
318
+ "no-unneeded-ternary": "warn",
319
+ /**
320
+ * Disallow loops with a body that allows only one iteration.
321
+ *
322
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-unreachable-loop
323
+ */
324
+ "no-unreachable-loop": "warn",
325
+ "no-unsafe-finally": "warn",
326
+ "no-unsafe-optional-chaining": "warn",
327
+ "no-unused-labels": "warn",
328
+ "no-unused-private-class-members": "warn",
329
+ "no-useless-backreference": "warn",
330
+ /**
331
+ * Disallow unnecessary `.call()` and `.apply()`.
332
+ *
333
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-useless-call
334
+ */
335
+ "no-useless-call": "warn",
336
+ "no-useless-catch": "warn",
337
+ /**
338
+ * Disallow useless computed property keys.
339
+ *
340
+ * � Fixable - https://eslint.org/docs/rules/no-useless-computed-key
341
+ */
342
+ "no-useless-computed-key": "warn",
343
+ /**
344
+ * Disallow unnecessary concatenation of strings.
345
+ *
346
+ * � Not fixable - https://eslint.org/docs/rules/no-useless-concat
347
+ */
348
+ "no-useless-concat": "warn",
349
+ "no-useless-escape": "warn",
350
+ /**
351
+ * Disallow renaming import, export, and destructured assignments to the
352
+ * same name.
353
+ *
354
+ * � Fixable - https://eslint.org/docs/rules/no-useless-rename
355
+ */
356
+ "no-useless-rename": "warn",
357
+ /**
358
+ * Disallow redundant return statements.
359
+ *
360
+ * � Fixable - https://eslint.org/docs/rules/no-useless-return
361
+ */
362
+ "no-useless-return": "warn",
363
+ /**
364
+ * Require `let` or `const` instead of `var`.
365
+ * ts transpiles let/const to var, so no need for vars any more
366
+ *
367
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-var
368
+ */
369
+ "no-var": "warn",
370
+ "no-with": "warn",
371
+ /**
372
+ * Require object literal shorthand syntax.
373
+ *
374
+ * 🔧 Fixable - https://eslint.org/docs/rules/object-shorthand
375
+ */
376
+ "object-shorthand": "warn",
377
+ /**
378
+ * Require default to `const` instead of `let`.
379
+ * ts provides better types with const
380
+ *
381
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-const
382
+ */
383
+ "prefer-const": "warn",
384
+ /**
385
+ * Require using named capture groups in regular expressions.
386
+ *
387
+ * � Not fixable - https://eslint.org/docs/rules/prefer-named-capture-group
388
+ */
389
+ "prefer-named-capture-group": "warn",
390
+ /**
391
+ * Disallow parseInt() in favor of binary, octal, and hexadecimal literals.
392
+ *
393
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-numeric-literals
394
+ */
395
+ "prefer-numeric-literals": "warn",
396
+ /**
397
+ * Require use of an object spread over Object.assign.
398
+ *
399
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-object-spread
400
+ */
401
+ "prefer-object-spread": "warn",
402
+ /**
403
+ * Disallow use of the RegExp constructor in favor of regular expression
404
+ * literals.
405
+ *
406
+ * � Not fixable - https://eslint.org/docs/rules/prefer-regex-literals
407
+ */
408
+ "prefer-regex-literals": "warn",
409
+ /**
410
+ * Require using rest parameters instead of `arguments`.
411
+ * ts provides better types with rest args over arguments
412
+ *
413
+ * 🚫 Not fixable - https://eslint.org/docs/rules/prefer-rest-params
414
+ */
415
+ "prefer-rest-params": "warn",
416
+ /**
417
+ * Require using spread syntax instead of `.apply()`.
418
+ * ts transpiles spread to apply, so no need for manual apply
419
+ *
420
+ * 🚫 Not fixable - https://eslint.org/docs/rules/prefer-spread
421
+ */
422
+ "prefer-spread": "warn",
423
+ /**
424
+ * Require using template literals instead of string concatenation.
425
+ *
426
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-template
427
+ */
428
+ "prefer-template": "warn",
429
+ "require-yield": "warn",
430
+ /**
431
+ * Require a `Symbol` description.
432
+ *
433
+ * 🚫 Not fixable - https://eslint.org/docs/rules/symbol-description
434
+ */
435
+ "symbol-description": "warn",
436
+ "use-isnan": "warn",
437
+ "valid-typeof": "warn",
438
+ /**
439
+ * Disallow "Yoda conditions", ensuring the comparison.
440
+ *
441
+ * 🔧 Fixable - https://eslint.org/docs/rules/yoda
442
+ */
443
+ yoda: "warn",
444
+ });
@@ -0,0 +1,20 @@
1
+ import type { EslintRuleConfig } from "../types.js";
2
+
3
+ export type BaseRules = Record<string, EslintRuleConfig> & {
4
+ camelcase?: EslintRuleConfig<{
5
+ allow?: string[];
6
+ ignoreDestructuring?: boolean;
7
+ ignoreGlobals?: boolean;
8
+ ignoreImports?: boolean;
9
+ properties?: "always" | "never";
10
+ }>;
11
+ "func-style"?: EslintRuleConfig<
12
+ "declaration" | "expression",
13
+ {
14
+ allowArrowFunctions?: boolean;
15
+ overrides?: {
16
+ namedExports?: "declaration" | "expression" | "ignore";
17
+ };
18
+ }
19
+ >;
20
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Debug names for ESLint configuration objects.
3
+ * These names help identify different configuration sections in ESLint's debug output
4
+ * and error messages, making it easier to track which rules come from which config.
5
+ */
6
+ export const configNames = {
7
+ base: "base",
8
+ convex: "convex",
9
+ disableTypeChecked: "UserConfig[1] > typescript-eslint/disable-type-checked",
10
+ ignores: "ignores",
11
+ import: "import",
12
+ jsdoc: "jsdoc",
13
+ markdown: "markdown",
14
+ nextjs: "nextjs",
15
+ perfectionist: "perfectionist",
16
+ preferArrowFunction: "prefer-arrow-function",
17
+ query: "@tanstack/query",
18
+ react: "react",
19
+ reactRefresh: "react-refresh",
20
+ storybook: "storybook:stories",
21
+ storybookConfig: "storybook:config",
22
+ testing: "testing",
23
+ turbo: "turbo",
24
+ typescript: "tseslint",
25
+ typescriptTesting: "tseslint-testing",
26
+ unicorn: "unicorn",
27
+ } as const;
28
+
29
+ export type ConfigName = (typeof configNames)[keyof typeof configNames];
30
+
31
+ /**
32
+ * Maps plugin prefixes to their corresponding config names.
33
+ * This is the single source of truth for categorizing rules by plugin.
34
+ */
35
+ export const pluginPrefixMap = new Map<string, ConfigName>([
36
+ ["@convex-dev", configNames.convex],
37
+ ["@tanstack/query", configNames.query],
38
+ ["@typescript-eslint", configNames.typescript],
39
+ ["import", configNames.import],
40
+ ["import-x", configNames.import],
41
+ ["jest", configNames.testing],
42
+ ["jsdoc", configNames.jsdoc],
43
+ ["nextjs", configNames.nextjs],
44
+ ["perfectionist", configNames.perfectionist],
45
+ ["react", configNames.react],
46
+ ["react-hooks", configNames.react],
47
+ ["react-refresh", configNames.reactRefresh],
48
+ ["storybook", configNames.storybook],
49
+ ["turbo", configNames.turbo],
50
+ ["unicorn", configNames.unicorn],
51
+ ["vitest", configNames.testing],
52
+ ]);
@@ -0,0 +1,30 @@
1
+ # Convex Configuration
2
+
3
+ ESLint rules for Convex backend development.
4
+
5
+ [← Back to main README](../../../README.md)
6
+
7
+ ## Overview
8
+
9
+ Convex configuration is **disabled by default** and provides rules from @convex-dev/eslint-plugin, which is Convex's own ESLint plugin.
10
+
11
+ > **Note:** This plugin is currently in **alpha** and is subject to change.
12
+
13
+ ## Quick Start
14
+
15
+ ```js
16
+ import { eslintConfig } from "js-style-kit";
17
+
18
+ export default eslintConfig({
19
+ convex: true, // Enable Convex rules
20
+ });
21
+ ```
22
+
23
+ ## File Scope
24
+
25
+ Convex rules apply only to files in your `convex` directory.
26
+
27
+ ## Learn More
28
+
29
+ - [Convex ESLint Plugin](https://docs.convex.dev/eslint) - Official documentation
30
+ - [Main README](../../../README.md)
@@ -0,0 +1,34 @@
1
+ import type { ESLint } from "eslint";
2
+
3
+ import { createRequire } from "node:module";
4
+
5
+ import type { EslintConfigObject, EslintRuleConfig } from "../types.js";
6
+
7
+ import { configNames } from "../constants.js";
8
+ import { convexRules } from "./rules.js";
9
+
10
+ // TODO: Replace with ESM import once @convex-dev/eslint-plugin stabilizes
11
+ // The alpha version (0.0.1-alpha.4) doesn't have proper ESM exports yet
12
+ const require = createRequire(import.meta.url);
13
+
14
+ const convexPlugin = require("@convex-dev/eslint-plugin");
15
+
16
+ /**
17
+ * Creates an ESLint configuration for Convex.
18
+ *
19
+ * @param customRules - Optional object containing custom rules to override or add to the Convex configuration.
20
+ * @returns ESLint configuration object for Convex
21
+ */
22
+ export const convexConfig = (
23
+ customRules?: Record<string, EslintRuleConfig>,
24
+ ): EslintConfigObject => ({
25
+ files: ["**/convex/**/*.{ts,js}"],
26
+ name: configNames.convex,
27
+ plugins: {
28
+ "@convex-dev": convexPlugin as unknown as ESLint.Plugin,
29
+ },
30
+ rules: {
31
+ ...convexRules,
32
+ ...(customRules ?? {}),
33
+ },
34
+ });
@@ -0,0 +1,8 @@
1
+ import type { ConvexRules } from "./types.js";
2
+
3
+ export const convexRules: ConvexRules = {
4
+ "@convex-dev/import-wrong-runtime": "warn",
5
+ "@convex-dev/no-args-without-validator": "warn",
6
+ "@convex-dev/no-missing-args-validator": "warn",
7
+ "@convex-dev/no-old-registered-function-syntax": "warn",
8
+ };
@@ -0,0 +1,8 @@
1
+ import type { EslintRuleConfig } from "../types.js";
2
+
3
+ export interface ConvexRules {
4
+ "@convex-dev/import-wrong-runtime": EslintRuleConfig;
5
+ "@convex-dev/no-args-without-validator": EslintRuleConfig;
6
+ "@convex-dev/no-missing-args-validator": EslintRuleConfig;
7
+ "@convex-dev/no-old-registered-function-syntax": EslintRuleConfig;
8
+ }
@@ -0,0 +1,31 @@
1
+ import type { Linter } from "eslint";
2
+
3
+ import { configNames } from "./constants.js";
4
+
5
+ /**
6
+ * Creates an ESLint configuration for file and directory ignores.
7
+ * By default, ignores node_modules, dist directories, and .git directories.
8
+ *
9
+ * @param options - Object with options to control the ignores configuration
10
+ * @param options.userIgnores - Additional glob patterns to ignore in ESLint checks
11
+ * @param options.next - Whether to include .next directory in ignores
12
+ * @param options.storybook - Whether to include .storybook directory in ignores
13
+ * @returns ESLint configuration object with ignore patterns
14
+ */
15
+ export const ignoresConfig = ({
16
+ next = false,
17
+ storybook = false,
18
+ userIgnores = [],
19
+ }: {
20
+ next?: boolean;
21
+ storybook?: boolean;
22
+ userIgnores?: string[];
23
+ } = {}): Linter.Config => ({
24
+ ignores: [
25
+ "**/dist/",
26
+ ...(next ? [".next"] : []),
27
+ ...(storybook ? ["!.storybook"] : []),
28
+ ...userIgnores,
29
+ ],
30
+ name: configNames.ignores,
31
+ });