@timmo001/oxlint-rules 0.3.1 → 0.3.2

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 (25) hide show
  1. package/README.md +2 -1
  2. package/THIRD_PARTY_NOTICES.md +9 -0
  3. package/dist/cli.js +733 -35
  4. package/dist/configs/recommended-effect.js +767 -69
  5. package/dist/configs/recommended.js +535 -30
  6. package/dist/upstream/anti-slop.js +535 -30
  7. package/dist/upstream/effect.js +196 -3
  8. package/package.json +1 -1
  9. package/vendor/anti-slop/src/effect/index.ts +8 -0
  10. package/vendor/anti-slop/src/effect/rules/no-manual-effect-error-tag.ts +52 -0
  11. package/vendor/anti-slop/src/effect/rules/no-manual-tag-comparison.ts +45 -0
  12. package/vendor/anti-slop/src/effect/rules/no-manual-tagged-construction.ts +37 -0
  13. package/vendor/anti-slop/src/effect/rules/prefer-effect-match.ts +54 -0
  14. package/vendor/anti-slop/src/effect/shared/tagged-values.ts +97 -0
  15. package/vendor/anti-slop/src/index.ts +2 -0
  16. package/vendor/anti-slop/src/rules/no-known-value-widening.ts +2 -14
  17. package/vendor/anti-slop/src/rules/no-module-mocking.ts +3 -14
  18. package/vendor/anti-slop/src/rules/require-readable-spacing.ts +47 -0
  19. package/vendor/anti-slop/src/shared/reflect-method.ts +2 -13
  20. package/vendor/anti-slop/src/shared/scope.ts +15 -0
  21. package/vendor/anti-slop/src/vendor/eslint-stylistic/LICENSE +22 -0
  22. package/vendor/anti-slop/src/vendor/eslint-stylistic/UPSTREAM.md +28 -0
  23. package/vendor/anti-slop/src/vendor/eslint-stylistic/padding-line-ast.ts +51 -0
  24. package/vendor/anti-slop/src/vendor/eslint-stylistic/padding-line-between-statements.ts +906 -0
  25. package/vendor/anti-slop/src/vendor/eslint-stylistic/padding-line-options.d.ts +87 -0
@@ -1,17 +1,6 @@
1
- import type { ESTree, Scope, SourceCode, Variable } from "@oxlint/plugins";
1
+ import { resolveVariable } from "./scope.ts";
2
2
 
3
- function resolveVariable(
4
- sourceCode: SourceCode,
5
- identifier: ESTree.IdentifierReference,
6
- ): Variable | null {
7
- let scope: Scope | null = sourceCode.getScope(identifier);
8
- while (scope !== null) {
9
- const variable = scope.set.get(identifier.name);
10
- if (variable !== undefined) return variable;
11
- scope = scope.upper;
12
- }
13
- return null;
14
- }
3
+ import type { ESTree, SourceCode } from "@oxlint/plugins";
15
4
 
