@inthedark/dxlint 0.1.3 → 0.1.5
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/bin/dxlint-linux-x64 +0 -0
- package/bin/dxlint-win32-x64.exe +0 -0
- package/package.json +1 -1
- package/std/ts/modules.dx +14 -2
- package/std/ts/names.dx +10 -1
- package/std/ts/structure/padding.dx +2 -0
- package/std/ts/style/comments.dx +34 -1
package/bin/dxlint-linux-x64
CHANGED
|
Binary file
|
package/bin/dxlint-win32-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/std/ts/modules.dx
CHANGED
|
@@ -37,7 +37,19 @@ import .ts/comments
|
|
|
37
37
|
star_excludes ["default", "="]
|
|
38
38
|
search order
|
|
39
39
|
globals {
|
|
40
|
-
|
|
40
|
+
# TypeScript 7 ships them in its platform package instead.
|
|
41
|
+
libraries [
|
|
42
|
+
"{{package_dir}}/typescript/lib/lib.{{name:lower}}.d.ts",
|
|
43
|
+
"{{package_dir}}/@typescript/typescript-win32-x64/lib/lib.{{name:lower}}.d.ts",
|
|
44
|
+
"{{package_dir}}/@typescript/typescript-win32-arm64/lib/lib.{{name:lower}}.d.ts",
|
|
45
|
+
"{{package_dir}}/@typescript/typescript-linux-x64/lib/lib.{{name:lower}}.d.ts",
|
|
46
|
+
"{{package_dir}}/@typescript/typescript-linux-arm64/lib/lib.{{name:lower}}.d.ts",
|
|
47
|
+
"{{package_dir}}/@typescript/typescript-linux-arm/lib/lib.{{name:lower}}.d.ts",
|
|
48
|
+
"{{package_dir}}/@typescript/typescript-darwin-x64/lib/lib.{{name:lower}}.d.ts",
|
|
49
|
+
"{{package_dir}}/@typescript/typescript-darwin-arm64/lib/lib.{{name:lower}}.d.ts",
|
|
50
|
+
]
|
|
51
|
+
# `/// <reference lib="x" />` asks for `lib:x`, wherever the release keeps it.
|
|
52
|
+
library_prefix "lib:"
|
|
41
53
|
library_option "lib"
|
|
42
54
|
default_libraries ["es2023", "dom"]
|
|
43
55
|
types_option "types"
|
|
@@ -256,7 +268,7 @@ in ts_reference_path let ts_module_path_reference {
|
|
|
256
268
|
|| re_test(path, /^[A-Za-z]:\//) then path else "./{path}"
|
|
257
269
|
}
|
|
258
270
|
in ts_reference_types let ts_module_types_reference "@types/{ts_module_reference}"
|
|
259
|
-
in ts_reference_lib let ts_module_lib_reference "
|
|
271
|
+
in ts_reference_lib let ts_module_lib_reference "lib:{ts_module_reference}"
|
|
260
272
|
in ts_reference_path {
|
|
261
273
|
globals all value, type, query from module ts_module_path_reference
|
|
262
274
|
}
|
package/std/ts/names.dx
CHANGED
|
@@ -85,6 +85,11 @@ in ts_rest { targets argument }
|
|
|
85
85
|
in ts_function, ts_arrow, ts_method, ts_function_type, ts_method_signature, ts_call_signature {
|
|
86
86
|
declares value, query parameter in nearest function hoisted
|
|
87
87
|
}
|
|
88
|
+
# Other files see these bodies only by entering them: the declared return
|
|
89
|
+
# type (or a constructor's or setter's role) stands for what they do, so an
|
|
90
|
+
# edit inside one concerns only the files that stepped in.
|
|
91
|
+
in ts_function, ts_arrow { opaque body when return_type != null }
|
|
92
|
+
in ts_method { opaque body when return_type != null || kind == "constructor" || kind == "set" }
|
|
88
93
|
in ts_parameter { targets name }
|
|
89
94
|
in ts_function, ts_method { declares value, query "arguments" in nearest function hoisted }
|
|
90
95
|
# A declaration's name lands in the enclosing block; an expression's only
|
|
@@ -142,9 +147,13 @@ in ts_identifier {
|
|
|
142
147
|
# `[key: string]: T` names nothing.
|
|
143
148
|
|| is ts_parameter.name && parent is ts_index_signature.parameter) {
|
|
144
149
|
when ts_name_outside_method != null { resolves value outside ts_name_outside_method }
|
|
145
|
-
when ts_name_outside_method == null { resolves value }
|
|
150
|
+
when ts_name_outside_method == null && !ts_name_type_key { resolves value }
|
|
151
|
+
# A computed key inside type syntax reads like `typeof`: type-only
|
|
152
|
+
# imports count.
|
|
153
|
+
when ts_name_outside_method == null && ts_name_type_key { resolves query }
|
|
146
154
|
}
|
|
147
155
|
}
|
|
156
|
+
in ts_identifier let ts_name_type_key name_type_access && containing(ts_computed_key) != null
|
|
148
157
|
in ts_type_reference { resolves type name }
|
|
149
158
|
# `export { x }` uses `x`; `export { x } from "m"` does not.
|
|
150
159
|
in ts_export_specifier { when parent.from == null { resolves value, type local } }
|
|
@@ -220,7 +220,9 @@ fn structure_padding_finding(source, pair, comments) = {
|
|
|
220
220
|
|
|
221
221
|
in structure_padding_owner rule es-padding-line-between-statements {
|
|
222
222
|
option options { blankLine: "any" | "always" | "never"; prev: string | { selector: string; lineMode?: "any" | "singleline" | "multiline" } | (string | { selector: string; lineMode?: "any" | "singleline" | "multiline" })[]; next: string | { selector: string; lineMode?: "any" | "singleline" | "multiline" } | (string | { selector: string; lineMode?: "any" | "singleline" | "multiline" })[] }[] = [] "ordered statement padding policies"
|
|
223
|
+
option typescriptBodies boolean = true "also pad namespace bodies, interfaces and type literals (false: only the statement lists ESLint core checks)"
|
|
223
224
|
when any(options, policy => policy.blankLine != "any")
|
|
225
|
+
when typescriptBodies || !(node is (ts_interface, ts_type_literal) || node is ts_block && parent is ts_namespace)
|
|
224
226
|
let prepared_options map(options, config => {
|
|
225
227
|
blankLine: config.blankLine,
|
|
226
228
|
prev: padding_prepare_selectors(config.prev),
|
package/std/ts/style/comments.dx
CHANGED
|
@@ -32,15 +32,48 @@ in ts_comment rule es-ban-linter-comment {
|
|
|
32
32
|
{ name: "eslint", pattern: /^(?:\/\/|\/\*)\s*eslint-(?:disable|enable)(?:-(?:line|next-line))?(?:\s|\*\/|$)/ },
|
|
33
33
|
{ name: "eslint", pattern: /^\/\*\s*(?:eslint|eslint-env|globals?|exported)(?:\s|\*\/)/ }
|
|
34
34
|
] "linter comments to report: a name for the message and a pattern over the whole comment"
|
|
35
|
+
option renames { [rule: string]: string } = {} "dxlint names for ESLint rule ids in converted suppressions, over the built-in mapping"
|
|
35
36
|
let format first(filter(formats, format => re_test(text, format.pattern)))
|
|
36
37
|
when format != null
|
|
37
38
|
let content re_replace(text, /^\/\/|^\/\*|\*\/$/, "")
|
|
38
39
|
let normalised re_replace(content, /^\s+|\s+$/, "")
|
|
39
|
-
|
|
40
|
+
# ESLint suppressions become dxlint's own; other linter comments go.
|
|
41
|
+
let suppression eslint_suppression(source, node, normalised, renames)
|
|
42
|
+
let edit if suppression == "keep" then null
|
|
43
|
+
else if suppression != null then { start: offset, end: end_offset, text: suppression } else linter_comment_edit(source, node)
|
|
40
44
|
warn "{format.name} comment detected: \"{if node is ts_line_comment then '// ' normalised else '/* ' normalised ' */'}\""
|
|
41
45
|
fix at edit if edit != null as edit.text
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
# `eslint-disable-next-line a, b -- why` as `dxlint-ignore es-a es-b`; the
|
|
49
|
+
# block forms become `dxlint-ignore-start` / `-end`. `dxlint-ignore` alone on
|
|
50
|
+
# its line covers the next line, after code its own: a next-line directive
|
|
51
|
+
# after code has no equivalent ("keep": reported, not fixed), and a same-line
|
|
52
|
+
# one alone on its line suppresses nothing (null: removed). Null for other
|
|
53
|
+
# comments too.
|
|
54
|
+
fn eslint_suppression(source, n, content, renames) = {
|
|
55
|
+
value kind: if re_test(content, /^eslint-(?:disable-next-line|disable-line|disable|enable)(?:\s|$)/)
|
|
56
|
+
then re_replace(content, /^eslint-(disable-next-line|disable-line|disable|enable)[\s\S]*$/, "$1") else null
|
|
57
|
+
value alone: re_test(byte_slice(source, position(n.offset).js_line_start, n.offset), /^[ \t]*$/)
|
|
58
|
+
value rest: re_replace(re_replace(content, /^eslint-[a-z-]+/, ""), /\s--[\s\S]*$/, "")
|
|
59
|
+
value ids: filter(split(trim(re_replace(rest, /[\s,]+/, " ")), " "), id => id != "")
|
|
60
|
+
value names: join(map(ids, id => " " eslint_rule_name(id, renames)))
|
|
61
|
+
value word: get({ disable: "dxlint-ignore-start", enable: "dxlint-ignore-end" }, kind ?? "")
|
|
62
|
+
?? (if kind == "disable-next-line" && alone || kind == "disable-line" && !alone then "dxlint-ignore" else null)
|
|
63
|
+
value if kind == "disable-next-line" && !alone then "keep"
|
|
64
|
+
else if word == null then null else if n is ts_line_comment then "// " word names else "/* " word names " */"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# An ESLint rule id as dxlint names it: the plugin goes (`@typescript-eslint/`,
|
|
68
|
+
# `import/`, ...), the language prefix comes.
|
|
69
|
+
fn eslint_rule_name(id, renames) = get(renames, id) ?? get({
|
|
70
|
+
"import/no-deprecated": "es-import-no-deprecated",
|
|
71
|
+
"license-header/header": "es-header"
|
|
72
|
+
}, id) ?? {
|
|
73
|
+
value bare: re_replace(id, /^.*\//, "")
|
|
74
|
+
value if contains(["eol-last", "linebreak-style", "no-trailing-spaces"], bare) then "shared-" bare else "es-" bare
|
|
75
|
+
}
|
|
76
|
+
|
|
44
77
|
# Only directives before the first code token are triple-slash references.
|
|
45
78
|
in ts_line_comment rule es-triple-slash-reference {
|
|
46
79
|
option lib ("always" | "never") = "always" "When lib directives are allowed."
|