@kutur-kit/oxc 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (76) hide show
  1. package/README.md +59 -7
  2. package/dist/effect.d.ts.map +1 -1
  3. package/dist/effect.js +6 -0
  4. package/dist/effect.js.map +1 -1
  5. package/dist/foldkit-stylex/attributes.d.ts +2 -0
  6. package/dist/foldkit-stylex/attributes.d.ts.map +1 -0
  7. package/dist/foldkit-stylex/attributes.js +191 -0
  8. package/dist/foldkit-stylex/attributes.js.map +1 -0
  9. package/dist/foldkit-stylex/components.d.ts +12 -0
  10. package/dist/foldkit-stylex/components.d.ts.map +1 -0
  11. package/dist/foldkit-stylex/components.js +41 -0
  12. package/dist/foldkit-stylex/components.js.map +1 -0
  13. package/dist/foldkit-stylex/condition-key.d.ts +16 -0
  14. package/dist/foldkit-stylex/condition-key.d.ts.map +1 -0
  15. package/dist/foldkit-stylex/condition-key.js +255 -0
  16. package/dist/foldkit-stylex/condition-key.js.map +1 -0
  17. package/dist/foldkit-stylex/hover-gate.d.ts +2 -0
  18. package/dist/foldkit-stylex/hover-gate.d.ts.map +1 -0
  19. package/dist/foldkit-stylex/hover-gate.js +78 -0
  20. package/dist/foldkit-stylex/hover-gate.js.map +1 -0
  21. package/dist/foldkit-stylex/styles.d.ts +2 -0
  22. package/dist/foldkit-stylex/styles.d.ts.map +1 -0
  23. package/dist/foldkit-stylex/styles.js +131 -0
  24. package/dist/foldkit-stylex/styles.js.map +1 -0
  25. package/dist/foldkit-stylex/unstyled-view.d.ts +2 -0
  26. package/dist/foldkit-stylex/unstyled-view.d.ts.map +1 -0
  27. package/dist/foldkit-stylex/unstyled-view.js +94 -0
  28. package/dist/foldkit-stylex/unstyled-view.js.map +1 -0
  29. package/dist/foldkit-stylex/vite.d.ts +2 -0
  30. package/dist/foldkit-stylex/vite.d.ts.map +1 -0
  31. package/dist/foldkit-stylex/vite.js +26 -0
  32. package/dist/foldkit-stylex/vite.js.map +1 -0
  33. package/dist/foldkit-stylex.d.ts +22 -0
  34. package/dist/foldkit-stylex.d.ts.map +1 -0
  35. package/dist/foldkit-stylex.js +26 -0
  36. package/dist/foldkit-stylex.js.map +1 -0
  37. package/dist/foldkit-stylex.json +26 -0
  38. package/dist/plugin.d.ts.map +1 -1
  39. package/dist/plugin.js +16 -0
  40. package/dist/plugin.js.map +1 -1
  41. package/dist/rules/imports.d.ts +37 -0
  42. package/dist/rules/imports.d.ts.map +1 -0
  43. package/dist/rules/imports.js +72 -0
  44. package/dist/rules/imports.js.map +1 -0
  45. package/dist/rules/no-manual-effect-runtime-in-tests.d.ts +2 -0
  46. package/dist/rules/no-manual-effect-runtime-in-tests.d.ts.map +1 -0
  47. package/dist/rules/no-manual-effect-runtime-in-tests.js +74 -0
  48. package/dist/rules/no-manual-effect-runtime-in-tests.js.map +1 -0
  49. package/dist/rules/scope.d.ts +9 -0
  50. package/dist/rules/scope.d.ts.map +1 -0
  51. package/dist/rules/scope.js +15 -0
  52. package/dist/rules/scope.js.map +1 -0
  53. package/dist/rules/self-contained-function.d.ts +2 -0
  54. package/dist/rules/self-contained-function.d.ts.map +1 -0
  55. package/dist/rules/self-contained-function.js +56 -0
  56. package/dist/rules/self-contained-function.js.map +1 -0
  57. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.d.ts.map +1 -1
  58. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.js +17 -1
  59. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.js.map +1 -1
  60. package/package.json +14 -4
  61. package/src/effect.ts +6 -0
  62. package/src/foldkit-stylex/attributes.ts +282 -0
  63. package/src/foldkit-stylex/components.ts +41 -0
  64. package/src/foldkit-stylex/condition-key.ts +321 -0
  65. package/src/foldkit-stylex/hover-gate.ts +96 -0
  66. package/src/foldkit-stylex/styles.ts +170 -0
  67. package/src/foldkit-stylex/unstyled-view.ts +121 -0
  68. package/src/foldkit-stylex/vite.ts +29 -0
  69. package/src/foldkit-stylex.ts +30 -0
  70. package/src/plugin.ts +16 -0
  71. package/src/rules/imports.ts +99 -0
  72. package/src/rules/no-manual-effect-runtime-in-tests.ts +99 -0
  73. package/src/rules/scope.ts +24 -0
  74. package/src/rules/self-contained-function.ts +76 -0
  75. package/src/vendor/anti-slop/UPSTREAM.md +2 -0
  76. package/src/vendor/anti-slop/rules/no-shape-in-symbol-names.ts +22 -1
