eslint-config-agent 3.0.4 → 3.1.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 (39) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +592 -26
  3. package/configs/base-plugins.js +32 -0
  4. package/configs/config-files.js +19 -3
  5. package/configs/examples.js +12 -1
  6. package/configs/javascript.js +12 -4
  7. package/configs/length-rule-scope.js +27 -0
  8. package/configs/overrides.js +3 -14
  9. package/configs/test-files.js +40 -1
  10. package/configs/tsx.js +10 -0
  11. package/configs/typescript.js +44 -2
  12. package/exports/ddd.d.ts +10 -0
  13. package/exports/ddd.js +1 -3
  14. package/exports/incremental.d.ts +11 -0
  15. package/exports/incremental.js +39 -0
  16. package/exports/recommended-incremental.d.ts +11 -0
  17. package/exports/recommended-incremental.js +46 -0
  18. package/exports/recommended.d.ts +14 -0
  19. package/exports/recommended.js +110 -0
  20. package/exports/to-warnings.d.ts +20 -0
  21. package/exports/to-warnings.js +41 -0
  22. package/index.d.ts +18 -0
  23. package/index.js +883 -7
  24. package/package.json +46 -17
  25. package/plugins/index.js +6 -0
  26. package/rules/index.js +20 -22
  27. package/rules/no-inline-union-types/index.js +8 -6
  28. package/rules/no-process-env-properties/index.js +4 -4
  29. package/rules/no-record-literal-types/index.js +3 -3
  30. package/rules/plugin/import/index.js +41 -0
  31. package/rules/plugin/index.js +0 -2
  32. package/rules/plugin/n/index.js +16 -2
  33. package/rules/plugin/n/no-process-env/index.js +4 -4
  34. package/rules/plugin/react/index.js +150 -2
  35. package/rules/plugin/typescript-eslint/index.js +406 -0
  36. package/rules/require-spec-file-tsx/README.md +57 -0
  37. package/rules/require-spec-file-tsx/helpers.js +93 -0
  38. package/rules/require-spec-file-tsx/index.js +109 -0
  39. package/rules/plugin/jsx-a11y/index.js +0 -3
@@ -0,0 +1,20 @@
1
+ import type { Linter } from 'eslint'
2
+
3
+ /**
4
+ * Downgrade every error-level rule in a flat-config block to a warning.
5
+ *
6
+ * The single source of truth used internally by the
7
+ * `eslint-config-agent/incremental` and
8
+ * `eslint-config-agent/recommended-incremental` presets. Map it over a
9
+ * flat-config array to warn-level the shared ruleset while composing your own
10
+ * config — for example to keep a handful of rules as hard errors from day one
11
+ * without copy-pasting the downgrade logic by hand.
12
+ *
13
+ * Blocks without a `rules` object (for example `ignores`-only blocks) are
14
+ * returned untouched. Both shorthand (`'error'`) and tuple (`['error',
15
+ * options]`) rule values are handled, and `off`/`warn` rules are left exactly
16
+ * as they are.
17
+ * @param block A flat-config block.
18
+ * @returns The block with error-level rules downgraded to warnings.
19
+ */
20
+ export declare const toWarnings: (block: Linter.Config) => Linter.Config
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Shared severity-downgrade helper for the warn-level adoption presets.
3
+ *
4
+ * Both `eslint-config-agent/incremental` and
5
+ * `eslint-config-agent/recommended-incremental` need to take a built flat-config
6
+ * array and rewrite every error-level rule to a warning so `eslint` exits `0`
7
+ * while still reporting the full backlog. That logic lived inline in
8
+ * `incremental.js`; extracting it here keeps a single source of truth so the two
9
+ * presets cannot drift apart.
10
+ */
11
+
12
+ const WARN = 'warn'
13
+ const ERROR_LEVELS = new Set(['error', 2])
14
+
15
+ const downgrade = severity => (ERROR_LEVELS.has(severity) ? WARN : severity)
16
+
17
+ /**
18
+ * Downgrade every error-level rule in a flat-config block to a warning.
19
+ *
20
+ * Blocks without a `rules` object (for example `ignores`-only blocks) are
21
+ * returned untouched. Both shorthand (`'error'`) and tuple
22
+ * (`['error', options]`) rule values are handled, and `off`/`warn` rules are
23
+ * left exactly as they are.
24
+ * @param block A flat-config block.
25
+ * @returns The block with error-level rules downgraded to warnings.
26
+ */
27
+ export const toWarnings = block => {
28
+ if (block.rules === undefined) {
29
+ return block
30
+ }
31
+
32
+ const rules = Object.fromEntries(
33
+ Object.entries(block.rules).map(([name, value]) =>
34
+ Array.isArray(value)
35
+ ? [name, [downgrade(value[0]), ...value.slice(1)]]
36
+ : [name, downgrade(value)]
37
+ )
38
+ )
39
+
40
+ return { ...block, rules }
41
+ }
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { Linter } from 'eslint'
2
+
3
+ /**
4
+ * The default `eslint-config-agent` flat config: the full strict ruleset for
5
+ * TypeScript, React, and Preact projects.
6
+ *
7
+ * It is an array of flat-config blocks, so spread it into (or export it
8
+ * directly as) your `eslint.config.*`:
9
+ *
10
+ * ```ts
11
+ * import config from 'eslint-config-agent'
12
+ *
13
+ * export default config
14
+ * ```
15
+ */
16
+ declare const config: Linter.Config[]
17
+
18
+ export default config