@ttsc/lint 0.12.3 → 0.12.4

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 (62) hide show
  1. package/lib/defaultFormat.d.ts +10 -11
  2. package/lib/defaultFormat.js +10 -11
  3. package/lib/defaultFormat.js.map +1 -1
  4. package/lib/index.js +10 -4
  5. package/lib/index.js.map +1 -1
  6. package/lib/structures/ITtscLintConfig.d.ts +2 -2
  7. package/lib/structures/ITtscLintFormatConfig.d.ts +53 -55
  8. package/lib/structures/ITtscLintPluginMeta.d.ts +9 -1
  9. package/lib/structures/TtscLintRule.d.ts +10 -1
  10. package/lib/structures/TtscLintRuleMap.d.ts +2 -2
  11. package/linthost/ast_helpers.go +17 -0
  12. package/linthost/compile.go +37 -0
  13. package/linthost/config.go +184 -35
  14. package/linthost/config_format.go +257 -244
  15. package/linthost/directives.go +72 -0
  16. package/linthost/dispatch.go +33 -33
  17. package/linthost/engine.go +4 -0
  18. package/linthost/eslint_runtime.go +31 -0
  19. package/linthost/fix.go +29 -0
  20. package/linthost/format.go +23 -0
  21. package/linthost/host.go +11 -0
  22. package/linthost/print_dispatch.go +7 -5
  23. package/linthost/print_doc.go +4 -0
  24. package/linthost/print_nodes_call.go +9 -0
  25. package/linthost/rules_arrays.go +5 -2
  26. package/linthost/rules_debugger.go +3 -2
  27. package/linthost/rules_dupes.go +7 -4
  28. package/linthost/rules_empty.go +3 -2
  29. package/linthost/rules_escape.go +15 -0
  30. package/linthost/rules_eval.go +3 -0
  31. package/linthost/rules_finally.go +11 -0
  32. package/linthost/rules_format_jsdoc.go +7 -0
  33. package/linthost/rules_format_print_width.go +3 -0
  34. package/linthost/rules_format_quotes.go +3 -0
  35. package/linthost/rules_format_sort_imports.go +4 -0
  36. package/linthost/rules_gap.go +20 -0
  37. package/linthost/rules_imports.go +5 -7
  38. package/linthost/rules_logic.go +11 -0
  39. package/linthost/rules_loops.go +4 -0
  40. package/linthost/rules_misc.go +4 -2
  41. package/linthost/rules_params.go +7 -11
  42. package/linthost/rules_problems.go +24 -1
  43. package/linthost/rules_promise.go +12 -0
  44. package/linthost/rules_protos.go +3 -2
  45. package/linthost/rules_self.go +6 -0
  46. package/linthost/rules_strings.go +10 -0
  47. package/linthost/rules_suggestions.go +14 -4
  48. package/linthost/rules_throw.go +2 -0
  49. package/linthost/rules_ts.go +13 -0
  50. package/linthost/rules_ts_extra.go +25 -8
  51. package/linthost/rules_var.go +14 -1
  52. package/package.json +3 -3
  53. package/plugin/main.go +4 -4
  54. package/rule/astutil/astutil.go +12 -0
  55. package/rule/rule.go +123 -123
  56. package/src/defaultFormat.ts +10 -11
  57. package/src/index.ts +16 -4
  58. package/src/structures/ITtscLintConfig.ts +2 -2
  59. package/src/structures/ITtscLintFormatConfig.ts +53 -55
  60. package/src/structures/ITtscLintPluginMeta.ts +9 -1
  61. package/src/structures/TtscLintRule.ts +10 -1
  62. package/src/structures/TtscLintRuleMap.ts +17 -18
@@ -4,10 +4,10 @@ import type { TtscLintSeverity } from "./TtscLintSeverity";
4
4
  * Prettier-style flat configuration for the `format/*` rules.
5
5
  *
6
6
  * The `format` block is the recommended way to enable formatting in
7
- * `@ttsc/lint`. Each key mirrors a Prettier option of the same name —
8
- * users coming from a `.prettierrc` can copy their config almost
9
- * verbatim. The block is opt-in by presence: a `lint.config.ts` with no
10
- * `format` field keeps every format rule off, exactly as before.
7
+ * `@ttsc/lint`. Each key mirrors a Prettier option of the same name — users
8
+ * coming from a `.prettierrc` can copy their config almost verbatim. The block
9
+ * is opt-in by presence: a `lint.config.ts` with no `format` field keeps every
10
+ * format rule off, exactly as before.
11
11
  *
