@inthedark/dxlint 0.1.8 → 0.1.10
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/core/frozen.dx +44 -0
- package/std/core.dx +1 -0
- package/std/ts/helpers.dx +3 -0
- package/std/ts/scoping/member-uses.dx +1 -2
- package/std/ts/style/classes.dx +3 -0
- package/std/ts/style/returns.dx +2 -0
package/bin/dxlint-linux-x64
CHANGED
|
Binary file
|
package/bin/dxlint-win32-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# .core/frozen: files sealed against change. A comment line holding
|
|
2
|
+
# `dxlint-frozen <hash>` seals the rest of the file: the hash covers every
|
|
3
|
+
# other line (line breaks as LF, no BOM), so any edit outside it shows.
|
|
4
|
+
# `dxlint-frozen <command> [args...] <hash>` seals what a command the root
|
|
5
|
+
# config declares prints for those arguments instead.
|
|
6
|
+
@macro frozen_seal_start /(?m)^[ \t]*(?:\/\/|#|--|;|\/\*|<!--)[ \t]*dxlint-frozen\b/
|
|
7
|
+
|
|
8
|
+
define {
|
|
9
|
+
fn frozen_hash(text) = fnv_hash(replace(re_replace(text, /^\u{FEFF}/, ""), "\r\n", "\n"))
|
|
10
|
+
|
|
11
|
+
in .* layer text match frozen_seal /^[ \t]*(?:\/\/|#|--|;|\/\*|<!--)[ \t]*dxlint-frozen\b[^\r\n]*(?:\r?\n|\z)/
|
|
12
|
+
in frozen_seal rule shared-frozen-file {
|
|
13
|
+
# Only the first seal counts; later ones are sealed content.
|
|
14
|
+
when !re_test(byte_slice(source, 0, offset), @frozen_seal_start)
|
|
15
|
+
let line trim_end(text, "\r\n")
|
|
16
|
+
# The line up to its last word, without a block comment's closer.
|
|
17
|
+
let kept re_replace(line, /[ \t]*(?:\*\/|-->)?[ \t]*$/, "")
|
|
18
|
+
let body re_replace(kept, /^.*?dxlint-frozen\b[ \t:]*/, "")
|
|
19
|
+
let words if body == "" then [] else split(re_replace(body, /[ \t]+/, " "), " ")
|
|
20
|
+
let written if re_test(last(words) ?? "", /^[0-9a-f]{16}$/) then last(words) else null
|
|
21
|
+
let named if written == null then words else take(words, count(words) - 1)
|
|
22
|
+
let command first(named)
|
|
23
|
+
let ran if command == null then null else command_output(node, command, drop(named, 1))
|
|
24
|
+
# A command still running: the file is linted again when it finishes.
|
|
25
|
+
when ran == null || ran.state != "pending"
|
|
26
|
+
let sealed when {
|
|
27
|
+
command == null then frozen_hash(byte_slice(source, 0, offset) byte_slice(source, end_offset))
|
|
28
|
+
ran.state == "ready" then frozen_hash(ran.output)
|
|
29
|
+
else then null
|
|
30
|
+
}
|
|
31
|
+
when sealed == null || written != sealed
|
|
32
|
+
let line_span { start: offset, end: offset + byte_len(line) }
|
|
33
|
+
let hash_span { start: offset + byte_len(kept) - 16, end: offset + byte_len(kept) }
|
|
34
|
+
report at line_span
|
|
35
|
+
warn when {
|
|
36
|
+
ran.state == "failed" then "Command `{command}` failed: {ran.message}"
|
|
37
|
+
ran.state == "disabled" then "Commands are off in this workspace, so this seal is not checked."
|
|
38
|
+
written == null then "Frozen file has no hash yet."
|
|
39
|
+
else then "Frozen file changed since it was sealed."
|
|
40
|
+
}
|
|
41
|
+
fix at line_span if sealed != null && written == null as kept " " sealed byte_slice(line, byte_len(kept))
|
|
42
|
+
suggest "Seal the file as it is now" at hash_span if sealed != null && written != null as sealed
|
|
43
|
+
}
|
|
44
|
+
}
|
package/std/core.dx
CHANGED
package/std/ts/helpers.dx
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
# A plain identifier, nothing else (`x`, `$el`, not `a.b` or `f()`).
|
|
4
4
|
fn is_identifier(x) = re_test(x, /^[A-Za-z_$][\w$]*$/)
|
|
5
5
|
|
|
6
|
+
# TypeScript source, where type-only syntax (annotations, modifiers) is legal.
|
|
7
|
+
in ts_program let typescript_source re_test(file, /\.[cm]?tsx?$/)
|
|
8
|
+
|
|
6
9
|
fn unparenthesised_node(n) = if n not ts_parenthesized then n else { value n; walk (current) if current is ts_parenthesized then current.expression.node else null; last }
|
|
7
10
|
fn outer_parenthesised_node(n) = { value n; walk (current) if current.parent is ts_parenthesized then current.parent.node else null; last }
|
|
8
11
|
|
|
@@ -90,14 +90,13 @@ fn member_usage_used(declaration) = {
|
|
|
90
90
|
}))
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
in ts_program let member_usage_typescript_file re_test(file, /\.[cm]?tsx?$/)
|
|
94
93
|
in ts_method, ts_class_property, ts_parameter let member_usage_private
|
|
95
94
|
modifier != null && contains([] modifier, "private")
|
|
96
95
|
in ts_method.key, ts_class_property.key, ts_parameter.name rule es-no-unused-private-class-members {
|
|
97
96
|
when is (ts_private_name, ts_identifier, ts_string, ts_number, ts_computed_key)
|
|
98
97
|
when parent not ts_parameter || parent.member_usage_private
|
|
99
98
|
when is ts_private_name || parent.member_usage_private
|
|
100
|
-
let typed ts_program.
|
|
99
|
+
let typed ts_program.typescript_source
|
|
101
100
|
when is ts_private_name || typed
|
|
102
101
|
let declaration parent.node
|
|
103
102
|
let name ts_value_key(node)
|
package/std/ts/style/classes.dx
CHANGED
|
@@ -40,6 +40,7 @@ in ts_class_property rule es-explicit-member-accessibility:property {
|
|
|
40
40
|
option accessibility ("explicit" | "no-public" | "off") = "explicit" "Required accessibility."
|
|
41
41
|
option ignoredMethodNames string[] = [] "Ignored method names."
|
|
42
42
|
option overrides { properties?: string; methods?: string; accessors?: string; constructors?: string; parameterProperties?: string } = {} "Requirements by member kind."
|
|
43
|
+
when ts_program.typescript_source
|
|
43
44
|
let check overrides.properties.nonempty ?? accessibility
|
|
44
45
|
let shape style_member
|
|
45
46
|
when !re_test(key, /^#/) && (check == "explicit" && !{ value @modifiers; has_accessibility } || check == "no-public" && contains([] modifier, "public"))
|
|
@@ -52,6 +53,7 @@ in ts_method rule es-explicit-member-accessibility:method {
|
|
|
52
53
|
option accessibility ("explicit" | "no-public" | "off") = "explicit" "Required accessibility."
|
|
53
54
|
option ignoredMethodNames string[] = [] "Ignored method names."
|
|
54
55
|
option overrides { properties?: string; methods?: string; accessors?: string; constructors?: string; parameterProperties?: string } = {} "Requirements by member kind."
|
|
56
|
+
when ts_program.typescript_source
|
|
55
57
|
let check {
|
|
56
58
|
value (if class_constructor then overrides.constructors else if kind == "get" || kind == "set" then overrides.accessors else overrides.methods)
|
|
57
59
|
nonempty
|
|
@@ -68,6 +70,7 @@ in ts_parameter rule es-explicit-member-accessibility:parameter {
|
|
|
68
70
|
option accessibility ("explicit" | "no-public" | "off") = "explicit" "Required accessibility."
|
|
69
71
|
option ignoredMethodNames string[] = [] "Ignored method names."
|
|
70
72
|
option overrides { properties?: string; methods?: string; accessors?: string; constructors?: string; parameterProperties?: string } = {} "Requirements by member kind."
|
|
73
|
+
when ts_program.typescript_source
|
|
71
74
|
let check overrides.parameterProperties.nonempty ?? accessibility
|
|
72
75
|
let shape style_member
|
|
73
76
|
when contains([] modifier, "readonly") && parent is ts_method
|
package/std/ts/style/returns.dx
CHANGED
|
@@ -67,6 +67,7 @@ in ts_function, ts_arrow, ts_method let explicit_return_shape {
|
|
|
67
67
|
option allowHigherOrderFunctions boolean = true "Allow functions returning only functions."
|
|
68
68
|
option allowIIFEs boolean = false "Allow functions directly within calls."
|
|
69
69
|
option allowTypedFunctionExpressions boolean = true "Allow contextually typed function expressions."
|
|
70
|
+
when ts_program.typescript_source
|
|
70
71
|
let shape explicit_return_shape
|
|
71
72
|
when !shape.valid && !contains(allowedNames, shape.name)
|
|
72
73
|
when !(allowFunctionsWithoutTypeParameters && count(type_parameter) == 0 || allowIIFEs && shape.iife || allowHigherOrderFunctions && shape.higher_order || allowConciseArrowFunctionExpressionsStartingWithVoid && shape.void_arrow)
|
|
@@ -133,6 +134,7 @@ in ts_parameter let boundary_argument {
|
|
|
133
134
|
option allowHigherOrderFunctions boolean = true "Allow functions returning only functions."
|
|
134
135
|
option allowTypedFunctionExpressions boolean = true "Allow contextually typed functions."
|
|
135
136
|
option allowOverloadFunctions boolean = false "Allow implementations with overload signatures."
|
|
137
|
+
when ts_program.typescript_source
|
|
136
138
|
let boundary_shape if parameter_check then parent.explicit_return_shape else explicit_return_shape
|
|
137
139
|
let boundary_name if parameter_check then parent.boundary_function_name else boundary_function_name
|
|
138
140
|
let empty_method if parameter_check then parent.boundary_empty_method else boundary_empty_method
|