@ttsc/lint 0.10.2 → 0.11.0-dev.20260517
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 +172 -33
- package/lib/defineConfig.d.ts +55 -0
- package/lib/defineConfig.js +39 -0
- package/lib/defineConfig.js.map +1 -0
- package/lib/index.d.ts +25 -1
- package/lib/index.js +622 -2
- package/lib/index.js.map +1 -1
- package/lib/structures/ITtscLintPlugin.d.ts +53 -0
- package/lib/structures/ITtscLintPlugin.js +3 -0
- package/lib/structures/ITtscLintPlugin.js.map +1 -0
- package/lib/structures/ITtscLintPluginConfig.d.ts +82 -5
- package/lib/structures/ITtscLintPluginMeta.d.ts +12 -0
- package/lib/structures/ITtscLintPluginMeta.js +3 -0
- package/lib/structures/ITtscLintPluginMeta.js.map +1 -0
- package/lib/structures/PluginRuleNames.d.ts +14 -0
- package/lib/structures/PluginRuleNames.js +3 -0
- package/lib/structures/PluginRuleNames.js.map +1 -0
- package/lib/structures/TtscLintConfig.d.ts +24 -8
- package/lib/structures/TtscLintConfigEntry.d.ts +39 -0
- package/lib/structures/TtscLintConfigEntry.js +3 -0
- package/lib/structures/TtscLintConfigEntry.js.map +1 -0
- package/lib/structures/TtscLintFormatConfig.d.ts +154 -0
- package/lib/structures/TtscLintFormatConfig.js +3 -0
- package/lib/structures/TtscLintFormatConfig.js.map +1 -0
- package/lib/structures/TtscLintPlugins.d.ts +9 -0
- package/lib/structures/TtscLintPlugins.js +3 -0
- package/lib/structures/TtscLintPlugins.js.map +1 -0
- package/lib/structures/TtscLintRule.d.ts +1 -1
- package/lib/structures/TtscLintRuleEntry.d.ts +22 -0
- package/lib/structures/TtscLintRuleEntry.js +3 -0
- package/lib/structures/TtscLintRuleEntry.js.map +1 -0
- package/lib/structures/TtscLintRuleMap.d.ts +44 -0
- package/lib/structures/TtscLintRuleMap.js +3 -0
- package/lib/structures/TtscLintRuleMap.js.map +1 -0
- package/lib/structures/TtscLintRuleOptions.d.ts +149 -0
- package/lib/structures/TtscLintRuleOptions.js +3 -0
- package/lib/structures/TtscLintRuleOptions.js.map +1 -0
- package/lib/structures/defaultFormat.d.ts +31 -0
- package/lib/structures/defaultFormat.js +35 -0
- package/lib/structures/defaultFormat.js.map +1 -0
- package/lib/structures/index.d.ts +10 -0
- package/lib/structures/index.js +10 -0
- package/lib/structures/index.js.map +1 -1
- package/{plugin → linthost}/ast_helpers.go +92 -1
- package/{plugin → linthost}/compile.go +1 -1
- package/{plugin → linthost}/config.go +583 -66
- package/linthost/config_format.go +360 -0
- package/linthost/contrib_adapter.go +134 -0
- package/{plugin → linthost}/directives.go +1 -1
- package/linthost/dispatch.go +62 -0
- package/{plugin → linthost}/engine.go +156 -11
- package/{plugin → linthost}/eslint_runtime.go +76 -2
- package/linthost/fix.go +249 -0
- package/linthost/format.go +107 -0
- package/{plugin → linthost}/host.go +1 -1
- package/linthost/print_dispatch.go +118 -0
- package/linthost/print_doc.go +168 -0
- package/linthost/print_engine.go +343 -0
- package/linthost/print_nodes_array.go +46 -0
- package/linthost/print_nodes_call.go +180 -0
- package/linthost/print_nodes_imports.go +171 -0
- package/linthost/print_nodes_list.go +64 -0
- package/linthost/print_nodes_object.go +51 -0
- package/{plugin → linthost}/rules_arrays.go +1 -1
- package/{plugin → linthost}/rules_console.go +1 -1
- package/{plugin → linthost}/rules_debugger.go +1 -1
- package/{plugin → linthost}/rules_dupes.go +1 -1
- package/{plugin → linthost}/rules_empty.go +1 -1
- package/linthost/rules_escape.go +238 -0
- package/{plugin → linthost}/rules_eval.go +1 -1
- package/{plugin → linthost}/rules_finally.go +1 -1
- package/linthost/rules_format_jsdoc.go +230 -0
- package/linthost/rules_format_print_width.go +332 -0
- package/linthost/rules_format_quotes.go +219 -0
- package/linthost/rules_format_semi.go +190 -0
- package/linthost/rules_format_sort_imports.go +462 -0
- package/linthost/rules_format_trailing_comma.go +460 -0
- package/{plugin → linthost}/rules_gap.go +101 -6
- package/linthost/rules_imports.go +101 -0
- package/{plugin → linthost}/rules_logic.go +55 -3
- package/{plugin → linthost}/rules_loops.go +1 -1
- package/{plugin → linthost}/rules_misc.go +1 -1
- package/linthost/rules_params.go +64 -0
- package/{plugin → linthost}/rules_problems.go +10 -2
- package/linthost/rules_promise.go +111 -0
- package/{plugin → linthost}/rules_protos.go +1 -1
- package/{plugin → linthost}/rules_self.go +1 -1
- package/{plugin → linthost}/rules_strings.go +1 -1
- package/{plugin → linthost}/rules_suggestions.go +51 -9
- package/{plugin → linthost}/rules_throw.go +1 -1
- package/{plugin → linthost}/rules_ts.go +12 -2
- package/{plugin → linthost}/rules_ts_extra.go +90 -4
- package/{plugin → linthost}/rules_var.go +36 -5
- package/package.json +8 -6
- package/plugin/main.go +14 -27
- package/rule/astutil/astutil.go +148 -0
- package/rule/rule.go +291 -0
- package/src/defineConfig.ts +69 -0
- package/src/index.ts +807 -3
- package/src/structures/ITtscLintPlugin.ts +56 -0
- package/src/structures/ITtscLintPluginConfig.ts +86 -5
- package/src/structures/ITtscLintPluginMeta.ts +14 -0
- package/src/structures/PluginRuleNames.ts +19 -0
- package/src/structures/TtscLintConfig.ts +27 -8
- package/src/structures/TtscLintConfigEntry.ts +50 -0
- package/src/structures/TtscLintFormatConfig.ts +169 -0
- package/src/structures/TtscLintPlugins.ts +10 -0
- package/src/structures/TtscLintRule.ts +14 -1
- package/src/structures/TtscLintRuleEntry.ts +28 -0
- package/src/structures/TtscLintRuleMap.ts +52 -0
- package/src/structures/TtscLintRuleOptions.ts +162 -0
- package/src/structures/defaultFormat.ts +33 -0
- 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);
|
package/src/structures/index.ts
CHANGED
|
@@ -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";
|