@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.
- package/lib/defaultFormat.d.ts +10 -11
- package/lib/defaultFormat.js +10 -11
- package/lib/defaultFormat.js.map +1 -1
- package/lib/index.js +10 -4
- package/lib/index.js.map +1 -1
- package/lib/structures/ITtscLintConfig.d.ts +2 -2
- package/lib/structures/ITtscLintFormatConfig.d.ts +53 -55
- package/lib/structures/ITtscLintPluginMeta.d.ts +9 -1
- package/lib/structures/TtscLintRule.d.ts +10 -1
- package/lib/structures/TtscLintRuleMap.d.ts +2 -2
- package/linthost/ast_helpers.go +17 -0
- package/linthost/compile.go +37 -0
- package/linthost/config.go +184 -35
- package/linthost/config_format.go +257 -244
- package/linthost/directives.go +72 -0
- package/linthost/dispatch.go +33 -33
- package/linthost/engine.go +4 -0
- package/linthost/eslint_runtime.go +31 -0
- package/linthost/fix.go +29 -0
- package/linthost/format.go +23 -0
- package/linthost/host.go +11 -0
- package/linthost/print_dispatch.go +7 -5
- package/linthost/print_doc.go +4 -0
- package/linthost/print_nodes_call.go +9 -0
- package/linthost/rules_arrays.go +5 -2
- package/linthost/rules_debugger.go +3 -2
- package/linthost/rules_dupes.go +7 -4
- package/linthost/rules_empty.go +3 -2
- package/linthost/rules_escape.go +15 -0
- package/linthost/rules_eval.go +3 -0
- package/linthost/rules_finally.go +11 -0
- package/linthost/rules_format_jsdoc.go +7 -0
- package/linthost/rules_format_print_width.go +3 -0
- package/linthost/rules_format_quotes.go +3 -0
- package/linthost/rules_format_sort_imports.go +4 -0
- package/linthost/rules_gap.go +20 -0
- package/linthost/rules_imports.go +5 -7
- package/linthost/rules_logic.go +11 -0
- package/linthost/rules_loops.go +4 -0
- package/linthost/rules_misc.go +4 -2
- package/linthost/rules_params.go +7 -11
- package/linthost/rules_problems.go +24 -1
- package/linthost/rules_promise.go +12 -0
- package/linthost/rules_protos.go +3 -2
- package/linthost/rules_self.go +6 -0
- package/linthost/rules_strings.go +10 -0
- package/linthost/rules_suggestions.go +14 -4
- package/linthost/rules_throw.go +2 -0
- package/linthost/rules_ts.go +13 -0
- package/linthost/rules_ts_extra.go +25 -8
- package/linthost/rules_var.go +14 -1
- package/package.json +3 -3
- package/plugin/main.go +4 -4
- package/rule/astutil/astutil.go +12 -0
- package/rule/rule.go +123 -123
- package/src/defaultFormat.ts +10 -11
- package/src/index.ts +16 -4
- package/src/structures/ITtscLintConfig.ts +2 -2
- package/src/structures/ITtscLintFormatConfig.ts +53 -55
- package/src/structures/ITtscLintPluginMeta.ts +9 -1
- package/src/structures/TtscLintRule.ts +10 -1
- 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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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
|
-
*
|
|
38
|
+
* Rule enablement matrix (when the `format` block is present):
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
-
*
|
|
52
|
-
*
|
|
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
|
-
*
|
|
69
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
116
|
-
*
|
|
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
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
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
|
-
*
|
|
152
|
+
* Enable `format/jsdoc`. Pass `true` to turn it on with built-in defaults, or
|
|
153
|
+
* an object to customize:
|
|
156
154
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
};
|