@@ -0,0 +1,26 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ const unplugin = "@stylexjs/unplugin";
3
+ export const vite = defineRule({
4
+ meta: {
5
+ type: "problem",
6
+ docs: { description: "Require foldkitStylex() instead of StyleX's own bundler plugin." },
7
+ schema: [],
8
+ messages: {
9
+ helper: "Use foldkitStylex() from @kutur-kit/foldkit-stylex/vite. It compiles this package in dev, SSR and Vitest, where StyleX's own plugin leaves it uncompiled, keeps light-dark() colors valid and fails a build whose client links no CSS.",
10
+ },
11
+ },
12
+ createOnce(context) {
13
+ return {
14
+ ImportDeclaration(node) {
15
+ const source = node.source.value;
16
+ // A type import, such as the plugin's options, loads no plugin.
17
+ if (node.importKind === "type")
18
+ return;
19
+ if (source === unplugin || source.startsWith(`${unplugin}/`)) {
20
+ context.report({ node, messageId: "helper" });
21
+ }
22
+ },
23
+ };
24
+ },
25
+ });
26
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sources":["../../src/foldkit-stylex/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,iEAAiE,EAAE;QACxF,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,MAAM,EACJ,wOAAwO;SAC3O;KACF;IACD,UAAU,CAAC,OAAO;QAChB,OAAO;YACL,iBAAiB,CAAC,IAAI;gBACpB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAEjC,gEAAgE;gBAChE,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM;oBAAE,OAAO;gBAEvC,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;oBAC7D,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ declare const foldkitStylex: {
2
+ jsPlugins: {
3
+ name: string;
4
+ specifier: string;
5
+ }[];
6
+ rules: {
7
+ "kit/foldkit-stylex-attributes": "error";
8
+ "kit/foldkit-stylex-condition-key": "error";
9
+ "kit/foldkit-stylex-hover-gate": "error";
10
+ "kit/foldkit-stylex-styles": "error";
11
+ "kit/foldkit-stylex-unstyled-view": "error";
12
+ "kit/foldkit-stylex-vite": "error";
13
+ "stylex/enforce-extension": "error";
14
+ "stylex/no-legacy-contextual-styles": "error";
15
+ "stylex/no-nonstandard-styles": "error";
16
+ "stylex/no-unused": "error";
17
+ "stylex/valid-shorthands": "error";
18
+ "stylex/valid-styles": "error";
19
+ };
20
+ };
21
+ export default foldkitStylex;
22
+ //# sourceMappingURL=foldkit-stylex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldkit-stylex.d.ts","sources":["../src/foldkit-stylex.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAoBK,CAAC;AAEzB,eAAe,aAAa,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { fileURLToPath } from "node:url";
2
+ const extension = import.meta.url.endsWith(".ts") ? "ts" : "js";
3
+ // `satisfies` keeps each plugin entry an object, which the build's JSON form relies on.
4
+ const foldkitStylex = {
5
+ jsPlugins: [
6
+ // `/base` registers the same plugin with the same specifier, so Oxlint loads it once.
7
+ { name: "kit", specifier: fileURLToPath(new URL(`./plugin.${extension}`, import.meta.url)) },
8
+ { name: "stylex", specifier: fileURLToPath(import.meta.resolve("@stylexjs/eslint-plugin")) },
9
+ ],
10
+ rules: {
11
+ "kit/foldkit-stylex-attributes": "error",
12
+ "kit/foldkit-stylex-condition-key": "error",
13
+ "kit/foldkit-stylex-hover-gate": "error",
14
+ "kit/foldkit-stylex-styles": "error",
15
+ "kit/foldkit-stylex-unstyled-view": "error",
16
+ "kit/foldkit-stylex-vite": "error",
17
+ "stylex/enforce-extension": "error",
18
+ "stylex/no-legacy-contextual-styles": "error",
19
+ "stylex/no-nonstandard-styles": "error",
20
+ "stylex/no-unused": "error",
21
+ "stylex/valid-shorthands": "error",
22
+ "stylex/valid-styles": "error",
23
+ },
24
+ };
25
+ export default foldkitStylex;
26
+ //# sourceMappingURL=foldkit-stylex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldkit-stylex.js","sources":["../src/foldkit-stylex.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAEhE,wFAAwF;AACxF,MAAM,aAAa,GAAG;IACpB,SAAS,EAAE;QACT,sFAAsF;QACtF,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,SAAS,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;QAC5F,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE;KAC7F;IACD,KAAK,EAAE;QACL,+BAA+B,EAAE,OAAO;QACxC,kCAAkC,EAAE,OAAO;QAC3C,+BAA+B,EAAE,OAAO;QACxC,2BAA2B,EAAE,OAAO;QACpC,kCAAkC,EAAE,OAAO;QAC3C,yBAAyB,EAAE,OAAO;QAClC,0BAA0B,EAAE,OAAO;QACnC,oCAAoC,EAAE,OAAO;QAC7C,8BAA8B,EAAE,OAAO;QACvC,kBAAkB,EAAE,OAAO;QAC3B,yBAAyB,EAAE,OAAO;QAClC,qBAAqB,EAAE,OAAO;KAC/B;CACqB,CAAC;AAEzB,eAAe,aAAa,CAAC"}
@@ -0,0 +1,26 @@
1
+ {
2
+ "jsPlugins": [
3
+ {
4
+ "name": "kit",
5
+ "specifier": "./plugin.js"
6
+ },
7
+ {
8
+ "name": "stylex",
9
+ "specifier": "@stylexjs/eslint-plugin"
10
+ }
11
+ ],
12
+ "rules": {
13
+ "kit/foldkit-stylex-attributes": "error",
14
+ "kit/foldkit-stylex-condition-key": "error",
15
+ "kit/foldkit-stylex-hover-gate": "error",
16
+ "kit/foldkit-stylex-styles": "error",
17
+ "kit/foldkit-stylex-unstyled-view": "error",
18
+ "kit/foldkit-stylex-vite": "error",
19
+ "stylex/enforce-extension": "error",
20
+ "stylex/no-legacy-contextual-styles": "error",
21
+ "stylex/no-nonstandard-styles": "error",
22
+ "stylex/no-unused": "error",
23
+ "stylex/valid-shorthands": "error",
24
+ "stylex/valid-styles": "error"
25
+ }
26
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sources":["../src/plugin.ts"],"names":[],"mappings":";AAMA,wBAOG"}
1
+ {"version":3,"file":"plugin.d.ts","sources":["../src/plugin.ts"],"names":[],"mappings":";AAcA,wBAeG"}
package/dist/plugin.js CHANGED
@@ -1,13 +1,29 @@
1
1
  import { definePlugin } from "@oxlint/plugins";
2
+ import { attributes } from "./foldkit-stylex/attributes.js";
3
+ import { conditionKey } from "./foldkit-stylex/condition-key.js";
4
+ import { hoverGate } from "./foldkit-stylex/hover-gate.js";
5
+ import { styles } from "./foldkit-stylex/styles.js";
6
+ import { unstyledView } from "./foldkit-stylex/unstyled-view.js";
7
+ import { vite } from "./foldkit-stylex/vite.js";
2
8
  import { commentProse } from "./rules/comment-prose.js";
9
+ import { noManualEffectRuntimeInTests } from "./rules/no-manual-effect-runtime-in-tests.js";
3
10
  import { noSuppressionDirectives } from "./rules/no-suppression-directives.js";
4
11
  import { noYieldInIf } from "./rules/no-yield-in-if.js";
12
+ import { selfContainedFunction } from "./rules/self-contained-function.js";
5
13
  export default definePlugin({
6
14
  meta: { name: "@kutur-kit/oxc" },
7
15
  rules: {
8
16
  "comment-prose": commentProse,
17
+ "foldkit-stylex-attributes": attributes,
18
+ "foldkit-stylex-condition-key": conditionKey,
19
+ "foldkit-stylex-hover-gate": hoverGate,
20
+ "foldkit-stylex-styles": styles,
21
+ "foldkit-stylex-unstyled-view": unstyledView,
22
+ "foldkit-stylex-vite": vite,
23
+ "no-manual-effect-runtime-in-tests": noManualEffectRuntimeInTests,
9
24
  "no-suppression-directives": noSuppressionDirectives,
10
25
  "no-yield-in-if": noYieldInIf,
26
+ "self-contained-function": selfContainedFunction,
11
27
  },
12
28
  });
13
29
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;IAChC,KAAK,EAAE;QACL,eAAe,EAAE,YAAY;QAC7B,2BAA2B,E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ers to through an import: the module and the export path inside it. After
4
+ * `import { Popover } from "@foldkit/ui"`, `Popover.view` is `@foldkit/ui` with `Popover.view`.
5
+ */
6
+ export type Imported = Readonly<{
7
+ source: string;
8
+ path: string;
9
+ }>;
10
+ export type Imports = ReadonlyMap<string, Imported>;
11
+ /**
12
+ * The import that each local name binds. Rules recognise calls such as `sx(...)` or
13
+ * `Effect.runSync(...)` by these, so a local function that happens to be called `sx` is not one.
14
+ */
15
+ export declare const importsOf: (program: ESTree.Program) => Imports;
16
+ /**
17
+ * Resolves an identifier, a member chain such as `Ui.Popover.view` or a qualified type name such as
18
+ * `PopoverStyle.Styles` to the import it starts from, or `undefined` for anything else.
19
+ */
20
+ export declare const resolve: (node: ESTree.Node, imports: Imports) => Imported | undefined;
21
+ /** The export path `node` names in `source`, such as `create` for `stylex.create`. */
22
+ export declare const exportOf: (node: ESTree.Node, imports: Imports, source: string) => string | undefined;
23
+ /**
24
+ * The export `imported` names in an Effect module, read from the barrel (`Effect.runSync` from
25
+ * "effect") or the module's own path (`runSync` from "effect/Effect").
26
+ */
27
+ export declare const effectMemberOf: (imported: Imported | undefined, module: string) => string | undefined;
28
+ /** The identifier a member chain such as `tab.tab.attributes` starts from. */
29
+ export declare const rootOf: (node: ESTree.Expression) => ESTree.IdentifierReference | undefined;
30
+ /** A call of a method named `name` on any object, such as `h.Class(...)`. */
31
+ export declare const isMethodCall: (node: ESTree.Node, name: string) => node is ESTree.CallExpression;
32
+ /** A property's key as written, for identifier and string keys. */
33
+ export declare const keyOf: (property: Readonly<{
34
+ computed: boolean;
35
+ key: ESTree.PropertyKey;
36
+ }>) => string | undefined;
37
+ //# sourceMappingURL=imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.d.ts","sources":["../../src/rules/imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElE,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,SAAS,YAAa,MAAM,CAAC,OAAO,KAAG,OAUjD,CAAC;AAYJ;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAU,MAAM,CAAC,IAAI,WAAW,OAAO,KAAG,QAAQ,GAAG,SAexE,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,QAAQ,SAAU,MAAM,CAAC,IAAI,WAAW,OAAO,UAAU,MAAM,uBAI3E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,aAAc,QAAQ,GAAG,SAAS,UAAU,MAAM,uBAM5E,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,MAAM,SAAU,MAAM,CAAC,UAAU,KAAG,MAAM,CAAC,mBAAmB,GAAG,SAI7E,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,YAAY,SAAU,MAAM,CAAC,IAAI,QAAQ,MAAM,KAAG,IAAI,IAAI,MAAM,CAAC,cAK1C,CAAC;AAErC,mEAAmE;AACnE,eAAO,MAAM,KAAK,aAAc,QAAQ,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAA;CAAE,CAAC,uBAMvF,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The import that each local name binds. Rules recognise calls such as `sx(...)` or
3
+ * `Effect.runSync(...)` by these, so a local function that happens to be called `sx` is not one.
4
+ */
5
+ export const importsOf = (program) => new Map(program.body.flatMap((statement) => statement.type === "ImportDeclaration"
6
+ ? statement.specifiers.map((specifier) => [
7
+ specifier.local.name,
8
+ { source: statement.source.value, path: pathOf(specifier) },
9
+ ])
10
+ : []));
11
+ const pathOf = (specifier) => {
12
+ if (specifier.type === "ImportNamespaceSpecifier")
13
+ return "";
14
+ if (specifier.type === "ImportDefaultSpecifier")
15
+ return "default";
16
+ return specifier.imported.type === "Literal" ? specifier.imported.value : specifier.imported.name;
17
+ };
18
+ const join = (path, name) => (path === "" ? name : `${path}.${name}`);
19
+ /**
20
+ * Resolves an identifier, a member chain such as `Ui.Popover.view` or a qualified type name such as
21
+ * `PopoverStyle.Styles` to the import it starts from, or `undefined` for anything else.
22
+ */
23
+ export const resolve = (node, imports) => {
24
+ if (node.type === "Identifier")
25
+ return imports.get(node.name);
26
+ const [object, property] = node.type === "MemberExpression" && !node.computed
27
+ ? [node.object, node.property]
28
+ : node.type === "TSQualifiedName"
29
+ ? [node.left, node.right]
30
+ : [];
31
+ if (object === undefined || property?.type !== "Identifier")
32
+ return undefined;
33
+ const resolved = resolve(object, imports);
34
+ return resolved && { source: resolved.source, path: join(resolved.path, property.name) };
35
+ };
36
+ /** The export path `node` names in `source`, such as `create` for `stylex.create`. */
37
+ export const exportOf = (node, imports, source) => {
38
+ const resolved = resolve(node, imports);
39
+ return resolved?.source === source ? resolved.path : undefined;
40
+ };
41
+ /**
42
+ * The export `imported` names in an Effect module, read from the barrel (`Effect.runSync` from
43
+ * "effect") or the module's own path (`runSync` from "effect/Effect").
44
+ */
45
+ export const effectMemberOf = (imported, module) => {
46
+ if (imported?.source === `effect/${module}`)
47
+ return imported.path;
48
+ return imported?.source === "effect" && imported.path.startsWith(`${module}.`)
49
+ ? imported.path.slice(module.length + 1)
50
+ : undefined;
51
+ };
52
+ /** The identifier a member chain such as `tab.tab.attributes` starts from. */
53
+ export const rootOf = (node) => {
54
+ if (node.type === "Identifier")
55
+ return node;
56
+ return node.type === "MemberExpression" ? rootOf(node.object) : undefined;
57
+ };
58
+ /** A call of a method named `name` on any object, such as `h.Class(...)`. */
59
+ export const isMethodCall = (node, name) => node.type === "CallExpression" &&
60
+ node.callee.type === "MemberExpression" &&
61
+ !node.callee.computed &&
62
+ node.callee.property.type === "Identifier" &&
63
+ node.callee.property.name === name;
64
+ /** A property's key as written, for identifier and string keys. */
65
+ export const keyOf = (property) => {
66
+ if (property.computed)
67
+ return undefined;
68
+ if (property.key.type === "Identifier")
69
+ return property.key.name;
70
+ return property.key.type === "Literal" ? String(property.key.value) : undefined;
71
+ };
72
+ //# sourceMappingURL=imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.js","sources":["../../src/rules/imports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAuB,EAAW,EAAE,CAC5D,IAAI,GAAG,CACL,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CACjC,SAAS,CAAC,IAAI,KAAK,mBAAmB;IACpC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAsB,EAAE,CAAC;QAC1D,SAAS,CAAC,KAAK,CAAC,IAAI;QACpB,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;KAC5D,CAAC;IACJ,CAAC,CAAC,EAAE,CACP,CACF,CAAC;AAEJ,MAAM,MAAM,GAAG,CAAC,SAA4C,EAAE,EAAE;IAC9D,IAAI,SAAS,CAAC,IAAI,KAAK,0BAA0B;QAAE,OAAO,EAAE,CAAC;IAE7D,IAAI,SAAS,CAAC,IAAI,KAAK,wBAAwB;QAAE,OAAO,SAAS,CAAC;IAElE,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;AACpG,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAA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I,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;IAEjE,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const noManualEffectRuntimeInTests: import("@oxlint/plugins").Rule;
2
+ //# sourceMappingURL=no-manual-effect-runtime-in-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-manual-effect-runtime-in-tests.d.ts","sources":["../../src/rules/no-manual-effect-runtime-in-tests.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,4BAA4B,gCAmEvC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { effectMemberOf, importsOf, keyOf, resolve, } from "./imports.js";
3
+ import { variableOf } from "./scope.js";
4
+ // The runners of Effect and of a ManagedRuntime. Effect's `<runner>With` forms take a Context.
5
+ const runners = new Set([
6
+ "runCallback",
7
+ "runFork",
8
+ "runPromise",
9
+ "runPromiseExit",
10
+ "runSync",
11
+ "runSyncExit",
12
+ ]);
13
+ const isEffectRunner = (imported) => runners.has(effectMemberOf(imported, "Effect")?.replace(/With$/, "") ?? "");
14
+ const makesRuntime = (node, imports) => node?.type === "CallExpression" &&
15
+ effectMemberOf(resolve(node.callee, imports), "ManagedRuntime") === "make";
16
+ export const noManualEffectRuntimeInTests = defineRule({
17
+ meta: {
18
+ type: "problem",
19
+ docs: { description: "Disallow running effects by hand in tests." },
20
+ schema: [],
21
+ messages: {
22
+ manualRuntime: "Manual Effect runner `{{runner}}` in a test. It runs the effect on the real clock and outside the test's Layers and scope, so time-based code waits for real time and each test wires its services by hand. Fix: write the test with `it.effect` from `@effect/vitest`, provide services with Layers and control time with `TestClock` from `effect/testing`.",
23
+ },
24
+ },
25
+ createOnce(context) {
26
+ let imports = new Map();
27
+ // `ManagedRuntime.make(...)`, or a variable it is assigned to, where it is declared or later, as
28
+ // in `beforeAll(() => { runtime = ManagedRuntime.make(layer); })`.
29
+ const isRuntime = (node) => {
30
+ if (node?.type !== "Identifier")
31
+ return makesRuntime(node, imports);
32
+ const references = variableOf(context.sourceCode, node)?.references ?? [];
33
+ return references.some(({ writeExpr }) => makesRuntime(writeExpr, imports));
34
+ };
35
+ const report = (node) => context.report({
36
+ node,
37
+ messageId: "manualRuntime",
38
+ data: { runner: context.sourceCode.getText(node) },
39
+ });
40
+ return {
41
+ Program(program) {
42
+ imports = importsOf(program);
43
+ },
44
+ ImportSpecifier(node) {
45
+ if (isEffectRunner(imports.get(node.local.name)))
46
+ report(node.imported);
47
+ },
48
+ // `const { runPromise } = runtime`.
49
+ VariableDeclarator({ id, init }) {
50
+ if (id.type !== "ObjectPattern" || !isRuntime(init))
51
+ return;
52
+ for (const property of id.properties) {
53
+ if (property.type === "Property" && runners.has(keyOf(property) ?? "")) {
54
+ report(property.key);
55
+ }
56
+ }
57
+ },
58
+ MemberExpression(node) {
59
+ if (isEffectRunner(resolve(node, imports))) {
60
+ report(node);
61
+ return;
62
+ }
63
+ const { object, property } = node;
64
+ if (!node.computed &&
65
+ property.type === "Identifier" &&
66
+ runners.has(property.name) &&
67
+ isRuntime(object)) {
68
+ report(node);
69
+ }
70
+ },
71
+ };
72
+ },
73
+ });
74
+ //# sourceMappingURL=no-manual-effect-runtime-in-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-manual-effect-runtime-in-tests.js","sources":["../../src/rules/no-manual-effect-runtime-in-tests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EACL,cAAc,EAGd,SAAS,EACT,KAAK,EACL,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,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,CAAC,QAAQ;oBACd,QAAQ,CAAC,IAAI,KAAK,YAAY;oBAC9B,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC1B,SAAS,CAAC,MAAM,CAAC,EACjB,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ESTree, SourceCode, Variable } from "@oxlint/plugins";
2
+ /**
3
+ * The variable an identifier refers to, from the innermost scope that declares its name, or
4
+ * `undefined` for a global. Rules that follow a value to where it was made, such as a parameter or
5
+ * a `const` initialiser, read the variable's `defs` and `references`, so a same-named binding
6
+ * elsewhere in the file is a different variable.
7
+ */
8
+ export declare const variableOf: (sourceCode: SourceCode, identifier: ESTree.IdentifierReference) => Variable | undefined;
9
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sources":["../../src/rules/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAS,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,UAAU,eACT,UAAU,cACV,MAAM,CAAC,mBAAmB,KACrC,QAAQ,GAAG,SAYb,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The variable an identifier refers to, from the innermost scope that declares its name, or
3
+ * `undefined` for a global. Rules that follow a value to where it was made, such as a parameter or
4
+ * a `const` initialiser, read the variable's `defs` and `references`, so a same-named binding
5
+ * elsewhere in the file is a different variable.
6
+ */
7
+ export const variableOf = (sourceCode, identifier) => {
8
+ for (let scope = sourceCode.getScope(identifier); scope !== null; scope = scope.upper) {
9
+ const variable = scope.set.get(identifier.name);
10
+ if (variable !== undefined)
11
+ return variable;
12
+ }
13
+ return undefined;
14
+ };
15
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sources":["../../src/rules/scope.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,UAAsB,EACtB,UAAsC,EAChB,EAAE;IACxB,KACE,IAAI,KAAK,GAAiB,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzD,KAAK,KAAK,IAAI,EACd,KAAK,GAAG,KAAK,CAAC,KAAK,EACnB,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;IAC9C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const selfContainedFunction: import("@oxlint/plugins").Rule;
2
+ //# sourceMappingURL=self-contained-function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-contained-function.d.ts","sources":["../../src/rules/self-contained-function.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,qBAAqB,gCAuChC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ const isFunction = (node) => node?.type === "FunctionDeclaration" ||
3
+ node?.type === "FunctionExpression" ||
4
+ node?.type === "ArrowFunctionExpression";
5
+ // The functions a module exports where it declares them: `export const f = () => …`,
6
+ // `export function f() {}` and `export default …`.
7
+ const exportedFunctions = (node) => {
8
+ const { declaration } = node;
9
+ if (isFunction(declaration))
10
+ return [declaration];
11
+ if (declaration?.type !== "VariableDeclaration")
12
+ return [];
13
+ return declaration.declarations.flatMap(({ init }) => (isFunction(init) ? [init] : []));
14
+ };
15
+ // `typeof value` and `typeof value.key` in a type, which compile away.
16
+ const inTypeQuery = (node) => node.parent?.type === "TSTypeQuery" ||
17
+ (node.parent?.type === "TSQualifiedName" && inTypeQuery(node.parent));
18
+ // Oxlint runs TS-ESLint's scope manager, which flags a reference in a type position, but the
19
+ // plugin's types leave the flag out. Without it, every reference counts as a value.
20
+ const readsValue = (reference) => (!("isValueReference" in reference) || reference.isValueReference !== false) &&
21
+ !inTypeQuery(reference.identifier);
22
+ export const selfContainedFunction = defineRule({
23
+ meta: {
24
+ type: "problem",
25
+ docs: {
26
+ description: "Disallow exported functions that read the module's bindings, for functions sent to a page as source.",
27
+ },
28
+ schema: [],
29
+ messages: {
30
+ outside: "Playwright sends this function to the page as source, so it cannot reach `{{name}}` outside its body. Move the helper inside the function.",
31
+ },
32
+ },
33
+ createOnce(context) {
34
+ const check = (node) => {
35
+ for (const fn of exportedFunctions(node)) {
36
+ // `through` holds the references the function's scopes leave unresolved: outer bindings
37
+ // and globals. Only the module's own bindings are missing from the page; a function
38
+ // declaration still reaches its own name there.
39
+ for (const reference of context.sourceCode.getScope(fn).through) {
40
+ const variable = reference.resolved;
41
+ if (variable?.scope.type === "module" &&
42
+ !variable.defs.some((definition) => definition.node === fn) &&
43
+ readsValue(reference)) {
44
+ context.report({
45
+ node: reference.identifier,
46
+ messageId: "outside",
47
+ data: { name: reference.identifier.name },
48
+ });
49
+ }
50
+ }
51
+ }
52
+ };
53
+ return { ExportNamedDeclaration: check, ExportDefaultDeclaration: check };
54
+ },
55
+ });
56
+ //# sourceMappingURL=self-contained-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-contained-function.js","sources":["../../src/rules/self-contained-function.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,GAAG,CAAC,IAAoC,EAAwB,EAAE,CAChF,IAAI,EAAE,IAAI,KAAK,qBAAqB;IACpC,IAAI,EAAE,IAAI,KAAK,oBAAoB;IACnC,IAAI,EAAE,IAAI,KAAK,yBAAyB,CAAC;AAE3C,qFAAqF;AACrF,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,CACxB,IAAqE,EACxC,EAAE;IAC/B,MA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ACxF,oFAAoF;gBACpF,gDAAgD;gBAChD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;oBAChE,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;oBAEpC,IACE,QAAQ,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ;wBACjC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,EAAE,CAAC;wBAC3D,UAAU,CAAC,SAAS,CAAC,EACrB,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,SAAS,CAAC,UAAU;4BAC1B,SAAS,EAAE,SAAS;4BACpB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE;yBAC1C,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,CAAC;IAC5E,CAAC;CACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"no-shape-in-symbol-names.d.ts","sources":["../../../../src/vendor/anti-slop/rules/no-shape-in-symbol-names.ts"],"names":[],"mappings":"AAgBA,iGAAiG;AACjG,eAAO,MAAM,gCAAgC,gCA4B3C,CAAC"}
1
+ {"version":3,"file":"no-shape-in-symbol-names.d.ts","sources":["../../../../src/vendor/anti-slop/rules/no-shape-in-symbol-names.ts"],"names":[],"mappings":"AA+BA,iGAAiG;AACjG,eAAO,MAAM,gCAAgC,gCAkC3C,CAAC"}
@@ -10,6 +10,19 @@ function isBorrowedMemberName(node) {
10
10
  return false;
11
11
  return parent.property === node && parent.computed === false;
12
12
  }
13
+ // CSS and SVG properties whose names contain "shape", as StyleX, React and SVG write them.
14
+ const CSS_PROPERTY = /^(?:shape(?:Outside|Margin|ImageThreshold|Rendering)|corner(?:Top|Right|Bottom|Left|Start|End|Block|Inline)*Shape)$/;
15
+ /** Return whether an identifier is a key or attribute that names a CSS or SVG property. */
16
+ function isCssPropertyName(node) {
17
+ const parent = node.parent;
18
+ if (parent === null || !CSS_PROPERTY.test(node.name))
19
+ return false;
20
+ if (parent.type === "JSXAttribute")
21
+ return parent.name === node;
22
+ return ((parent.type === "Property" || parent.type === "TSPropertySignature") &&
23
+ parent.key === node &&
24
+ parent.computed === false);
25
+ }
13
26
  /** Ban the case-insensitive substring "shape" in every JavaScript and TypeScript symbol name. */
14
27
  export const noForbiddenTermInSymbolNamesRule = defineRule({
15
28
  meta: {
@@ -23,8 +36,11 @@ export const noForbiddenTermInSymbolNamesRule = defineRule({
23
36
  },
24
37
  createOnce(context) {
25
38
  const reportForbiddenSymbolName = (node) => {
26
- if (!containsForbiddenSymbolName(node.name) || isBorrowedMemberName(node))
39
+ if (!containsForbiddenSymbolName(node.name) ||
40
+ isBorrowedMemberName(node) ||
41
+ isCssPropertyName(node)) {
27
42
  return;
43
+ }
28
44
  context.report({
29
45
  node,
30
46
  messageId: "forbiddenSymbolName",
@@ -1 +1 @@
1
- {"version":3,"file":"no-shape-in-symbol-names.js","sources":["../../../../src/vendor/anti-slop/rules/no-shape-in-symbol-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAEtC,SAAS,2BAA2B,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAC5D,CAAC;AAED,8FAA8F;AAC9F,SAAS,oBAAoB,CAAC,IAAiB;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB;QAAE,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S,EAAE,qBAAqB;gBAChC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;aAC1B,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,yBAAyB;YACrC,iBAAiB,EAAE,yBAAyB;YAC5C,aAAa,EAAE,yBAAyB;SACzC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kutur-kit/oxc",
3
- "version": "0.1.0-alpha.4",
4
- "description": "Oxlint and Oxfmt presets for TypeScript, with optional Effect rules and a prose check for Markdown.",
3
+ "version": "0.1.0-alpha.6",
4
+ "description": "Oxlint and Oxfmt presets for TypeScript, with optional Effect and @kutur-kit/foldkit-stylex rules and a prose check for Markdown.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,6 +32,10 @@
32
32
  "./anti-slop": {
33
33
  "types": "./dist/anti-slop.d.ts",
34
34
  "default": "./dist/anti-slop.js"
35
+ },
36
+ "./foldkit-stylex": {
37
+ "types": "./dist/foldkit-stylex.d.ts",
38
+ "default": "./dist/foldkit-stylex.js"
35
39
  }
36
40
  },
37
41
  "publishConfig": {
@@ -44,7 +48,9 @@
44
48
  },
45
49
  "devDependencies": {
46
50
  "@effect/tsgo": "0.67.4",
51
+ "@kutur-kit/foldkit-stylex": "0.1.0-alpha.2",
47
52
  "@kutur-kit/tsconfig": "0.1.0-alpha.1",
53
+ "@stylexjs/eslint-plugin": "0.19.1",
48
54
  "@types/node": "26.6.6",
49
55
  "oxfmt": "0.77.0",
50
56
  "oxlint": "1.91.0",
@@ -53,6 +59,7 @@
53
59
  },
54
60
  "peerDependencies": {
55
61
  "@effect/tsgo": "~0.67.4",
62
+ "@stylexjs/eslint-plugin": "~0.19.1",
56
63
  "oxfmt": "~0.77.0",
57
64
  "oxlint": "~1.91.0"
58
65
  },
@@ -60,15 +67,18 @@
60
67
  "@effect/tsgo": {
61
68
  "optional": true
62
69
  },
63
- "oxlint": {
70
+ "@stylexjs/eslint-plugin": {
64
71
  "optional": true
65
72
  },
66
73
  "oxfmt": {
67
74
  "optional": true
75
+ },
76
+ "oxlint": {
77
+ "optional": true
68
78
  }
69
79
  },
70
80
  "scripts": {
71
- "build": "node --input-type=module -e 'import { rmSync } from \"node:fs\"; rmSync(\"dist\", { recursive: true, force: true });' && tsrs -p tsconfig.build.json",
81
+ "build": "node --input-type=module -e 'import { rmSync } from \"node:fs\"; rmSync(\"dist\", { recursive: true, force: true });' && tsrs -p tsconfig.build.json && node scripts/write-json-preset.ts",
72
82
  "lint:package": "publint --pack pnpm --strict",
73
83
  "test": "node --test test/*.test.ts",
74
84
  "typecheck": "effect-tsgo tsrs -p tsconfig.json --noEmit"
package/src/effect.ts CHANGED
@@ -25,6 +25,12 @@ const effect: OxlintConfig = {
25
25
  // Effect's documented form for a service is a class that extends `Context.Service`.
26
26
  "effecttsgo/service-not-as-class": "warn",
27
27
  },
28
+ overrides: [
29
+ {
30
+ files: ["**/*.test.*", "**/*.spec.*", "**/test/**", "**/tests/**"],
31
+ rules: { "kit/no-manual-effect-runtime-in-tests": "error" },
32
+ },
33
+ ],
28
34
  options: { typeAware: true },
29
35
  };
30
36