12
12
  * Once present, the block configures a curated set of format rules at
13
13
  * Prettier-aligned defaults. `ttsc format` uses these rules to rewrite source.
@@ -19,37 +19,37 @@ import type { TtscLintSeverity } from "./TtscLintSeverity";
19
19
  * import type { ITtscLintConfig } from "@ttsc/lint";
20
20
  *
21
21
  * export default {
22
- * rules: { "no-var": "error" },
23
- * format: {
24
- * severity: "warning",
25
- * printWidth: 100,
26
- * singleQuote: true,
27
- * importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
28
- * },
22
+ * rules: { "no-var": "error" },
23
+ * format: {
24
+ * severity: "warning",
25
+ * printWidth: 100,
26
+ * singleQuote: true,
27
+ * importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
28
+ * },
29
29
  * } satisfies ITtscLintConfig;
30
30
  *
31
- * Deviations from Prettier:
32
- * - `endOfLine` is restricted to `"lf"` and `"crlf"`. Prettier's
33
- * `"cr"` and `"auto"` modes are intentionally unsupported — the
34
- * printer does not auto-detect terminators.
35
- * - Many Prettier knobs (`bracketSpacing`, `arrowParens`,
36
- * `quoteProps`, JSX-specific switches) are not yet implemented.
31
+ * Deviations from Prettier:
32
+ * - `endOfLine` is restricted to `"lf"` and `"crlf"`. Prettier's
33
+ * `"cr"` and `"auto"` modes are intentionally unsupported — the
34
+ * printer does not auto-detect terminators.
35
+ * - Many Prettier knobs (`bracketSpacing`, `arrowParens`,
36
+ * `quoteProps`, JSX-specific switches) are not yet implemented.
37
37
  *
38
- * Rule enablement matrix (when the `format` block is present):
38
+ * Rule enablement matrix (when the `format` block is present):
39
39
  *
40
- * - `format/semi` — always on. `semi: false` flips it to `prefer:
41
- * "never"`.
42
- * - `format/quotes` — always on. `singleQuote: true` flips to
43
- * `prefer: "single"`.
44
- * - `format/trailing-comma` — always on. `trailingComma: "none"`
45
- * disables the rule's edits without removing the surface.
46
- * - `format/print-width` — always on, driven by `printWidth`,
47
- * `tabWidth`, `useTabs`, `endOfLine`.
48
- * - `format/sort-imports` — opt-in. Setting `importOrder` enables it.
49
- * - `format/jsdoc` — opt-in. Setting `jsdoc` enables it.
40
+ * - `format/semi` — always on. `semi: false` flips it to `prefer:
41
+ * "never"`.
42
+ * - `format/quotes` — always on. `singleQuote: true` flips to
43
+ * `prefer: "single"`.
44
+ * - `format/trailing-comma` — always on. `trailingComma: "none"`
45
+ * disables the rule's edits without removing the surface.
46
+ * - `format/print-width` — always on, driven by `printWidth`,
47
+ * `tabWidth`, `useTabs`, `endOfLine`.
48
+ * - `format/sort-imports` — opt-in. Setting `importOrder` enables it.
49
+ * - `format/jsdoc` — opt-in. Setting `jsdoc` enables it.
50
50
  *
51
- * Format findings produced from this block are off by default. Set `severity`
52
- * only when a project intentionally wants check-time format diagnostics.
51
+ * Format findings produced from this block are off by default. Set `severity`
52
+ * only when a project intentionally wants check-time format diagnostics.
53
53
  */
