@commonplaces/oxlint-plugin 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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +130 -2
  3. package/dist/alchemy.d.ts +2 -0
  4. package/dist/alchemy.js +196 -0
  5. package/dist/anti-slop/effect/index.d.ts +3 -0
  6. package/dist/anti-slop/effect/index.js +10 -0
  7. package/dist/anti-slop/effect/rules/no-service-constructor-imports.d.ts +2 -0
  8. package/dist/anti-slop/effect/rules/no-service-constructor-imports.js +45 -0
  9. package/dist/anti-slop/index.d.ts +3 -0
  10. package/dist/anti-slop/index.js +38 -0
  11. package/dist/anti-slop/rules/no-chained-type-assertions.d.ts +2 -0
  12. package/dist/anti-slop/rules/no-chained-type-assertions.js +57 -0
  13. package/dist/anti-slop/rules/no-conditional-empty-object-spread.d.ts +2 -0
  14. package/dist/anti-slop/rules/no-conditional-empty-object-spread.js +36 -0
  15. package/dist/anti-slop/rules/no-known-value-widening.d.ts +2 -0
  16. package/dist/anti-slop/rules/no-known-value-widening.js +171 -0
  17. package/dist/anti-slop/rules/no-module-mocking.d.ts +2 -0
  18. package/dist/anti-slop/rules/no-module-mocking.js +73 -0
  19. package/dist/anti-slop/rules/no-object-parameters.d.ts +2 -0
  20. package/dist/anti-slop/rules/no-object-parameters.js +86 -0
  21. package/dist/anti-slop/rules/no-reflect-apply.d.ts +2 -0
  22. package/dist/anti-slop/rules/no-reflect-apply.js +25 -0
  23. package/dist/anti-slop/rules/no-reflect-get.d.ts +2 -0
  24. package/dist/anti-slop/rules/no-reflect-get.js +25 -0
  25. package/dist/anti-slop/rules/no-runtime-typeof.d.ts +2 -0
  26. package/dist/anti-slop/rules/no-runtime-typeof.js +47 -0
  27. package/dist/anti-slop/rules/no-shape-in-symbol-names.d.ts +2 -0
  28. package/dist/anti-slop/rules/no-shape-in-symbol-names.js +33 -0
  29. package/dist/anti-slop/rules/no-unknown-parameters.d.ts +2 -0
  30. package/dist/anti-slop/rules/no-unknown-parameters.js +69 -0
  31. package/dist/anti-slop/rules/no-unknown-returns.d.ts +2 -0
  32. package/dist/anti-slop/rules/no-unknown-returns.js +77 -0
  33. package/dist/anti-slop/rules/no-unknown-type-aliases.d.ts +2 -0
  34. package/dist/anti-slop/rules/no-unknown-type-aliases.js +58 -0
  35. package/dist/anti-slop/rules/no-unsafe-dictionary-type.d.ts +2 -0
  36. package/dist/anti-slop/rules/no-unsafe-dictionary-type.js +111 -0
  37. package/dist/anti-slop/rules/no-widen-then-assert.d.ts +2 -0
  38. package/dist/anti-slop/rules/no-widen-then-assert.js +255 -0
  39. package/dist/anti-slop/rules/require-safety-comment-for-type-assertion.d.ts +2 -0
  40. package/dist/anti-slop/rules/require-safety-comment-for-type-assertion.js +51 -0
  41. package/dist/anti-slop/shared/dictionary-types.d.ts +21 -0
  42. package/dist/anti-slop/shared/dictionary-types.js +374 -0
  43. package/dist/anti-slop/shared/lexical-type-parameters.d.ts +3 -0
  44. package/dist/anti-slop/shared/lexical-type-parameters.js +25 -0
  45. package/dist/anti-slop/shared/reflect-method.d.ts +3 -0
  46. package/dist/anti-slop/shared/reflect-method.js +24 -0
  47. package/dist/bun.d.ts +9 -0
  48. package/dist/bun.js +30 -0
  49. package/dist/effect.d.ts +17 -0
  50. package/dist/effect.js +352 -0
  51. package/dist/index.d.ts +57 -0
  52. package/dist/index.js +62 -0
  53. package/dist/package.d.ts +9 -0
  54. package/dist/package.js +50 -0
  55. package/dist/strict-effect.d.ts +2 -0
  56. package/dist/strict-effect.js +2381 -0
  57. package/dist/syntax.d.ts +5 -0
  58. package/dist/syntax.js +26 -0
  59. package/package.json +77 -4