16
5
  function isGlobalReflect(sourceCode: SourceCode, expression: ESTree.Expression): boolean {
17
6
  if (expression.type !== "Identifier" || expression.name !== "Reflect") return false;
@@ -0,0 +1,15 @@
1
+ import type { ESTree, Scope, SourceCode, Variable } from "@oxlint/plugins";
2
+
3
+ /** Resolve an identifier to its binding by walking lexical scopes upward. */
4
+ export function resolveVariable(
5
+ sourceCode: SourceCode,
6
+ identifier: ESTree.IdentifierReference,
7
+ ): Variable | null {
8
+ let scope: Scope | null = sourceCode.getScope(identifier);
9
+ while (scope !== null) {
10
+ const variable = scope.set.get(identifier.name);
11
+ if (variable !== undefined) return variable;
12
+ scope = scope.upper;
13
+ }
14
+ return null;
15
+ }
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
4
+ Copyright (c) 2023-PRESENT ESLint Stylistic contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Vendored padding-line-between-statements
2
+
3
+ Source: [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic), commit `435c3ea0fd26a5fef9042c4b36b6e165fbbf8d08`.
4
+
5
+ Copied files:
6
+
7
+ - `packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements.ts`
8
+ - `packages/eslint-plugin/rules/padding-line-between-statements/types.d.ts` → `padding-line-options.d.ts`
9
+ - Root `LICENSE`, retained verbatim. Both OpenJS Foundation and ESLint Stylistic notices apply.
10
+
11
+ The rule is MIT-licensed. Keep `LICENSE` with every redistributed copy, including skill assets. No Stylistic, ESLint, TypeScript-ESLint, or additional parser runtime dependency is required.
12
+
13
+ ## Local adaptations
14
+
15
+ - Replace upstream type aliases with Oxlint's ESTree, context, token/comment, and rule types. Upstream's token type includes comments; Oxlint exposes those separately.
16
+ - Replace `AST_NODE_TYPES` enum members with identical string literals.
17
+ - Guard indexed reads for consuming repositories with `noUncheckedIndexedAccess`. Impossible missing AST/configuration entries raise explicit invariant errors rather than introducing new non-null assertions.
18
+ - Replace the repository-specific `createRule` factory with `createPaddingLineRule(options)`. The anti-slop wrapper supplies typed options directly; it exposes no user configuration options.
19
+ - Implement the small required AST helper surface in `padding-line-ast.ts` using Oxlint's public source-code/token API. `isParenthesized` only needs the one-pair check used to exclude parenthesized directive strings, not the upstream general-purpose overloads.
20
+ - Retain the upstream statement matchers, scope tracking, comment-aware insertion/removal, selector support, and diagnostic text. Upstream naming and non-null assumptions remain localized here to keep future diffs reviewable; the file is not a model for new application code.
21
+
22
+ The opinionated policy lives outside this directory in `../../rules/require-readable-spacing.ts`. It adds spacing without collapsing existing blank lines. Short local bindings, consecutive imports, and adjacent overload signatures/implementation remain grouped. Spacing is syntactic, not an inference of business-logic boundaries.
23
+
24
+ ## Updating and verification
25
+
26
+ Fetch an explicit upstream revision, compare the original rule and types against this revision, and port relevant fixes while retaining the adapters above. Update this record and preserve the license. Run `pnpm check` and `pnpm sync:skill-assets` as required by repository guidance.
27
+
28
+ Focused Oxlint RuleTester cases live in `../../rules/require-readable-spacing.test.ts`; they test exact fixes, JSDoc/trailing comments, same-line statements, semicolon-free code, TypeScript exports/overloads, Effect-style generators, and upstream removal behavior. `../../rules/require-readable-spacing-cli.test.ts` verifies the exported plugin through the native Oxlint CLI on multiple files, including rejection, autofix, and repeated-fix stability. The complete upstream JS/TS test suites have not been ported; this is focused compatibility evidence, not a claim of full upstream conformance.
@@ -0,0 +1,51 @@
1
+ // Local replacements for the upstream helper imports. See UPSTREAM.md.
2
+ import type { ESTree, SourceCode, Token as SyntaxToken, Comment, Location } from "@oxlint/plugins";
3
+
4
+ type Token = SyntaxToken | Comment;
5
+
6
+ /** Line terminators recognized by the upstream padding matcher. */
7
+ export const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
8
+
9
+ /** Test a closing brace without treating comment text as punctuation. */
10
+ export const isClosingBraceToken = (token: Token): boolean =>
11
+ token.type === "Punctuator" && token.value === "}";
12
+
13
+ /** Test a semicolon without treating comment text as punctuation. */
14
+ export const isSemicolonToken = (token: Token): boolean =>
15
+ token.type === "Punctuator" && token.value === ";";
16
+
17
+ /** Filter the optional final semicolon when identifying block-like statements. */
18
+ export const isNotSemicolonToken = (token: Token): boolean => !isSemicolonToken(token);
19
+
20
+ /** Compare token/node boundaries, including attached comments. */
21
+ export const isTokenOnSameLine = (left: { loc: Location }, right: { loc: Location }): boolean =>
22
+ left.loc.end.line === right.loc.start.line;
23
+
24
+ /** Recognize declarations and expressions used by the upstream IIFE matcher. */
25
+ export const isFunction = (node: ESTree.Node): boolean =>
26
+ node.type === "FunctionDeclaration" ||
27
+ node.type === "FunctionExpression" ||
28
+ node.type === "ArrowFunctionExpression";
29
+
30
+ /** Preserve the upstream multiline statement heuristic. */
31
+ export const isSingleLine = (node: ESTree.Node): boolean =>
32
+ node.loc.start.line === node.loc.end.line;
33
+
34
+ /** Unwrap optional chaining before checking IIFE syntax. */
35
+ export const skipChainExpression = (node: ESTree.Node): ESTree.Node =>
36
+ node.type === "ChainExpression" ? node.expression : node;
37
+
38
+ /** Only a program or function-body expression can begin a directive prologue. */
39
+ export const isTopLevelExpressionStatement = (
40
+ node: ESTree.Node,
41
+ ): node is ESTree.ExpressionStatement =>
42
+ node.type === "ExpressionStatement" &&
43
+ (node.parent.type === "Program" ||
44
+ (node.parent.type === "BlockStatement" && isFunction(node.parent.parent)));
45
+
46
+ /** A single wrapping pair suffices to exclude a string from directive syntax. */
47
+ export function isParenthesized(node: ESTree.Node, sourceCode: SourceCode): boolean {
48
+ const before = sourceCode.getTokenBefore(node);
49
+ const after = sourceCode.getTokenAfter(node);
50
+ return before?.value === "(" && after?.value === ")";
51
+ }