54
54
  export interface ITtscLintFormatConfig {
55
55
  /**
@@ -64,33 +64,33 @@ export interface ITtscLintFormatConfig {
64
64
  severity?: TtscLintSeverity;
65
65
 
66
66
  /**
67
- * Insert trailing semicolons on ASI-terminated statements. Mirrors
68
- * Prettier's `semi`. `false` flips the rule to require *no*
69
- * trailing semicolon (rare; matches prettier's `semi: false`).
67
+ * Insert trailing semicolons on ASI-terminated statements. Mirrors Prettier's
68
+ * `semi`. `false` flips the rule to require _no_ trailing semicolon (rare;
69
+ * matches prettier's `semi: false`).
70
70
  *
71
71
  * @default true
72
72
  */
73
73
  semi?: boolean;
74
74
 
75
75
  /**
76
- * Prefer single-quoted strings. Mirrors Prettier's `singleQuote`.
77
- * `false` means double quotes (Prettier's default).
76
+ * Prefer single-quoted strings. Mirrors Prettier's `singleQuote`. `false`
77
+ * means double quotes (Prettier's default).
78
78
  *
79
79
  * @default false
80
80
  */
81
81
  singleQuote?: boolean;
82
82
 
83
83
  /**
84
- * Trailing-comma policy. Mirrors Prettier's `trailingComma`. The
85
- * `"none"` mode disables the rule's edits.
84
+ * Trailing-comma policy. Mirrors Prettier's `trailingComma`. The `"none"`
85
+ * mode disables the rule's edits.
86
86
  *
87
87
  * @default "all"
88
88
  */
89
89
  trailingComma?: "all" | "es5" | "none";
90
90
 
91
91
  /**
92
- * Maximum column width before broken-form layout is chosen.
93
- * Mirrors Prettier's `printWidth`.
92
+ * Maximum column width before broken-form layout is chosen. Mirrors
93
+ * Prettier's `printWidth`.
94
94
  *
95
95
  * @default 80
96
96
  */
@@ -111,20 +111,19 @@ export interface ITtscLintFormatConfig {
111
111
  useTabs?: boolean;
112
112
 
113
113
  /**
114
- * Line terminator the printer emits on reflow. `@ttsc/lint`
115
- * supports `"lf"` and `"crlf"`. Prettier's `"cr"` and `"auto"` are
116
- * intentionally unsupported because the printer does not
117
- * auto-detect line endings.
114
+ * Line terminator the printer emits on reflow. `@ttsc/lint` supports `"lf"`
115
+ * and `"crlf"`. Prettier's `"cr"` and `"auto"` are intentionally unsupported
116
+ * because the printer does not auto-detect line endings.
118
117
  *
119
118
  * @default "lf"
120
119
  */
121
120
  endOfLine?: "lf" | "crlf";
122
121
 
123
122
  /**
124
- * Group order for `format/sort-imports`. Setting this enables the
125
- * rule; mirrors `@trivago/prettier-plugin-sort-imports`'
126
- * `importOrder`. The `<THIRD_PARTY_MODULES>` literal is the
127
- * catch-all placeholder for specifiers that match no other group.
123
+ * Group order for `format/sort-imports`. Setting this enables the rule;
124
+ * mirrors `@trivago/prettier-plugin-sort-imports`' `importOrder`. The
125
+ * `<THIRD_PARTY_MODULES>` literal is the catch-all placeholder for specifiers
126
+ * that match no other group.
128
127
  */
129
128
  importOrder?: readonly ("<THIRD_PARTY_MODULES>" | (string & {}))[];
130
129
 
@@ -136,8 +135,7 @@ export interface ITtscLintFormatConfig {
136
135
  importOrderSeparation?: boolean;
137
136
 
138
137
  /**
139
- * Sort named import specifiers alphabetically within each
140
- * declaration.
138
+ * Sort named import specifiers alphabetically within each declaration.
141
139
  *
142
140
  * @default true
143
141
  */
@@ -151,13 +149,13 @@ export interface ITtscLintFormatConfig {
151
149
  importOrderCaseInsensitive?: boolean;
152
150
 
153
151
  /**
154
- * Enable `format/jsdoc`. Pass `true` to turn it on with built-in
155
- * defaults, or an object to customize:
152
+ * Enable `format/jsdoc`. Pass `true` to turn it on with built-in defaults, or
153
+ * an object to customize:
156
154
  *
157
- * - `tagSynonyms` — extra `from → to` rewrites layered on the
158
- * built-in synonym table.
159
- * - `sortTags` — sort JSDoc tags into canonical order (reserved;
160
- * today's MVP only rewrites tag names).
155
+ * - `tagSynonyms` — extra `from → to` rewrites layered on the built-in synonym
156
+ * table.
157
+ * - `sortTags` — sort JSDoc tags into canonical order (reserved; today's MVP
158
+ * only rewrites tag names).
161
159
  *
162
160
  * @default false (off)
163
161
  */
@@ -1,4 +1,12 @@
1
- /** Plugin-level metadata shared with the diagnostic surface. */
1
+ /**
2
+ * Plugin-level metadata exposed on `ITtscLintPlugin.meta`.
3
+ *
4
+ * All fields are optional. When `namespace` is absent, `@ttsc/lint` falls back
5
+ * to the key used in the tsconfig `plugins` map (or `lint.config.*` `plugins`
6
+ * object) as the rule-name prefix. `name` and `version` are purely
7
+ * informational — they appear in diagnostic messages and are not validated at
8
+ * build time.
9
+ */
2
10
  export interface ITtscLintPluginMeta {
3
11
  /** Plugin package name as published on npm. */
4
12
  name?: string;
@@ -1,9 +1,18 @@
1
1
  /**
2
- * Lint rule names understood by the `@ttsc/lint` native sidecar.
2
+ * Union of every built-in lint rule name understood by the `@ttsc/lint` native
3
+ * sidecar.
3
4
  *
4
5
  * These names intentionally mirror familiar ESLint / TypeScript-ESLint rule
5
6
  * names so a `compilerOptions.plugins[]` entry can configure native linting
6
7
  * without introducing a separate lint config file.
8
+ *
9
+ * The `format/*` members at the bottom of the union are applied by `ttsc
10
+ * format`; their severity also controls whether `ttsc check` surfaces
11
+ * unformatted code as a diagnostic.
12
+ *
13
+ * This type is used as the key constraint in `TtscLintRuleMap` for rules that
14
+ * carry no per-rule options. Rules with typed option objects are additionally
15
+ * listed in `ITtscLintRuleOptionsMap`.
7
16
  */
8
17
  export type TtscLintRule =
9
18
  | "adjacent-overload-signatures"
@@ -11,8 +11,8 @@ import type { TtscLintSeverity } from "./TtscLintSeverity";
11
11
  * `[severity, options]`, with the options type picked per rule key.
12
12
  * - Every other built-in rule accepts `severity` or `[severity]`.
13
13
  * - Namespaced contributor plugin rules accept `severity`, `[severity]`, or
14
- * `[severity, unknownOptions]` because the host type surface no longer
15
- * knows contributor rule schemas.
14
+ * `[severity, unknownOptions]` because the host type surface no longer knows
15
+ * contributor rule schemas.
16
16
  *
17
17
  * Splitting the two halves (instead of folding them into one mapped type with a
18
18
  * conditional value) keeps TypeScript's contextual typing intact inside the
@@ -38,19 +38,18 @@ import type { TtscLintSeverity } from "./TtscLintSeverity";
38
38
  * splits each negative case into its own const to keep every branch
39
39
  * load-bearing.
40
40
  */
41
- export type TtscLintRuleMap =
42
- {
43
- [K in keyof ITtscLintRuleOptionsMap]?:
44
- | TtscLintSeverity
45
- | readonly [TtscLintSeverity]
46
- | readonly [TtscLintSeverity, ITtscLintRuleOptionsMap[K]];
47
- } & {
48
- [K in Exclude<TtscLintRule, keyof ITtscLintRuleOptionsMap>]?:
49
- | TtscLintSeverity
50
- | readonly [TtscLintSeverity];
51
- } & {
52
- [K in `${string}/${string}`]?:
53
- | TtscLintSeverity
54
- | readonly [TtscLintSeverity]
55
- | readonly [TtscLintSeverity, unknown];
56
- };
41
+ export type TtscLintRuleMap = {
42
+ [K in keyof ITtscLintRuleOptionsMap]?:
43
+ | TtscLintSeverity
44
+ | readonly [TtscLintSeverity]
45
+ | readonly [TtscLintSeverity, ITtscLintRuleOptionsMap[K]];
46
+ } & {
47
+ [K in Exclude<TtscLintRule, keyof ITtscLintRuleOptionsMap>]?:
48
+ | TtscLintSeverity
49
+ | readonly [TtscLintSeverity];
50
+ } & {
51
+ [K in `${string}/${string}`]?:
52
+ | TtscLintSeverity
53
+ | readonly [TtscLintSeverity]
54
+ | readonly [TtscLintSeverity, unknown];
55
+ };