@inthedark/dxlint 0.1.1 → 0.1.3
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 +18 -20
- package/bin/dxlint-linux-x64 +0 -0
- package/bin/dxlint-win32-x64.exe +0 -0
- package/package.json +2 -2
- package/rules/bugs.dx +49 -0
- package/rules/es-no-semi.dx +1 -1
- package/rules/{format.dx → formatting.dx} +7 -9
- package/rules/recommended.dx +5 -50
- package/rules/{conventions.dx → style.dx} +17 -3
- package/rules/suspicious.dx +25 -4
- package/rules/type-safety.dx +18 -0
- package/std/core/lines.dx +3 -3
- package/std/ts/expressions.dx +1 -1
- package/std/ts/format.dx +8 -8
- package/std/ts/indentation.dx +59 -59
- package/std/ts/jsx.dx +9 -9
- package/std/ts/layout/blocks.dx +5 -5
- package/std/ts/layout/calls.dx +8 -8
- package/std/ts/layout/expressions.dx +3 -3
- package/std/ts/layout/literals.dx +2 -2
- package/std/ts/layout/separators.dx +4 -4
- package/std/ts/layout/text.dx +1 -1
- package/std/ts/license.dx +5 -5
- package/std/ts/parentheses.dx +1 -1
- package/std/ts/problems/expressions.dx +2 -2
- package/std/ts/restrictions/comments.dx +1 -1
- package/std/ts/restrictions.dx +11 -11
- package/std/ts/scoping.dx +7 -7
- package/std/ts/structure.dx +9 -9
- package/std/ts/style/classes.dx +2 -2
- package/std/ts/style/comments.dx +13 -5
- package/std/ts/style/declarations.dx +1 -1
- package/std/ts/style/signatures.dx +2 -2
- package/std/ts/style/types.dx +6 -6
- package/std/ts/suggestions/accessors.dx +1 -1
- package/std/ts/suggestions/builtins.dx +1 -1
- package/std/ts/suggestions/comparisons.dx +1 -1
- package/std/ts/suggestions/curly.dx +1 -1
- package/std/ts/suggestions/directives.dx +1 -1
- package/std/ts/suggestions/expressions.dx +1 -1
- package/std/ts/suggestions/functions.dx +3 -3
- package/std/ts/suggestions/object-shorthand.dx +2 -2
- package/std/ts/typed/return-await.dx +1 -1
- package/std/whitespace.dx +2 -2
- package/rules/correctness.dx +0 -33
- package/rules/types.dx +0 -21
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dxlint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let you and your agents own your linter
|
|
4
4
|
|
|
5
5
|
```dx
|
|
6
6
|
import .ts
|
|
@@ -19,20 +19,20 @@ warn: Promises must be awaited, end with a call to .catch, end with a call to .t
|
|
|
19
19
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## another linter? ugh...
|
|
23
23
|
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
24
|
+
- **it's over 200× faster than eslint+typescript-eslint.** because apples to apples requires eslint *without* its caching enabled, and dxlint's cache is intrinsic. (even without that, it's also twice as fast and significantly less memory hungry)
|
|
25
|
+
- **and it has almost perfect eslint parity.** 99.4% of eslint's and typescript-eslint's test cases give the same result. type-aware rules read your `tsconfig.json` *without running typescript*
|
|
26
|
+
- **everything is overrideable, you own it all.** built-in rules are `.dx` files: override them, tweak them, write your own, or describe a whole new language
|
|
27
|
+
- **plus a high quality vscode extension too!** extremely fast, with diagnostics, with a proper `.dx` lsp
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## getting started
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
32
|
npm install --save-dev @inthedark/dxlint
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
put a `.dx` at your project root:
|
|
36
36
|
|
|
37
37
|
```dx
|
|
38
38
|
import .ts
|
|
@@ -48,13 +48,15 @@ ignore "dist" "src/generated/**"
|
|
|
48
48
|
| `dxlint rules` | list every rule with its options |
|
|
49
49
|
| `dxlint describe <name>` | explain a rule, option or anything else in the config |
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
exit code 1 means errors were found, 2 means the config is broken.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
don't forget to add `.dxcache` to `.gitignore`!!!
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
for more on the basics: [docs/basic.md](docs/basic.md) and [the rule list](docs/rules/README.md).
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
## the language
|
|
58
|
+
|
|
59
|
+
a rule is a few lines of `.dx`: where to look, when it is wrong, and optionally the fix
|
|
58
60
|
|
|
59
61
|
```dx
|
|
60
62
|
import .ts
|
|
@@ -66,13 +68,9 @@ in ts_call.callee rule no-alert-calls error "use the notification service instea
|
|
|
66
68
|
|
|
67
69
|
[docs/advanced.md](docs/advanced.md) covers the whole language, from rules over the built-in syntax trees to defining your own languages. [docs/ts.md](docs/ts.md) covers what the TypeScript library understands: scopes, modules, types and narrowing.
|
|
68
70
|
|
|
69
|
-
##
|
|
70
|
-
|
|
71
|
-
`dxlint lsp` is a language server: diagnostics as you type, quick fixes, fix-all, and for `.dx` files hover, go to definition, references, completion and an outline. The VS Code extension is in [editors/vscode](editors/vscode).
|
|
72
|
-
|
|
73
|
-
## Performance
|
|
71
|
+
## performance
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
one core (`--jobs 1`, both pinned to the same core, wall time, measured in one session), on a project with 2,094 .ts files, its complex custom eslint config ported, type-aware rules included:
|
|
76
74
|
|
|
77
75
|
| | ESLint | dxlint |
|
|
78
76
|
| --- | --- | --- |
|
|
@@ -80,6 +78,6 @@ One core (`--jobs 1`, both pinned to the same core, wall time, measured in one s
|
|
|
80
78
|
| cached run, nothing changed | 4.4 s | 0.8 s |
|
|
81
79
|
| peak memory (working set) | 2.0 GB | 0.7 GB |
|
|
82
80
|
|
|
83
|
-
|
|
81
|
+
and remember: this isn't a fair comparison because [eslint --cache doesn't work with typescript-eslint](https://typescript-eslint.io/troubleshooting/faqs/eslint/?utm_source=chatgpt.com#can-i-use-eslints---cache-with-typescript-eslint)!
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
also note that by default dxlint uses every core, and is significantly better at that than eslint+typescript-eslint due to no reliance on typescript itself
|
package/bin/dxlint-linux-x64
CHANGED
|
Binary file
|
package/bin/dxlint-win32-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inthedark/dxlint",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "let you and your agents own your linter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/rules/bugs.dx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# rules:bugs: code that is wrong: it throws, never runs, or cannot do what it
|
|
2
|
+
# says. On as errors. Part of rules:recommended; no rule is in two rulesets.
|
|
3
|
+
|
|
4
|
+
rule es-await-thenable* error
|
|
5
|
+
rule es-constructor-super error
|
|
6
|
+
rule es-for-direction error
|
|
7
|
+
rule es-getter-return error
|
|
8
|
+
rule es-no-array-delete error
|
|
9
|
+
rule es-no-async-promise-executor error
|
|
10
|
+
rule es-no-base-to-string error
|
|
11
|
+
rule es-no-class-assign error
|
|
12
|
+
rule es-no-compare-neg-zero error
|
|
13
|
+
rule es-no-const-assign error
|
|
14
|
+
rule es-no-constant-binary-expression error
|
|
15
|
+
rule es-no-dupe-args error
|
|
16
|
+
rule es-no-dupe-class-members error
|
|
17
|
+
rule es-no-dupe-else-if error
|
|
18
|
+
rule es-no-dupe-keys error
|
|
19
|
+
rule es-no-duplicate-case error
|
|
20
|
+
rule es-no-duplicate-enum-values error
|
|
21
|
+
rule es-no-empty-character-class error
|
|
22
|
+
rule es-no-ex-assign error
|
|
23
|
+
rule es-no-floating-promises error
|
|
24
|
+
rule es-no-for-in-array error
|
|
25
|
+
rule es-no-func-assign error
|
|
26
|
+
rule es-no-import-assign error
|
|
27
|
+
rule es-no-invalid-regexp error
|
|
28
|
+
rule es-no-loss-of-precision error
|
|
29
|
+
rule es-no-misleading-character-class* error
|
|
30
|
+
rule es-no-misused-promises error
|
|
31
|
+
rule es-no-new-native-nonconstructor error
|
|
32
|
+
rule es-no-non-null-asserted-optional-chain error
|
|
33
|
+
rule es-no-obj-calls error
|
|
34
|
+
rule es-no-redeclare error
|
|
35
|
+
rule es-no-self-assign error
|
|
36
|
+
rule es-no-setter-return error
|
|
37
|
+
rule es-no-sparse-arrays error
|
|
38
|
+
rule es-no-this-before-super error
|
|
39
|
+
rule es-no-unassigned-vars error
|
|
40
|
+
rule es-no-undef error
|
|
41
|
+
rule es-no-unexpected-multiline* error
|
|
42
|
+
rule es-no-unreachable error
|
|
43
|
+
rule es-no-unsafe-declaration-merging error
|
|
44
|
+
rule es-no-unsafe-finally* error
|
|
45
|
+
rule es-no-unsafe-negation error
|
|
46
|
+
rule es-no-unsafe-optional-chaining* error
|
|
47
|
+
rule es-unbound-method error
|
|
48
|
+
rule es-use-isnan error
|
|
49
|
+
rule es-valid-typeof error
|
package/rules/es-no-semi.dx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# rules:es-no-semi: semicolon-free JavaScript and TypeScript, on top of
|
|
2
|
-
# rules:
|
|
2
|
+
# rules:formatting. Statements end without `;`; a line that would continue the
|
|
3
3
|
# previous statement (`(`, `[`, a template) starts with its guard: `;[1].map(f)`.
|
|
4
4
|
|
|
5
5
|
rule es-semi {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# rules:
|
|
2
|
-
# lay code out (and topiary's for Rust).
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
# rules:formatting: layout and spacing, as eslint's and @stylistic's defaults
|
|
2
|
+
# lay code out (and topiary's for Rust). On as warnings; not part of
|
|
3
|
+
# rules:recommended. Rules whose port cannot follow the upstream default yet
|
|
4
|
+
# are left out (comma-dangle, object-curly-spacing, arrow-parens,
|
|
5
5
|
# dot-location, quote-props, operator-linebreak, one-var,
|
|
6
|
-
# generator-star-spacing, lines-between-class-members,
|
|
7
|
-
# padding-line-between-statements).
|
|
6
|
+
# generator-star-spacing, lines-between-class-members, padded-blocks,
|
|
7
|
+
# padding-line-between-statements). rules:es-no-semi drops semicolons on top.
|
|
8
8
|
|
|
9
9
|
rule es-array-bracket-spacing
|
|
10
10
|
rule es-arrow-spacing*
|
|
@@ -16,7 +16,6 @@ rule es-check-alignment*
|
|
|
16
16
|
rule es-comma-spacing*
|
|
17
17
|
rule es-comma-style
|
|
18
18
|
rule es-computed-property-spacing
|
|
19
|
-
rule shared-eol-last
|
|
20
19
|
rule es-key-spacing
|
|
21
20
|
rule es-keyword-spacing*
|
|
22
21
|
rule es-member-delimiter-style* {
|
|
@@ -28,8 +27,6 @@ rule es-no-mixed-operators*
|
|
|
28
27
|
rule es-no-multi-spaces
|
|
29
28
|
rule es-no-multiple-empty-lines
|
|
30
29
|
rule es-no-whitespace-before-property
|
|
31
|
-
rule es-padded-blocks:always-top
|
|
32
|
-
rule es-padded-blocks:always-bottom
|
|
33
30
|
rule es-quotes* {
|
|
34
31
|
set style "double"
|
|
35
32
|
}
|
|
@@ -45,5 +42,6 @@ rule es-template-curly-spacing
|
|
|
45
42
|
rule es-template-tag-spacing
|
|
46
43
|
rule es-type-annotation-spacing
|
|
47
44
|
rule es-yield-star-spacing
|
|
45
|
+
rule shared-eol-last
|
|
48
46
|
|
|
49
47
|
rule rs-*
|
package/rules/recommended.dx
CHANGED
|
@@ -1,51 +1,6 @@
|
|
|
1
|
-
# rules:recommended:
|
|
2
|
-
#
|
|
1
|
+
# rules:recommended: dxlint's recommendation: definite bugs as errors, likely
|
|
2
|
+
# mistakes and type-safety leaks as warnings. Exactly these three rulesets.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
rule es-no-compare-neg-zero
|
|
8
|
-
rule es-no-cond-assign
|
|
9
|
-
rule es-no-constant-condition*
|
|
10
|
-
rule es-no-control-regex
|
|
11
|
-
rule es-no-debugger
|
|
12
|
-
rule es-no-delete-var
|
|
13
|
-
rule es-no-dupe-else-if
|
|
14
|
-
rule es-no-duplicate-case
|
|
15
|
-
rule es-no-empty-character-class
|
|
16
|
-
rule es-no-empty-pattern*
|
|
17
|
-
rule es-no-empty-static-block
|
|
18
|
-
rule es-no-ex-assign
|
|
19
|
-
rule es-no-extra-boolean-cast*
|
|
20
|
-
rule es-no-fallthrough
|
|
21
|
-
rule es-no-global-assign
|
|
22
|
-
rule es-no-invalid-regexp
|
|
23
|
-
rule es-no-irregular-whitespace
|
|
24
|
-
rule es-no-loss-of-precision
|
|
25
|
-
rule es-no-misleading-character-class*
|
|
26
|
-
rule es-no-misused-new*
|
|
27
|
-
rule es-no-nonoctal-decimal-escape
|
|
28
|
-
rule es-no-octal
|
|
29
|
-
rule es-no-regex-spaces*
|
|
30
|
-
rule es-no-require-imports
|
|
31
|
-
rule es-no-self-assign
|
|
32
|
-
rule es-no-shadow-restricted-names
|
|
33
|
-
rule es-no-sparse-arrays
|
|
34
|
-
rule es-no-unexpected-multiline*
|
|
35
|
-
rule es-no-unsafe-finally*
|
|
36
|
-
rule es-no-unsafe-function-type
|
|
37
|
-
rule es-no-unsafe-optional-chaining*
|
|
38
|
-
rule es-no-unused-expressions
|
|
39
|
-
rule es-no-unused-labels
|
|
40
|
-
rule es-no-unused-private-class-members
|
|
41
|
-
rule es-no-unused-vars*
|
|
42
|
-
rule es-no-useless-assignment
|
|
43
|
-
rule es-no-useless-backreference*
|
|
44
|
-
rule es-no-useless-catch*
|
|
45
|
-
rule es-no-useless-escape*
|
|
46
|
-
rule es-no-wrapper-object-types
|
|
47
|
-
rule es-prefer-namespace-keyword
|
|
48
|
-
rule es-require-yield
|
|
49
|
-
rule es-triple-slash-reference
|
|
50
|
-
rule es-use-isnan
|
|
51
|
-
rule es-valid-typeof
|
|
4
|
+
import rules:bugs
|
|
5
|
+
import rules:suspicious
|
|
6
|
+
import rules:type-safety
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# rules:
|
|
2
|
-
#
|
|
1
|
+
# rules:style: one consistent, modern way to write things. On as warnings;
|
|
2
|
+
# not part of rules:recommended. No rule is in two rulesets.
|
|
3
3
|
|
|
4
4
|
rule es-adjacent-overload-signatures
|
|
5
5
|
rule es-array-type*
|
|
6
|
-
rule es-ban-
|
|
6
|
+
rule es-ban-linter-comment
|
|
7
7
|
rule es-class-literal-property-style
|
|
8
8
|
rule es-consistent-generic-constructors
|
|
9
9
|
rule es-consistent-indexed-object-style*
|
|
@@ -14,21 +14,35 @@ rule es-eqeqeq
|
|
|
14
14
|
rule es-explicit-function-return-type*
|
|
15
15
|
rule es-explicit-member-accessibility*
|
|
16
16
|
rule es-explicit-module-boundary-types*
|
|
17
|
+
rule es-no-array-constructor
|
|
17
18
|
rule es-no-confusing-non-null-assertion*
|
|
18
19
|
rule es-no-console
|
|
20
|
+
rule es-no-duplicate-type-constituents
|
|
19
21
|
rule es-no-extraneous-class
|
|
20
22
|
rule es-no-inferrable-types*
|
|
23
|
+
rule es-no-namespace
|
|
24
|
+
rule es-no-this-alias
|
|
21
25
|
rule es-no-unassigned-import
|
|
22
26
|
rule es-no-undef-init
|
|
27
|
+
rule es-no-unnecessary-boolean-literal-compare
|
|
28
|
+
rule es-no-unnecessary-template-expression
|
|
29
|
+
rule es-no-unnecessary-type-arguments
|
|
30
|
+
rule es-no-unnecessary-type-constraint
|
|
23
31
|
rule es-no-useless-constructor
|
|
24
32
|
rule es-no-var
|
|
25
33
|
rule es-no-var-requires
|
|
34
|
+
rule es-prefer-as-const
|
|
26
35
|
rule es-prefer-const
|
|
36
|
+
rule es-prefer-find*
|
|
27
37
|
rule es-prefer-function-type
|
|
38
|
+
rule es-prefer-includes
|
|
28
39
|
rule es-prefer-namespace-keyword
|
|
29
40
|
rule es-prefer-object-spread
|
|
41
|
+
rule es-prefer-optional-chain
|
|
42
|
+
rule es-prefer-readonly*
|
|
30
43
|
rule es-prefer-rest-params
|
|
31
44
|
rule es-prefer-spread
|
|
45
|
+
rule es-prefer-string-starts-ends-with*
|
|
32
46
|
rule es-prefer-template
|
|
33
47
|
rule es-radix
|
|
34
48
|
rule es-triple-slash-reference
|
package/rules/suspicious.dx
CHANGED
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
# rules:suspicious:
|
|
2
|
-
#
|
|
1
|
+
# rules:suspicious: likely a mistake, or code that does nothing. On as
|
|
2
|
+
# warnings. Part of rules:recommended; no rule is in two rulesets.
|
|
3
3
|
|
|
4
4
|
rule es-no-caller
|
|
5
|
+
rule es-no-case-declarations
|
|
6
|
+
rule es-no-cond-assign
|
|
7
|
+
rule es-no-constant-condition*
|
|
8
|
+
rule es-no-control-regex
|
|
9
|
+
rule es-no-debugger
|
|
5
10
|
rule es-no-delete-var
|
|
11
|
+
rule es-no-deprecated
|
|
12
|
+
rule es-no-empty
|
|
6
13
|
rule es-no-empty-interface
|
|
14
|
+
rule es-no-empty-pattern*
|
|
7
15
|
rule es-no-empty-static-block
|
|
8
16
|
rule es-no-eval*
|
|
9
17
|
rule es-no-extra-bind
|
|
10
18
|
rule es-no-extra-boolean-cast*
|
|
19
|
+
rule es-no-extra-non-null-assertion
|
|
20
|
+
rule es-no-fallthrough
|
|
11
21
|
rule es-no-global-assign
|
|
22
|
+
rule es-no-implied-eval
|
|
23
|
+
rule es-no-irregular-whitespace
|
|
12
24
|
rule es-no-misused-new*
|
|
13
25
|
rule es-no-new-func
|
|
14
26
|
rule es-no-new-wrappers
|
|
15
27
|
rule es-no-nonoctal-decimal-escape
|
|
16
28
|
rule es-no-octal
|
|
29
|
+
rule es-no-prototype-builtins
|
|
30
|
+
rule es-no-redundant-type-constituents
|
|
17
31
|
rule es-no-regex-spaces*
|
|
18
32
|
rule es-no-require-imports
|
|
19
33
|
rule es-no-sequences
|
|
20
34
|
rule es-no-shadow-restricted-names
|
|
21
35
|
rule es-no-template-curly-in-string
|
|
22
36
|
rule es-no-throw-literal
|
|
23
|
-
rule es-no-
|
|
37
|
+
rule es-no-unnecessary-type-assertion
|
|
24
38
|
rule es-no-unused-expressions
|
|
25
39
|
rule es-no-unused-imports
|
|
26
40
|
rule es-no-unused-labels
|
|
41
|
+
rule es-no-unused-private-class-members
|
|
42
|
+
rule es-no-unused-vars*
|
|
43
|
+
rule es-no-useless-assignment
|
|
44
|
+
rule es-no-useless-backreference*
|
|
27
45
|
rule es-no-useless-catch*
|
|
28
46
|
rule es-no-useless-escape*
|
|
29
47
|
rule es-no-with
|
|
30
|
-
rule es-
|
|
48
|
+
rule es-only-throw-error
|
|
49
|
+
rule es-prefer-promise-reject-errors
|
|
50
|
+
rule es-preserve-caught-error
|
|
51
|
+
rule es-require-await
|
|
31
52
|
rule es-require-yield
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# rules:type-safety: code that switches type checking off or lets `any` and
|
|
2
|
+
# loose types leak. On as warnings. Part of rules:recommended; no rule is in
|
|
3
|
+
# two rulesets.
|
|
4
|
+
|
|
5
|
+
rule es-ban-ts-comment
|
|
6
|
+
rule es-no-empty-object-type
|
|
7
|
+
rule es-no-explicit-any
|
|
8
|
+
rule es-no-unsafe-argument
|
|
9
|
+
rule es-no-unsafe-assignment
|
|
10
|
+
rule es-no-unsafe-call
|
|
11
|
+
rule es-no-unsafe-enum-comparison
|
|
12
|
+
rule es-no-unsafe-function-type
|
|
13
|
+
rule es-no-unsafe-member-access
|
|
14
|
+
rule es-no-unsafe-return
|
|
15
|
+
rule es-no-unsafe-unary-minus
|
|
16
|
+
rule es-no-wrapper-object-types
|
|
17
|
+
rule es-restrict-plus-operands*
|
|
18
|
+
rule es-restrict-template-expressions
|
package/std/core/lines.dx
CHANGED
|
@@ -14,14 +14,14 @@ define {
|
|
|
14
14
|
|
|
15
15
|
in .* layer lines match core_file_tail /[^\n]\z/
|
|
16
16
|
in core_file_tail rule shared-eol-last warn "Newline required at end of file but not found." {
|
|
17
|
-
option mode "always" | "never" = "always" "whether files end in a newline"
|
|
17
|
+
default option mode "always" | "never" = "always" "whether files end in a newline"
|
|
18
18
|
when mode == "always"
|
|
19
19
|
report at end_offset
|
|
20
20
|
fix as text "\n"
|
|
21
21
|
}
|
|
22
22
|
in .* layer lines match core_final_newlines /(?:\r?\n)+\z/
|
|
23
23
|
in core_final_newlines rule shared-eol-last:never warn "Newline not allowed at end of file." {
|
|
24
|
-
option mode "always" | "never" = "always" "whether files end in a newline"
|
|
24
|
+
default option mode "always" | "never" = "always" "whether files end in a newline"
|
|
25
25
|
when mode == "never"
|
|
26
26
|
report at { start: end_offset - (if ends_with(text, "\r\n") then 2 else 1), end: end_offset }
|
|
27
27
|
fix as ""
|
|
@@ -43,7 +43,7 @@ define {
|
|
|
43
43
|
|
|
44
44
|
in core_line match core_line_break /\r\n|[\n\r\u{2028}\u{2029}]/
|
|
45
45
|
in core_line_break rule shared-linebreak-style {
|
|
46
|
-
option mode "unix" | "windows" = "unix"
|
|
46
|
+
default option mode "unix" | "windows" = "unix"
|
|
47
47
|
when mode == "unix" && text != "\n" || mode == "windows" && text != "\r\n"
|
|
48
48
|
fix as if mode == "unix" then "\n" else "\r\n"
|
|
49
49
|
warn if mode == "unix" then "Expected linebreaks to be 'LF' but found 'CRLF'." else "Expected linebreaks to be 'CRLF' but found 'LF'."
|
package/std/ts/expressions.dx
CHANGED
|
@@ -256,7 +256,7 @@ fn logical_assignment_fix(source, n, info) = if !expression_fix_clean(n) then nu
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
in ts_assignment, ts_logical, ts_if rule es-logical-assignment-operators {
|
|
259
|
-
option mode ("always" | "never") = "always" "logical assignment policy"
|
|
259
|
+
default option mode ("always" | "never") = "always" "logical assignment policy"
|
|
260
260
|
option enforceForIfStatements boolean = false "include conditional assignments"
|
|
261
261
|
when not ts_if || enforceForIfStatements
|
|
262
262
|
let logical_info logical_assignment_info(node)
|
package/std/ts/format.dx
CHANGED
|
@@ -110,7 +110,7 @@ in ts_variable_declaration.kind rule es-no-var warn "Unexpected var, use let or
|
|
|
110
110
|
# ---- spacing ---------------------------------------------------------------
|
|
111
111
|
|
|
112
112
|
in ts_open_paren rule es-space-in-parens:after {
|
|
113
|
-
option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
113
|
+
default option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
114
114
|
option exceptions ("{}" | "[]" | "()" | "empty")[] = [] "invert spacing for nested delimiters"
|
|
115
115
|
let paren_edge token(node, "after")
|
|
116
116
|
when mode != "never" || count(exceptions) > 0 || paren_edge.start != end_offset
|
|
@@ -132,7 +132,7 @@ in ts_open_paren rule es-space-in-parens:after {
|
|
|
132
132
|
warn if paren_space != "" then "There should be no space after this paren." else "There must be a space after this paren."
|
|
133
133
|
}
|
|
134
134
|
in ts_close_paren rule es-space-in-parens:before {
|
|
135
|
-
option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
135
|
+
default option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
136
136
|
option exceptions ("{}" | "[]" | "()" | "empty")[] = [] "invert spacing for nested delimiters"
|
|
137
137
|
let paren_edge token(node, "before")
|
|
138
138
|
when mode != "never" || count(exceptions) > 0 || paren_edge.end != offset
|
|
@@ -161,7 +161,7 @@ fn format_gap_text(gap, spaced, comments) = (if spaced then " " else "") {
|
|
|
161
161
|
join ""
|
|
162
162
|
}
|
|
163
163
|
in ts_array, ts_array_pattern rule es-array-bracket-spacing {
|
|
164
|
-
option style "always" | "never" = "never" "spacing inside array brackets"
|
|
164
|
+
default option style "always" | "never" = "never" "spacing inside array brackets"
|
|
165
165
|
option singleValue boolean | null = null "override spacing around a single element"
|
|
166
166
|
option objectsInArrays boolean | null = null "override spacing beside object elements"
|
|
167
167
|
option arraysInArrays boolean | null = null "override spacing beside nested arrays"
|
|
@@ -195,7 +195,7 @@ in ts_array, ts_array_pattern rule es-array-bracket-spacing {
|
|
|
195
195
|
}
|
|
196
196
|
in ts_dot, ts_punctuator, ts_member.optional rule es-dot-location {
|
|
197
197
|
@ts_token_context
|
|
198
|
-
option style "object" | "property" = "property" "line for a member-access dot"
|
|
198
|
+
default option style "object" | "property" = "property" "line for a member-access dot"
|
|
199
199
|
when text == "." || text == "?."
|
|
200
200
|
when parent is (ts_member, ts_qualified_name, ts_import_type, ts_meta_property, ts_jsx_name)
|
|
201
201
|
when if style == "object" then position(offset).js_line != position(token(node, "before").end).js_line
|
|
@@ -210,7 +210,7 @@ in ts_dot, ts_punctuator, ts_member.optional rule es-dot-location {
|
|
|
210
210
|
|
|
211
211
|
@macro format_template_curly {
|
|
212
212
|
@ts_token_context
|
|
213
|
-
option mode "always" | "never" = "never" "spacing inside template substitutions"
|
|
213
|
+
default option mode "always" | "never" = "never" "spacing inside template substitutions"
|
|
214
214
|
let template_before { value space_before.text; re_find /\s*$/; nonempty } ?? ""
|
|
215
215
|
let template_after { value space_after.text; re_find /^\s*/; nonempty } ?? ""
|
|
216
216
|
}
|
|
@@ -240,7 +240,7 @@ in ts_template.quasi rule es-template-curly-spacing:missing-before warn "Expecte
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
@macro format_template_tag {
|
|
243
|
-
option style "always" | "never" = "never" "spacing after a template tag"
|
|
243
|
+
default option style "always" | "never" = "never" "spacing after a template tag"
|
|
244
244
|
let tag_gap ts_token_space(source, quasi.node, true)
|
|
245
245
|
let tag_comments { value overlapping(ts_comment); filter (comment) comment.offset >= tag_gap.start && comment.end_offset <= tag_gap.end }
|
|
246
246
|
let tag_line_comment any(tag_comments, comment => comment is ts_line_comment)
|
|
@@ -317,7 +317,7 @@ in ts_arrow.operator, ts_punctuator rule es-arrow-spacing:unexpected-after warn
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
@macro format_arrow_parens {
|
|
320
|
-
option style "always" | "as-needed" = "always" "parentheses around one arrow parameter"
|
|
320
|
+
default option style "always" | "as-needed" = "always" "parentheses around one arrow parameter"
|
|
321
321
|
option requireForBlockBody boolean = false "keep parentheses with a block body"
|
|
322
322
|
}
|
|
323
323
|
in ts_parameter let format_arrow_plain name is ts_identifier && optional == null && type == null && init == null && count(modifier) == 0 && count(decorator) == 0
|
|
@@ -376,7 +376,7 @@ in ts_assignment_pattern let format_curly_tail right.format_curly_tail.nonempty
|
|
|
376
376
|
in ts_as, ts_satisfies let format_curly_tail type.format_curly_tail.nonempty ?? type.node
|
|
377
377
|
in ts_mapped_type let format_object_tail type.format_curly_tail.nonempty ?? type.node
|
|
378
378
|
@macro format_object_curly_options {
|
|
379
|
-
option style "always" | "never" = "never" "spaces inside object-like braces"
|
|
379
|
+
default option style "always" | "never" = "never" "spaces inside object-like braces"
|
|
380
380
|
option arraysInObjects boolean | null = null "override spacing beside array values and index signatures"
|
|
381
381
|
option objectsInObjects boolean | null = null "override spacing beside object values"
|
|
382
382
|
option overrides { [node: string]: "always" | "never" } = {} "spacing by syntax kind"
|