@inthedark/dxlint 0.0.0-stage → 0.1.1

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.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -2
  3. package/bin/dxlint +15 -0
  4. package/bin/dxlint-linux-x64 +0 -0
  5. package/bin/dxlint-win32-x64.exe +0 -0
  6. package/package.json +40 -4
  7. package/rules/conventions.dx +34 -0
  8. package/rules/correctness.dx +33 -0
  9. package/rules/es-no-semi.dx +11 -0
  10. package/rules/format.dx +49 -0
  11. package/rules/recommended.dx +51 -0
  12. package/rules/suspicious.dx +31 -0
  13. package/rules/types.dx +21 -0
  14. package/std/c.dx +23 -0
  15. package/std/core/lines.dx +51 -0
  16. package/std/core/lists.dx +76 -0
  17. package/std/core.dx +30 -0
  18. package/std/css.dx +17 -0
  19. package/std/dx.dx +31 -0
  20. package/std/json.dx +104 -0
  21. package/std/markdown.dx +11 -0
  22. package/std/python.dx +21 -0
  23. package/std/rust/format.dx +316 -0
  24. package/std/rust.dx +34 -0
  25. package/std/toml.dx +19 -0
  26. package/std/ts/arithmetic.dx +87 -0
  27. package/std/ts/assertions.dx +477 -0
  28. package/std/ts/calls.dx +246 -0
  29. package/std/ts/comments.dx +10 -0
  30. package/std/ts/conditions.dx +531 -0
  31. package/std/ts/constants.dx +335 -0
  32. package/std/ts/deprecation.dx +185 -0
  33. package/std/ts/directives.dx +60 -0
  34. package/std/ts/effects.dx +219 -0
  35. package/std/ts/enums.dx +233 -0
  36. package/std/ts/expression-fixes.dx +67 -0
  37. package/std/ts/expressions.dx +270 -0
  38. package/std/ts/flow.dx +2 -0
  39. package/std/ts/format.dx +755 -0
  40. package/std/ts/globals.dx +106 -0
  41. package/std/ts/grammar.dx +488 -0
  42. package/std/ts/helpers.dx +102 -0
  43. package/std/ts/import-attributes.dx +88 -0
  44. package/std/ts/import-no-deprecated.dx +73 -0
  45. package/std/ts/indentation.dx +442 -0
  46. package/std/ts/jsx.dx +646 -0
  47. package/std/ts/layout/blocks.dx +281 -0
  48. package/std/ts/layout/calls.dx +79 -0
  49. package/std/ts/layout/expressions.dx +213 -0
  50. package/std/ts/layout/literals.dx +114 -0
  51. package/std/ts/layout/separators.dx +184 -0
  52. package/std/ts/layout/shared.dx +203 -0
  53. package/std/ts/layout/text.dx +142 -0
  54. package/std/ts/layout/types.dx +182 -0
  55. package/std/ts/layout.dx +9 -0
  56. package/std/ts/license.dx +54 -0
  57. package/std/ts/literal-text.dx +3 -0
  58. package/std/ts/literals.dx +95 -0
  59. package/std/ts/methods.dx +69 -0
  60. package/std/ts/modules.dx +268 -0
  61. package/std/ts/names.dx +348 -0
  62. package/std/ts/naming.dx +169 -0
  63. package/std/ts/narrowing.dx +96 -0
  64. package/std/ts/parentheses.dx +262 -0
  65. package/std/ts/precedence.dx +25 -0
  66. package/std/ts/problems/calls.dx +34 -0
  67. package/std/ts/problems/classes.dx +39 -0
  68. package/std/ts/problems/control-flow.dx +257 -0
  69. package/std/ts/problems/declarations.dx +67 -0
  70. package/std/ts/problems/duplicates.dx +70 -0
  71. package/std/ts/problems/expressions.dx +154 -0
  72. package/std/ts/problems/helpers.dx +22 -0
  73. package/std/ts/problems/imports.dx +43 -0
  74. package/std/ts/problems/non-null.dx +78 -0
  75. package/std/ts/problems/numeric-precision.dx +66 -0
  76. package/std/ts/problems/regexp.dx +66 -0
  77. package/std/ts/problems/statements.dx +36 -0
  78. package/std/ts/problems/typescript.dx +55 -0
  79. package/std/ts/problems/whitespace.dx +40 -0
  80. package/std/ts/problems.dx +20 -0
  81. package/std/ts/regex/checks.dx +249 -0
  82. package/std/ts/regex/findings.dx +209 -0
  83. package/std/ts/regex/grammar.dx +80 -0
  84. package/std/ts/regex/suggestions.dx +94 -0
  85. package/std/ts/regex/values.dx +378 -0
  86. package/std/ts/regex.dx +5 -0
  87. package/std/ts/restrictions/comments.dx +76 -0
  88. package/std/ts/restrictions.dx +811 -0
  89. package/std/ts/scopes.dx +68 -0
  90. package/std/ts/scoping/atomic.dx +40 -0
  91. package/std/ts/scoping/bindings.dx +126 -0
  92. package/std/ts/scoping/constness.dx +72 -0
  93. package/std/ts/scoping/globals.dx +52 -0
  94. package/std/ts/scoping/loops.dx +86 -0
  95. package/std/ts/scoping/member-uses.dx +111 -0
  96. package/std/ts/scoping/receivers.dx +107 -0
  97. package/std/ts/scoping/shadowing.dx +202 -0
  98. package/std/ts/scoping/usage.dx +393 -0
  99. package/std/ts/scoping.dx +842 -0
  100. package/std/ts/selectors.dx +10 -0
  101. package/std/ts/spreads.dx +97 -0
  102. package/std/ts/structure/declarations.dx +52 -0
  103. package/std/ts/structure/lines.dx +79 -0
  104. package/std/ts/structure/lists.dx +144 -0
  105. package/std/ts/structure/padding.dx +258 -0
  106. package/std/ts/structure.dx +963 -0
  107. package/std/ts/style/classes.dx +157 -0
  108. package/std/ts/style/comments.dx +75 -0
  109. package/std/ts/style/declarations.dx +82 -0
  110. package/std/ts/style/expressions.dx +125 -0
  111. package/std/ts/style/imports.dx +44 -0
  112. package/std/ts/style/ordering.dx +192 -0
  113. package/std/ts/style/returns.dx +152 -0
  114. package/std/ts/style/signatures.dx +308 -0
  115. package/std/ts/style/type-exports.dx +62 -0
  116. package/std/ts/style/type-imports.dx +166 -0
  117. package/std/ts/style/types.dx +474 -0
  118. package/std/ts/style.dx +29 -0
  119. package/std/ts/suggestions/accessors.dx +138 -0
  120. package/std/ts/suggestions/builtins.dx +110 -0
  121. package/std/ts/suggestions/comparisons.dx +41 -0
  122. package/std/ts/suggestions/computed-keys.dx +20 -0
  123. package/std/ts/suggestions/constructors.dx +54 -0
  124. package/std/ts/suggestions/control-flow.dx +204 -0
  125. package/std/ts/suggestions/curly.dx +124 -0
  126. package/std/ts/suggestions/directives.dx +79 -0
  127. package/std/ts/suggestions/errors.dx +106 -0
  128. package/std/ts/suggestions/expressions.dx +230 -0
  129. package/std/ts/suggestions/functions.dx +260 -0
  130. package/std/ts/suggestions/globals.dx +187 -0
  131. package/std/ts/suggestions/helpers.dx +17 -0
  132. package/std/ts/suggestions/object-shorthand.dx +148 -0
  133. package/std/ts/suggestions/object-spread.dx +96 -0
  134. package/std/ts/suggestions/regexp.dx +59 -0
  135. package/std/ts/suggestions/renames.dx +50 -0
  136. package/std/ts/suggestions/strings.dx +47 -0
  137. package/std/ts/suggestions/templates.dx +104 -0
  138. package/std/ts/suggestions.dx +24 -0
  139. package/std/ts/template-fixes.dx +22 -0
  140. package/std/ts/tokens.dx +124 -0
  141. package/std/ts/type-specifiers.dx +93 -0
  142. package/std/ts/typed/assignments.dx +154 -0
  143. package/std/ts/typed/awaitability.dx +157 -0
  144. package/std/ts/typed/boolean-comparisons.dx +82 -0
  145. package/std/ts/typed/defaults.dx +97 -0
  146. package/std/ts/typed/enum-consistency.dx +68 -0
  147. package/std/ts/typed/enums.dx +52 -0
  148. package/std/ts/typed/errors.dx +32 -0
  149. package/std/ts/typed/floating-promises.dx +147 -0
  150. package/std/ts/typed/for-in-arrays.dx +21 -0
  151. package/std/ts/typed/includes.dx +102 -0
  152. package/std/ts/typed/nullish-coalescing.dx +149 -0
  153. package/std/ts/typed/optional-chains.dx +317 -0
  154. package/std/ts/typed/promises.dx +205 -0
  155. package/std/ts/typed/qualifiers.dx +108 -0
  156. package/std/ts/typed/readonly-members.dx +159 -0
  157. package/std/ts/typed/readonly-parameters.dx +121 -0
  158. package/std/ts/typed/redundant-constituents.dx +171 -0
  159. package/std/ts/typed/regexp-exec.dx +79 -0
  160. package/std/ts/typed/rejection-handlers.dx +91 -0
  161. package/std/ts/typed/return-await.dx +116 -0
  162. package/std/ts/typed/return-this.dx +67 -0
  163. package/std/ts/typed/strict-void-return.dx +121 -0
  164. package/std/ts/typed/string-boundaries.dx +153 -0
  165. package/std/ts/typed/switches.dx +147 -0
  166. package/std/ts/typed/template-expressions.dx +127 -0
  167. package/std/ts/typed/template-values.dx +88 -0
  168. package/std/ts/typed/transfers.dx +106 -0
  169. package/std/ts/typed/type-arguments.dx +337 -0
  170. package/std/ts/typed/type-constituents.dx +143 -0
  171. package/std/ts/typed/type-conversions.dx +82 -0
  172. package/std/ts/typed/type-parameters.dx +280 -0
  173. package/std/ts/typed/unbound-method.dx +167 -0
  174. package/std/ts/typed/unsafe-calls.dx +73 -0
  175. package/std/ts/typed/unsafe-members.dx +36 -0
  176. package/std/ts/typed/void-expressions.dx +101 -0
  177. package/std/ts/typed.dx +585 -0
  178. package/std/ts/values/arguments.dx +13 -0
  179. package/std/ts/values/enums.dx +104 -0
  180. package/std/ts/values/inspection.dx +274 -0
  181. package/std/ts/values.dx +1217 -0
  182. package/std/ts.dx +77 -0
  183. package/std/whitespace.dx +37 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ErisInTheDark
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # dxlint
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A fast linter and fixer for TypeScript, JavaScript, Rust and more. It ships ports of 400+ ESLint, typescript-eslint and ESLint Stylistic rules, the type-aware ones included, and every rule is written in a small language, `.dx`, that you can read, change or extend.
4
+
5
+ ```dx
6
+ import .ts
7
+ import rules:recommended
8
+
9
+ rule es-eqeqeq error
10
+ rule es-no-floating-promises
11
+ ```
12
+
13
+ ```
14
+ $ dxlint
15
+ warn: Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator. [no-floating-promises]
16
+ --> src/save.ts:4:3
17
+ |
18
+ 4 | writeFile(path, data);
19
+ | ^^^^^^^^^^^^^^^^^^^^^^
20
+ ```
21
+
22
+ ## Why
23
+
24
+ - **Fast.** On a 2,000-file TypeScript codebase, on one core, a full run takes under half as long as ESLint, a cached run a fifth, in about a third of the memory.
25
+ - **Your ESLint rules.** 99.4% of ESLint's and typescript-eslint's own rule test cases give the same result. Type-aware rules read your `tsconfig.json` without running TypeScript.
26
+ - **A cache you can trust.** `.dxcache` records everything a file's result depended on, other files included, so an edit re-checks exactly the files it affects.
27
+ - **Rules are code you own.** Built-in rules are `.dx` files: override one, write your own in a few lines, or describe a whole new language.
28
+
29
+ ## Getting started
30
+
31
+ ```sh
32
+ npm install --save-dev @inthedark/dxlint
33
+ ```
34
+
35
+ Put a `.dx` at your project root:
36
+
37
+ ```dx
38
+ import .ts
39
+ import rules:recommended
40
+
41
+ ignore "dist" "src/generated/**"
42
+ ```
43
+
44
+ | command | |
45
+ | --- | --- |
46
+ | `dxlint [paths]` | lint the project (respects `.gitignore`) |
47
+ | `dxlint --fix` | apply fixes |
48
+ | `dxlint rules` | list every rule with its options |
49
+ | `dxlint describe <name>` | explain a rule, option or anything else in the config |
50
+
51
+ Exit code 1 means errors were found, 2 means the config is broken. Add `.dxcache` to `.gitignore`.
52
+
53
+ Next: [docs/basic.md](docs/basic.md) and [the rule list](docs/rules/README.md).
54
+
55
+ ## The language
56
+
57
+ A rule is a few lines of `.dx`: where to look, when it is wrong, and optionally the fix.
58
+
59
+ ```dx
60
+ import .ts
61
+
62
+ in ts_call.callee rule no-alert-calls error "use the notification service instead of {text}" {
63
+ when text == "alert"
64
+ }
65
+ ```
66
+
67
+ [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
+
69
+ ## Editors
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
74
+
75
+ One core (`--jobs 1`, both pinned to the same core, wall time, measured in one session), wayward (2,094 TypeScript files, its full ESLint config ported, type-aware rules included):
76
+
77
+ | | ESLint | dxlint |
78
+ | --- | --- | --- |
79
+ | first run | 164 s | 72 s |
80
+ | cached run, nothing changed | 4.4 s | 0.8 s |
81
+ | peak memory (working set) | 2.0 GB | 0.7 GB |
82
+
83
+ Note: 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
+
85
+ By default dxlint uses every core.
package/bin/dxlint ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ // Runs the dxlint binary for this platform. It finds its library (std/,
3
+ // rules/) in the nearest directory above it that holds both: this package.
4
+ const { spawnSync } = require("node:child_process");
5
+ const path = require("node:path");
6
+
7
+ const binary = path.join(__dirname, `dxlint-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
8
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: true });
9
+ if (result.error) {
10
+ process.stderr.write(result.error.code === "ENOENT"
11
+ ? `dxlint: no binary for ${process.platform}-${process.arch} (expected ${binary})\n`
12
+ : `dxlint: ${result.error.message}\n`);
13
+ process.exit(2);
14
+ }
15
+ process.exit(result.status ?? 1);
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@inthedark/dxlint",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Fast linter and fixer for TypeScript, JavaScript, Rust and more, with ESLint-compatible rules written in .dx",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ErisInTheDark/dxlint.git",
9
+ "directory": "package"
10
+ },
11
+ "homepage": "https://github.com/ErisInTheDark/dxlint#readme",
12
+ "keywords": [
13
+ "lint",
14
+ "linter",
15
+ "eslint",
16
+ "typescript",
17
+ "formatter"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "os": [
26
+ "win32",
27
+ "linux"
28
+ ],
29
+ "cpu": [
30
+ "x64"
31
+ ],
32
+ "bin": {
33
+ "dxlint": "bin/dxlint"
34
+ },
35
+ "files": [
36
+ "bin",
37
+ "std",
38
+ "rules",
39
+ "README.md",
40
+ "LICENSE"
41
+ ]
42
+ }
@@ -0,0 +1,34 @@
1
+ # rules:conventions: one consistent way to write things. Turns on every such
2
+ # rule of the imported languages, at its defaults.
3
+
4
+ rule es-adjacent-overload-signatures
5
+ rule es-array-type*
6
+ rule es-ban-tslint-comment
7
+ rule es-class-literal-property-style
8
+ rule es-consistent-generic-constructors
9
+ rule es-consistent-indexed-object-style*
10
+ rule es-consistent-type-definitions
11
+ rule es-consistent-type-imports
12
+ rule es-curly*
13
+ rule es-eqeqeq
14
+ rule es-explicit-function-return-type*
15
+ rule es-explicit-member-accessibility*
16
+ rule es-explicit-module-boundary-types*
17
+ rule es-no-confusing-non-null-assertion*
18
+ rule es-no-console
19
+ rule es-no-extraneous-class
20
+ rule es-no-inferrable-types*
21
+ rule es-no-unassigned-import
22
+ rule es-no-undef-init
23
+ rule es-no-useless-constructor
24
+ rule es-no-var
25
+ rule es-no-var-requires
26
+ rule es-prefer-const
27
+ rule es-prefer-function-type
28
+ rule es-prefer-namespace-keyword
29
+ rule es-prefer-object-spread
30
+ rule es-prefer-rest-params
31
+ rule es-prefer-spread
32
+ rule es-prefer-template
33
+ rule es-radix
34
+ rule es-triple-slash-reference
@@ -0,0 +1,33 @@
1
+ # rules:correctness: code that is almost certainly wrong. Turns on every
2
+ # such rule of the imported languages, at its defaults; rules of languages
3
+ # not imported are skipped. `rule name off` after the import takes one back.
4
+
5
+ rule es-constructor-super
6
+ rule es-for-direction
7
+ rule es-no-async-promise-executor
8
+ rule es-no-compare-neg-zero
9
+ rule es-no-cond-assign
10
+ rule es-no-constant-condition*
11
+ rule es-no-control-regex
12
+ rule es-no-debugger
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-ex-assign
18
+ rule es-no-fallthrough
19
+ rule es-no-invalid-regexp
20
+ rule es-no-irregular-whitespace
21
+ rule es-no-loss-of-precision
22
+ rule es-no-misleading-character-class*
23
+ rule es-no-self-assign
24
+ rule es-no-sparse-arrays
25
+ rule es-no-unexpected-multiline*
26
+ rule es-no-unsafe-finally*
27
+ rule es-no-unsafe-optional-chaining*
28
+ rule es-no-unused-private-class-members
29
+ rule es-no-unused-vars*
30
+ rule es-no-useless-assignment
31
+ rule es-no-useless-backreference*
32
+ rule es-use-isnan
33
+ rule es-valid-typeof
@@ -0,0 +1,11 @@
1
+ # rules:es-no-semi: semicolon-free JavaScript and TypeScript, on top of
2
+ # rules:format. Statements end without `;`; a line that would continue the
3
+ # previous statement (`(`, `[`, a template) starts with its guard: `;[1].map(f)`.
4
+
5
+ rule es-semi {
6
+ set mode "never"
7
+ set beforeStatementContinuationChars "always"
8
+ }
9
+ rule es-semi-style {
10
+ set style "first"
11
+ }
@@ -0,0 +1,49 @@
1
+ # rules:format: layout and spacing, as eslint's and @stylistic's defaults
2
+ # lay code out (and topiary's for Rust). Turns on every such rule of the
3
+ # imported languages; rules whose port cannot follow the upstream default
4
+ # yet are left out (comma-dangle, object-curly-spacing, arrow-parens,
5
+ # dot-location, quote-props, operator-linebreak, one-var,
6
+ # generator-star-spacing, lines-between-class-members,
7
+ # padding-line-between-statements).
8
+
9
+ rule es-array-bracket-spacing
10
+ rule es-arrow-spacing*
11
+ rule es-block-spacing*
12
+ rule es-brace-style* {
13
+ set style "1tbs"
14
+ }
15
+ rule es-check-alignment*
16
+ rule es-comma-spacing*
17
+ rule es-comma-style
18
+ rule es-computed-property-spacing
19
+ rule shared-eol-last
20
+ rule es-key-spacing
21
+ rule es-keyword-spacing*
22
+ rule es-member-delimiter-style* {
23
+ set delimiter "semi"
24
+ }
25
+ rule es-new-parens
26
+ rule es-no-floating-decimal*
27
+ rule es-no-mixed-operators*
28
+ rule es-no-multi-spaces
29
+ rule es-no-multiple-empty-lines
30
+ rule es-no-whitespace-before-property
31
+ rule es-padded-blocks:always-top
32
+ rule es-padded-blocks:always-bottom
33
+ rule es-quotes* {
34
+ set style "double"
35
+ }
36
+ rule es-rest-spread-spacing
37
+ rule es-semi
38
+ rule es-semi-spacing*
39
+ rule es-space-before-blocks
40
+ rule es-space-before-function-paren*
41
+ rule es-space-in-parens
42
+ rule es-space-infix-ops
43
+ rule es-spaced-comment*
44
+ rule es-template-curly-spacing
45
+ rule es-template-tag-spacing
46
+ rule es-type-annotation-spacing
47
+ rule es-yield-star-spacing
48
+
49
+ rule rs-*
@@ -0,0 +1,51 @@
1
+ # rules:recommended: the rules eslint and typescript-eslint recommend
2
+ # without type information, as far as dxlint has them.
3
+
4
+ rule es-constructor-super
5
+ rule es-for-direction
6
+ rule es-no-async-promise-executor
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
@@ -0,0 +1,31 @@
1
+ # rules:suspicious: code that is likely a mistake, or does nothing. Turns on
2
+ # every such rule of the imported languages, at its defaults.
3
+
4
+ rule es-no-caller
5
+ rule es-no-delete-var
6
+ rule es-no-empty-interface
7
+ rule es-no-empty-static-block
8
+ rule es-no-eval*
9
+ rule es-no-extra-bind
10
+ rule es-no-extra-boolean-cast*
11
+ rule es-no-global-assign
12
+ rule es-no-misused-new*
13
+ rule es-no-new-func
14
+ rule es-no-new-wrappers
15
+ rule es-no-nonoctal-decimal-escape
16
+ rule es-no-octal
17
+ rule es-no-regex-spaces*
18
+ rule es-no-require-imports
19
+ rule es-no-sequences
20
+ rule es-no-shadow-restricted-names
21
+ rule es-no-template-curly-in-string
22
+ rule es-no-throw-literal
23
+ rule es-no-unsafe-function-type
24
+ rule es-no-unused-expressions
25
+ rule es-no-unused-imports
26
+ rule es-no-unused-labels
27
+ rule es-no-useless-catch*
28
+ rule es-no-useless-escape*
29
+ rule es-no-with
30
+ rule es-no-wrapper-object-types
31
+ rule es-require-yield
package/rules/types.dx ADDED
@@ -0,0 +1,21 @@
1
+ # rules:types: rules that read declared types (dxlint's own type evaluator:
2
+ # no TypeScript needed). Turns on every such rule of the imported languages,
3
+ # at its defaults.
4
+
5
+ rule es-await-thenable*
6
+ rule es-no-deprecated
7
+ rule es-no-floating-promises
8
+ rule es-no-for-in-array
9
+ rule es-no-misused-promises
10
+ rule es-no-unnecessary-boolean-literal-compare
11
+ rule es-no-unnecessary-template-expression
12
+ rule es-no-unnecessary-type-arguments
13
+ rule es-no-unsafe-unary-minus
14
+ rule es-unbound-method
15
+ rule es-prefer-find*
16
+ rule es-prefer-includes
17
+ rule es-prefer-optional-chain
18
+ rule es-prefer-readonly*
19
+ rule es-prefer-string-starts-ends-with*
20
+ rule es-restrict-plus-operands*
21
+ rule es-restrict-template-expressions
package/std/c.dx ADDED
@@ -0,0 +1,23 @@
1
+ # std/c: the C family (C, C++, Java, C#, Go, Kotlin, Swift, Scala, Dart).
2
+ # Close enough for structure: // and /* */ comments, "strings", 'chars',
3
+ # `raw` (Go) and """text blocks""".
4
+
5
+ import .core
6
+
7
+ lang c "*.c" "*.h" "*.cc" "*.cpp" "*.cxx" "*.hpp" "*.hh" "*.java" "*.cs" "*.go" "*.kt" "*.kts" "*.swift" "*.scala" "*.dart" {
8
+ match parentheses
9
+ match brackets
10
+ match braces
11
+ }
12
+
13
+ group c_code .c, parentheses, brackets, braces
14
+
15
+ in c_code {
16
+ match c_line_comment /\/\// until /$/
17
+ match c_block_comment /\/\*/ until /\*\//
18
+ match c_text_block /"""/ until /"""/
19
+ match c_string /"/ until /"|$/
20
+ match c_char /'(?:\\.[^'\n]{0,8}|[^\\'\n])'/
21
+ match c_raw_string /`/ until /`/
22
+ }
23
+ in c_string, c_text_block match c_escape /\\(?:.|\n)/
@@ -0,0 +1,51 @@
1
+ # Shared line structure and hygiene; syntax owners supply comment/raw adapters.
2
+ @macro core_line_pattern /[^\n\r\u{2028}\u{2029}]*(?:\r\n|[\n\r\u{2028}\u{2029}])|[^\n\r\u{2028}\u{2029}]+/
3
+ @macro core_line_comment_pattern /\/\/[^\n\r\u{2028}\u{2029}]*/
4
+ @macro core_block_comment_pattern /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//
5
+ @macro core_html_comment_pattern /<!--/ until /-->/
6
+
7
+ define {
8
+ match core_line @core_line_pattern
9
+ match core_line_comment @core_line_comment_pattern
10
+ match core_block_comment @core_block_comment_pattern
11
+ match core_html_comment @core_html_comment_pattern
12
+ group core_comment core_line_comment, core_block_comment, core_html_comment
13
+ in .* layer lines match core_line
14
+
15
+ in .* layer lines match core_file_tail /[^\n]\z/
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"
18
+ when mode == "always"
19
+ report at end_offset
20
+ fix as text "\n"
21
+ }
22
+ in .* layer lines match core_final_newlines /(?:\r?\n)+\z/
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"
25
+ when mode == "never"
26
+ report at { start: end_offset - (if ends_with(text, "\r\n") then 2 else 1), end: end_offset }
27
+ fix as ""
28
+ }
29
+
30
+ in core_line match core_trailing_spaces /[ \t\u{00a0}\u{2000}-\u{200b}\u{3000}]+(?=[\r\n\u{2028}\u{2029}]|\z)/
31
+ in core_trailing_spaces let core_raw_space false
32
+ in core_trailing_spaces rule shared-no-trailing-spaces warn "Trailing spaces not allowed." {
33
+ option skipBlankLines boolean = false "ignore whitespace-only lines"
34
+ option ignoreComments boolean = false "ignore comment lines"
35
+ when !(skipBlankLines && re_test(parent.text, /^[ \t\u{00a0}\u{2000}-\u{200b}\u{3000}]*(?:\r\n|[\r\n\u{2028}\u{2029}])?\z/))
36
+ when !(ignoreComments && (starts_with(parent.text, "#!") || {
37
+ value overlapping(core_comment)
38
+ any (comment) comment is core_line_comment || position(comment.end_offset).js_line > position(offset).js_line
39
+ }))
40
+ when !core_raw_space
41
+ fix as ""
42
+ }
43
+
44
+ in core_line match core_line_break /\r\n|[\n\r\u{2028}\u{2029}]/
45
+ in core_line_break rule shared-linebreak-style {
46
+ option mode "unix" | "windows" = "unix"
47
+ when mode == "unix" && text != "\n" || mode == "windows" && text != "\r\n"
48
+ fix as if mode == "unix" then "\n" else "\r\n"
49
+ warn if mode == "unix" then "Expected linebreaks to be 'LF' but found 'CRLF'." else "Expected linebreaks to be 'CRLF' but found 'LF'."
50
+ }
51
+ }
@@ -0,0 +1,76 @@
1
+ # List policy, shared by native and pattern syntax adapters.
2
+ define {
3
+ fn core_list_gap_parts(source, from, to, comments) = {
4
+ value comments
5
+ filter (comment) comment.offset >= from && comment.end_offset <= to
6
+ fold ({ cursor: from, text: "" }) (state, comment) {
7
+ cursor: comment.end_offset, text: state.text byte_slice(source, state.cursor, comment.offset),
8
+ }
9
+ }
10
+ fn core_list_gap_text(source, to, parts) = parts.text byte_slice(source, parts.cursor, to)
11
+ fn core_list_site(source, context, mode, before, after, comments) = {
12
+ kind: context.kind, brackets: context.brackets, count: context.count,
13
+ single: context.single, node_single: context.node_single.nonempty ?? context.single,
14
+ first_broken: context.first_broken, empty_comments: context.empty_comments,
15
+ mode: mode, offset: before.end, end: after.start, prev: before.text, next: after.text,
16
+ comments: any(comments, comment => comment.offset >= before.end && comment.end_offset <= after.start),
17
+ spaced: {
18
+ value source
19
+ parts: core_list_gap_parts before.end after.start comments
20
+ value core_list_gap_text(source, after.start, parts)
21
+ re_test /\s/
22
+ },
23
+ broken: { value source; byte_slice before.end after.start; re_test /[\n\r\u{2028}\u{2029}]/ },
24
+ }
25
+ fn core_list_violation(info, by_node, by_bracket, empty, single, multi) =
26
+ !(by_node == "off" || by_node == null && by_bracket == "off")
27
+ && !(info.count == 0 && (by_node.empty.nonempty ?? by_bracket.empty.nonempty ?? empty) == "ignore")
28
+ && (when {
29
+ info.single && info.count <= (by_node.singleLine.maxItems.nonempty ?? by_bracket.singleLine.maxItems.nonempty ?? single.maxItems.nonempty ?? 1000000000) then
30
+ info.mode == "spacing" && (if info.count == 0 then (by_node.empty.nonempty ?? by_bracket.empty.nonempty ?? empty) == "always"
31
+ else (by_node.singleLine.spacing.nonempty ?? by_bracket.singleLine.spacing.nonempty ?? if info.brackets == "{{}}" && by_bracket != "off" then "always" else single.spacing.nonempty ?? "never") == "always") != info.spaced
32
+ info.count == 0 then
33
+ info.mode == "empty_wrapping"
34
+ && (info.empty_comments || (by_node.multiLine.minItems.nonempty ?? by_bracket.multiLine.minItems.nonempty ?? multi.minItems.nonempty ?? 0) != 0)
35
+ && info.empty_comments != info.broken
36
+ else then info.mode == "wrapping"
37
+ && (if info.node_single then info.count > (by_node.singleLine.maxItems.nonempty ?? by_bracket.singleLine.maxItems.nonempty ?? single.maxItems.nonempty ?? 1000000000)
38
+ else info.count >= (by_node.multiLine.minItems.nonempty ?? by_bracket.multiLine.minItems.nonempty ?? multi.minItems.nonempty ?? 0) && info.first_broken) != info.broken
39
+ })
40
+
41
+ fn core_list_fix_text(info, empty, overrides) =
42
+ when {
43
+ info.mode == "spacing" then if info.spaced then "" else " "
44
+ !info.broken then "\n"
45
+ info.mode == "empty_wrapping" then {
46
+ value by_node: { value overrides; get info.kind }
47
+ value by_bracket: { value overrides; get info.brackets }
48
+ value if (by_node.empty.nonempty ?? by_bracket.empty.nonempty ?? empty) == "always" then " " else ""
49
+ }
50
+ info.count != 1 && (info.kind == "TSInterfaceBody" || info.kind == "TSTypeLiteral") && !re_test(info.prev, /[,;]$/) then ","
51
+ else then ""
52
+ }
53
+
54
+ group core_list
55
+ in core_list rule es-list-style {
56
+ option empty "ignore" | "always" | "never" = "ignore" "empty bracket spacing"
57
+ option singleLine { spacing?: "always" | "never"; maxItems?: number } = { spacing: "never" } "single-line lists"
58
+ option multiLine { minItems?: number } = { minItems: 0 } "multiline lists"
59
+ option overrides { [key: string]: "off" | { empty?: "ignore" | "always" | "never"; singleLine?: { spacing?: "always" | "never"; maxItems?: number }; multiLine?: { minItems?: number } } } = { "{}": { singleLine: { spacing: "always" } } } "bracket and node type overrides"
60
+ each info in core_list_layout {
61
+ when {
62
+ value overrides
63
+ by_node: get info.kind
64
+ value overrides
65
+ by_bracket: get info.brackets
66
+ value core_list_violation(info, by_node, by_bracket, empty, singleLine, multiLine)
67
+ }
68
+ report at info.offset
69
+ fix at {
70
+ start: if info.mode == "wrapping" && !info.broken then info.end else info.offset,
71
+ end: if info.mode == "spacing" && !info.spaced then info.offset else info.end,
72
+ } if !info.comments as core_list_fix_text(info, empty, overrides)
73
+ warn (if info.mode == "spacing" then (if !info.spaced then "Should have space between '" else "Should not have space(s) between '") else (if !info.broken then "Should have line break between '" else "Should not have line break(s) between '")) info.prev "' and '" info.next "'"
74
+ }
75
+ }
76
+ }
package/std/core.dx ADDED
@@ -0,0 +1,30 @@
1
+ # .core: building blocks shared by every language (each imports it).
2
+ #
3
+ # Brackets are layers whose `until` middle lets their children eat nested
4
+ # content, so `(a, f(")"))` closes at the right parenthesis. Languages attach
5
+ # the brackets to their root and add their own strings and comments to them:
6
+ #
7
+ # in .mylang match parentheses
8
+ # in .mylang, parentheses, brackets, braces match my_string /"/ until /"/
9
+
10
+ match parentheses /\(/ until /\)/
11
+ match brackets /\[/ until /\]/
12
+ match braces /\{/ until /\}/
13
+ in parentheses, brackets, braces {
14
+ match parentheses
15
+ match brackets
16
+ match braces
17
+ }
18
+
19
+ match whitespace /[ \t]+/
20
+ match space /\s+/
21
+ match identifier /\b[A-Za-z_]\w*/
22
+ match number /\b\d[\d_]*(?:\.\d+)?/
23
+
24
+ # The line break this file uses, for fixes that add lines.
25
+ @macro newline (if contains(source, "\r\n") then "\r\n" else "\n")
26
+
27
+ # Language-neutral hygiene rules, defined (off) for every language.
28
+ import .whitespace
29
+ import .core/lines
30
+ import .core/lists
package/std/css.dx ADDED
@@ -0,0 +1,17 @@
1
+ # .css: textual CSS structure; pattern layers, not a full validator.
2
+
3
+ import .core
4
+
5
+ lang css "*.css" {
6
+ match braces
7
+ match brackets
8
+ match parentheses
9
+ }
10
+
11
+ group css_code .css, braces, brackets, parentheses
12
+ in css_code {
13
+ match css_comment like core_block_comment @core_block_comment_pattern
14
+ match css_string /"/ until /"/
15
+ match css_single_string /'/ until /'/
16
+ }
17
+ in css_string, css_single_string match css_escape /\\(?:\r\n|[\s\S])/
package/std/dx.dx ADDED
@@ -0,0 +1,31 @@
1
+ # .dx: the structure of .dx files themselves (config files named
2
+ # `.dx` included), so dxlint can lint its own rules.
3
+
4
+ import .core
5
+
6
+ lang dx "*.dx" ".dx" {
7
+ match parentheses
8
+ match brackets
9
+ match braces
10
+ }
11
+
12
+ group dx_code .dx, parentheses, brackets, braces
13
+
14
+ in dx_code {
15
+ match dx_comment /#/ until /$/
16
+ # Longer than `""` at the same spot, so it wins.
17
+ match dx_block_string /"""/ until /"""/
18
+ match dx_string /"/ until /"/
19
+ match dx_single_string /'/ until /'/
20
+ }
21
+ in dx_string, dx_single_string, dx_block_string match dx_escape /\\(?:.|\n)/
22
+ # `import some/path`: a bare path, not a regex.
23
+ in dx_code match dx_import_path /(?<=\bimport[ \t]+)[^\s#"']+/
24
+
25
+ # Regex literals: `/` never means division in dxlint.
26
+ in dx_code match dx_regex /\// until /\/|$/ {
27
+ match dx_regex_escape /\\./
28
+ match dx_regex_class /\[/ until /\]/ {
29
+ match dx_regex_escape
30
+ }
31
+ }