@ttsc/lint 0.10.2 → 0.11.0-dev.20260518

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 (113) hide show
  1. package/README.md +172 -33
  2. package/lib/defineConfig.d.ts +55 -0
  3. package/lib/defineConfig.js +39 -0
  4. package/lib/defineConfig.js.map +1 -0
  5. package/lib/index.d.ts +25 -1
  6. package/lib/index.js +622 -2
  7. package/lib/index.js.map +1 -1
  8. package/lib/structures/ITtscLintPlugin.d.ts +53 -0
  9. package/lib/structures/ITtscLintPlugin.js +3 -0
  10. package/lib/structures/ITtscLintPlugin.js.map +1 -0
  11. package/lib/structures/ITtscLintPluginConfig.d.ts +82 -5
  12. package/lib/structures/ITtscLintPluginMeta.d.ts +12 -0
  13. package/lib/structures/ITtscLintPluginMeta.js +3 -0
  14. package/lib/structures/ITtscLintPluginMeta.js.map +1 -0
  15. package/lib/structures/PluginRuleNames.d.ts +14 -0
  16. package/lib/structures/PluginRuleNames.js +3 -0
  17. package/lib/structures/PluginRuleNames.js.map +1 -0
  18. package/lib/structures/TtscLintConfig.d.ts +24 -8
  19. package/lib/structures/TtscLintConfigEntry.d.ts +39 -0
  20. package/lib/structures/TtscLintConfigEntry.js +3 -0
  21. package/lib/structures/TtscLintConfigEntry.js.map +1 -0
  22. package/lib/structures/TtscLintFormatConfig.d.ts +154 -0
  23. package/lib/structures/TtscLintFormatConfig.js +3 -0
  24. package/lib/structures/TtscLintFormatConfig.js.map +1 -0
  25. package/lib/structures/TtscLintPlugins.d.ts +9 -0
  26. package/lib/structures/TtscLintPlugins.js +3 -0
  27. package/lib/structures/TtscLintPlugins.js.map +1 -0
  28. package/lib/structures/TtscLintRule.d.ts +1 -1
  29. package/lib/structures/TtscLintRuleEntry.d.ts +22 -0
  30. package/lib/structures/TtscLintRuleEntry.js +3 -0
  31. package/lib/structures/TtscLintRuleEntry.js.map +1 -0
  32. package/lib/structures/TtscLintRuleMap.d.ts +44 -0
  33. package/lib/structures/TtscLintRuleMap.js +3 -0
  34. package/lib/structures/TtscLintRuleMap.js.map +1 -0
  35. package/lib/structures/TtscLintRuleOptions.d.ts +149 -0
  36. package/lib/structures/TtscLintRuleOptions.js +3 -0
  37. package/lib/structures/TtscLintRuleOptions.js.map +1 -0
  38. package/lib/structures/defaultFormat.d.ts +31 -0
  39. package/lib/structures/defaultFormat.js +35 -0
  40. package/lib/structures/defaultFormat.js.map +1 -0
  41. package/lib/structures/index.d.ts +10 -0
  42. package/lib/structures/index.js +10 -0
  43. package/lib/structures/index.js.map +1 -1
  44. package/{plugin → linthost}/ast_helpers.go +92 -1
  45. package/{plugin → linthost}/compile.go +1 -1
  46. package/{plugin → linthost}/config.go +583 -66
  47. package/linthost/config_format.go +360 -0
  48. package/linthost/contrib_adapter.go +134 -0
  49. package/{plugin → linthost}/directives.go +1 -1
  50. package/linthost/dispatch.go +65 -0
  51. package/{plugin → linthost}/engine.go +156 -11
  52. package/{plugin → linthost}/eslint_runtime.go +76 -2
  53. package/linthost/fix.go +249 -0
  54. package/linthost/format.go +107 -0
  55. package/{plugin → linthost}/host.go +1 -1
  56. package/linthost/print_dispatch.go +118 -0
  57. package/linthost/print_doc.go +168 -0
  58. package/linthost/print_engine.go +343 -0
  59. package/linthost/print_nodes_array.go +46 -0
  60. package/linthost/print_nodes_call.go +180 -0
  61. package/linthost/print_nodes_imports.go +171 -0
  62. package/linthost/print_nodes_list.go +64 -0
  63. package/linthost/print_nodes_object.go +51 -0
  64. package/{plugin → linthost}/rules_arrays.go +1 -1
  65. package/{plugin → linthost}/rules_console.go +1 -1
  66. package/{plugin → linthost}/rules_debugger.go +1 -1
  67. package/{plugin → linthost}/rules_dupes.go +1 -1
  68. package/{plugin → linthost}/rules_empty.go +1 -1
  69. package/linthost/rules_escape.go +238 -0
  70. package/{plugin → linthost}/rules_eval.go +1 -1
  71. package/{plugin → linthost}/rules_finally.go +1 -1
  72. package/linthost/rules_format_jsdoc.go +230 -0
  73. package/linthost/rules_format_print_width.go +332 -0
  74. package/linthost/rules_format_quotes.go +219 -0
  75. package/linthost/rules_format_semi.go +190 -0
  76. package/linthost/rules_format_sort_imports.go +462 -0
  77. package/linthost/rules_format_trailing_comma.go +460 -0
  78. package/{plugin → linthost}/rules_gap.go +101 -6
  79. package/linthost/rules_imports.go +101 -0
  80. package/{plugin → linthost}/rules_logic.go +55 -3
  81. package/{plugin → linthost}/rules_loops.go +1 -1
  82. package/{plugin → linthost}/rules_misc.go +1 -1
  83. package/linthost/rules_params.go +64 -0
  84. package/{plugin → linthost}/rules_problems.go +10 -2
  85. package/linthost/rules_promise.go +111 -0
  86. package/{plugin → linthost}/rules_protos.go +1 -1
  87. package/{plugin → linthost}/rules_self.go +1 -1
  88. package/{plugin → linthost}/rules_strings.go +1 -1
  89. package/{plugin → linthost}/rules_suggestions.go +51 -9
  90. package/{plugin → linthost}/rules_throw.go +1 -1
  91. package/{plugin → linthost}/rules_ts.go +12 -2
  92. package/{plugin → linthost}/rules_ts_extra.go +90 -4
  93. package/{plugin → linthost}/rules_var.go +36 -5
  94. package/package.json +8 -6
  95. package/plugin/main.go +14 -27
  96. package/rule/astutil/astutil.go +148 -0
  97. package/rule/rule.go +291 -0
  98. package/src/defineConfig.ts +69 -0
  99. package/src/index.ts +807 -3
  100. package/src/structures/ITtscLintPlugin.ts +56 -0
  101. package/src/structures/ITtscLintPluginConfig.ts +86 -5
  102. package/src/structures/ITtscLintPluginMeta.ts +14 -0
  103. package/src/structures/PluginRuleNames.ts +19 -0
  104. package/src/structures/TtscLintConfig.ts +27 -8
  105. package/src/structures/TtscLintConfigEntry.ts +50 -0
  106. package/src/structures/TtscLintFormatConfig.ts +169 -0
  107. package/src/structures/TtscLintPlugins.ts +10 -0
  108. package/src/structures/TtscLintRule.ts +14 -1
  109. package/src/structures/TtscLintRuleEntry.ts +28 -0
  110. package/src/structures/TtscLintRuleMap.ts +52 -0
  111. package/src/structures/TtscLintRuleOptions.ts +162 -0
  112. package/src/structures/defaultFormat.ts +33 -0
  113. package/src/structures/index.ts +10 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Per-rule option shapes used by `TtscLintRuleEntry` to type the second tuple