@@ -0,0 +1,5 @@
1
+ import type { Context, ESTree, Scope, Variable } from "@oxlint/plugins";
2
+ import { Option } from "effect";
3
+ export declare const propertyName: (node: ESTree.Node) => Option.Option<string>;
4
+ export declare const variableInScope: (scope: Scope, name: string) => Option.Option<Variable>;
5
+ export declare const childNodes: (context: Context, node: ESTree.Node) => readonly ESTree.Node[];
package/dist/syntax.js ADDED
@@ -0,0 +1,26 @@
1
+ import { Array, Option, Predicate, Record, Schema } from "effect";
2
+ export const propertyName = (node) => {
3
+ if (node.type === "Identifier")
4
+ return Option.some(node.name);
5
+ if (node.type === "Literal" && Predicate.isString(node.value))
6
+ return Option.some(node.value);
7
+ return Option.none();
8
+ };
9
+ export const variableInScope = (scope, name) => Array.findFirst(scope.variables, (variable) => variable.name === name).pipe(Option.orElse(() => Option.fromNullishOr(scope.upper).pipe(Option.flatMap((upper) => variableInScope(upper, name)))));
10
+ const nodeRecord = Schema.is(Schema.Record(Schema.String, Schema.Unknown));
11
+ // This adapter only receives Oxlint's parsed tree and its declared child keys.
12
+ // Oxlint owns the Node contract; the check selects nodes from nullable child slots.
13
+ const HostNode = Schema.declare((value) => nodeRecord(value) && Predicate.isString(value.type));
14
+ const isHostNode = Schema.is(HostNode);
15
+ const isChildren = Schema.is(Schema.Array(Schema.NullOr(HostNode)));
16
+ export const childNodes = (context, node) => {
17
+ if (!nodeRecord(node))
18
+ return [];
19
+ return Array.flatMap(Option.getOrElse(Record.get(context.sourceCode.visitorKeys, node.type), () => []), (key) => {
20
+ const value = Record.get(node, key);
21
+ return Option.match(value, {
22
+ onNone: () => [],
23
+ onSome: (child) => isHostNode(child) ? [child] : isChildren(child) ? Array.filter(child, isHostNode) : [],
24
+ });
25
+ });
26
+ };
package/package.json CHANGED
@@ -1,6 +1,79 @@
1
1
  {
2
2
  "name": "@commonplaces/oxlint-plugin",
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": "Shared Oxlint rules for strict Effect TypeScript, Alchemy and repository code.",
5
+ "license": "MIT",
6
+ "author": "Cooper Corbett",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/crcorbett/commonplace-lint.git",
10
+ "directory": "packages/oxlint-plugin"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "type": "module",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./strict-effect": {
25
+ "types": "./dist/strict-effect.d.ts",
26
+ "default": "./dist/strict-effect.js"
27
+ },
28
+ "./effect": {
29
+ "types": "./dist/effect.d.ts",
30
+ "default": "./dist/effect.js"
31
+ },
32
+ "./alchemy": {
33
+ "types": "./dist/alchemy.d.ts",
34
+ "default": "./dist/alchemy.js"
35
+ },
36
+ "./bun": {
37
+ "types": "./dist/bun.d.ts",
38
+ "default": "./dist/bun.js"
39
+ },
40
+ "./package": {
41
+ "types": "./dist/package.d.ts",
42
+ "default": "./dist/package.js"
43
+ },
44
+ "./anti-slop": {
45
+ "types": "./dist/anti-slop/index.d.ts",
46
+ "default": "./dist/anti-slop/index.js"
47
+ },
48
+ "./anti-slop-effect": {
49
+ "types": "./dist/anti-slop/effect/index.d.ts",
50
+ "default": "./dist/anti-slop/effect/index.js"
51
+ }
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "build": "rm -rf ./dist && tsc --build tsconfig.build.json --force",
58
+ "check-types": "tsc -p tsconfig.json --noEmit",
59
+ "test": "vitest run --root ../.. --project lint-package",
60
+ "prepack": "bun run build"
61
+ },
62
+ "dependencies": {
63
+ "@oxlint/plugins": "1.80.0",
64
+ "effect": "4.0.2"
65
+ },
66
+ "devDependencies": {
67
+ "@effect/platform-node": "4.0.2",
68
+ "@effect/vitest": "4.0.2",
69
+ "@types/bun": "1.4.0",
70
+ "typescript": "7.0.2",
71
+ "vitest": "5.0.1"
72
+ },
73
+ "peerDependencies": {
74
+ "oxlint": "1.80.0 || 1.85.0"
75
+ },
76
+ "engines": {
77
+ "node": ">=22.14.0"
78
+ }
79
+ }