3
+ * slot.
4
+ *
5
+ * Each entry here maps a rule name to its option struct. Rule names that do not
6
+ * appear in this interface accept severity-only configuration (a `[severity]`
7
+ * tuple is _also_ allowed for them, with an empty options blob).
8
+ *
9
+ * The shapes are designed to match the analogous prettier / ESLint options
10
+ * where the rule absorbs an existing tool's behavior:
11
+ *
12
+ * - `format/semi` mirrors prettier `semi`.
13
+ * - `format/quotes` mirrors prettier `singleQuote` (inverted).
14
+ * - `format/trailing-comma` mirrors prettier `trailingComma`.
15
+ * - `format/sort-imports` mirrors `@trivago/prettier-plugin-sort-imports`
16
+ * (`importOrder`, `importOrderSeparation`, `importOrderSortSpecifiers`,
17
+ * `importOrderCaseInsensitive`).
18
+ * - `format/jsdoc` mirrors `prettier-plugin-jsdoc` (`tagSynonyms` layered onto
19
+ * the built-in synonym table, `sortTags` reserved for a future pass).
20
+ *
21
+ * Future option additions go here so the TypeScript autocomplete updates in one
22
+ * place. The Go side reads these as `json.RawMessage` and each rule decodes
23
+ * into its own struct.
24
+ */
25
+ export namespace TtscLintRuleOptions {
26
+ /** `format/semi` options. */
27
+ export interface Semi {
28
+ /**
29
+ * Whether trailing semicolons must be present on ASI statements.
30
+ *
31
+ * @default "always"
32
+ */
33
+ prefer?: "always" | "never";
34
+ }
35
+
36
+ /** `format/quotes` options. */
37
+ export interface Quotes {
38
+ /**
39
+ * Quote style for string literals. Template literals are always preserved
40
+ * regardless of this setting.
41
+ *
42
+ * @default "double"
43
+ */
44
+ prefer?: "double" | "single";
45
+ }
46
+
47
+ /** `format/trailing-comma` options. */
48
+ export interface TrailingComma {
49
+ /**
50
+ * Which multi-line lists receive a trailing comma. `"all"` matches
51
+ * prettier's modern default; `"es5"` skips function calls and type
52
+ * parameter lists; `"none"` disables the rule entirely.
53
+ *
54
+ * @default "all"
55
+ */
56
+ mode?: "all" | "es5" | "none";
57
+ }
58
+
59
+ /** `format/sort-imports` options. */
60
+ export interface SortImports {
61
+ /**
62
+ * Ordered list of regex strings (or the `<THIRD_PARTY_MODULES>`
63
+ * placeholder) defining the group order. Imports matching the first pattern
64
+ * land in group 0, the second in group 1, and so on. The placeholder
65
+ * absorbs any specifier that does not match another pattern. Mirrors
66
+ * trivago's `importOrder` semantics.
67
+ */
68
+ importOrder?: readonly string[];
69
+
70
+ /**
71
+ * Insert a blank line between groups.
72
+ *
73
+ * @default true
74
+ */
75
+ importOrderSeparation?: boolean;
76
+
77
+ /**
78
+ * Sort named import specifiers alphabetically within each declaration.
79
+ *
80
+ * @default true
81
+ */
82
+ importOrderSortSpecifiers?: boolean;
83
+
84
+ /**
85
+ * Treat `A` and `a` as equivalent when comparing module specifiers and
86
+ * specifier names. Mirrors trivago's `importOrderCaseInsensitive`.
87
+ *
88
+ * @default false
89
+ */
90
+ importOrderCaseInsensitive?: boolean;
91
+ }
92
+
93
+ /** `format/print-width` options. */
94
+ export interface PrintWidth {
95
+ /**
96
+ * Maximum column width before broken-form layout is chosen. Mirrors
97
+ * prettier's `printWidth`.
98
+ *
99
+ * @default 80
100
+ */
101
+ printWidth?: number;
102
+
103
+ /**
104
+ * Indentation increment in columns. Mirrors prettier's `tabWidth`.
105
+ *
106
+ * @default 2
107
+ */
108
+ tabWidth?: number;
109
+
110
+ /**
111
+ * Emit indentation as tab characters rather than spaces. Mirrors
112
+ * prettier's `useTabs`. Continuation alignment beyond the tab
113
+ * boundary still falls back to spaces, matching dprint's
114
+ * "indent with tabs, align with spaces" convention.
115
+ *
116
+ * @default false
117
+ */
118
+ useTabs?: boolean;
119
+
120
+ /**
121
+ * Line-terminator emitted on every newline the printer inserts.
122
+ * Mirrors prettier's `endOfLine` `"lf"` and `"crlf"` modes.
123
+ *
124
+ * @default "lf"
125
+ */
126
+ endOfLine?: "lf" | "crlf";
127
+ }
128
+
129
+ /** `format/jsdoc` options. */
130
+ export interface JSDoc {
131
+ /**
132
+ * Extra `from → to` tag rewrites layered on top of the built-in synonym
133
+ * table (`@return → @returns`, `@arg → @param`, etc.). User-supplied
134
+ * entries win on key collision, so a `{"return": "RETURN"}` entry overrides
135
+ * the built-in default for `@return`.
136
+ *
137
+ * @default {} (use built-in table unchanged)
138
+ */
139
+ tagSynonyms?: Record<string, string>;
140
+
141
+ /**
142
+ * Sort JSDoc tag blocks into the canonical order (`@description`, `@param`,
143
+ * `@returns`, …).
144
+ *
145
+ * @default false (deferred; MVP only normalizes tag names)
146
+ */
147
+ sortTags?: boolean;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Index from rule name to its option struct. Used by `TtscLintRuleEntry<R>` to
153
+ * produce precise tuple types per rule.
154
+ */
155
+ export interface TtscLintRuleOptionsMap {
156
+ "format/semi": TtscLintRuleOptions.Semi;
157
+ "format/quotes": TtscLintRuleOptions.Quotes;
158
+ "format/trailing-comma": TtscLintRuleOptions.TrailingComma;
159
+ "format/sort-imports": TtscLintRuleOptions.SortImports;
160
+ "format/jsdoc": TtscLintRuleOptions.JSDoc;
161
+ "format/print-width": TtscLintRuleOptions.PrintWidth;
162
+ }
@@ -0,0 +1,33 @@
1
+ import type { TtscLintFormatConfig } from "./TtscLintFormatConfig";
2
+
3
+ /**
4
+ * Documented defaults for the `format` block's *always-on* rules
5
+ * (`format/semi`, `format/quotes`, `format/trailing-comma`,
6
+ * `format/print-width`).
7
+ *
8
+ * Exported so users can spread defaults next to overrides:
9
+ *
10
+ * import { defaultFormat, type TtscLintConfig } from "@ttsc/lint";
11
+ *
12
+ * export default {
13
+ * format: { ...defaultFormat, printWidth: 100 },
14
+ * } satisfies TtscLintConfig;
15
+ *
16
+ * The values mirror Prettier 1:1 except for the documented
17
+ * `endOfLine` narrowing (no `"cr"` / `"auto"`).
18
+ *
19
+ * Notably absent: `importOrder` and `jsdoc`. `format/sort-imports`
20
+ * and `format/jsdoc` are opt-in by setting their corresponding
21
+ * fields; the defaults const only seeds the rules that turn on
22
+ * unconditionally with a non-empty `format` block.
23
+ */
24
+ export const defaultFormat = Object.freeze({
25
+ severity: "warning",
26
+ semi: true,
27
+ singleQuote: false,
28
+ trailingComma: "all",
29
+ printWidth: 80,
30
+ tabWidth: 2,
31
+ useTabs: false,
32
+ endOfLine: "lf",
33
+ } satisfies TtscLintFormatConfig);
@@ -1,4 +1,14 @@
1
+ export * from "./defaultFormat";
2
+ export * from "./ITtscLintPlugin";
1
3
  export * from "./ITtscLintPluginConfig";
4
+ export * from "./ITtscLintPluginMeta";
5
+ export * from "./PluginRuleNames";
2
6
  export * from "./TtscLintConfig";
7
+ export * from "./TtscLintConfigEntry";
8
+ export * from "./TtscLintFormatConfig";
9
+ export * from "./TtscLintPlugins";
3
10
  export * from "./TtscLintRule";
11
+ export * from "./TtscLintRuleEntry";
12
+ export * from "./TtscLintRuleMap";
13
+ export * from "./TtscLintRuleOptions";
4
14
  export * from "./TtscLintSeverity";