@ashstack/lint 0.11.0 → 0.13.0

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 (49) hide show
  1. package/README.md +26 -3
  2. package/dist/lib/ast.js +1 -1
  3. package/dist/lib/destructured-hooks.js +1 -0
  4. package/dist/lib/detect.js +1 -1
  5. package/dist/lib/module.js +1 -1
  6. package/dist/lib/registry.js +1 -1
  7. package/dist/lib/rule-types/react-native.d.ts +92 -4
  8. package/dist/lib/rule-types/react.d.ts +65 -1
  9. package/dist/lib/types.d.ts +32 -0
  10. package/dist/modules.js +1 -1
  11. package/dist/react/rules/query/exhaustive-key.js +1 -0
  12. package/dist/react/rules/query/forward-signal.js +1 -0
  13. package/dist/react/rules/query/index.js +1 -1
  14. package/dist/react/rules/query/no-overridden-callbacks.js +1 -0
  15. package/dist/react/rules/query/optimistic-update-complete.js +1 -0
  16. package/dist/react/rules/query/require-destructured-hooks.js +1 -1
  17. package/dist/react/rules/query/shared.js +1 -0
  18. package/dist/react/rules/react/index.js +1 -1
  19. package/dist/react/rules/react/no-context-provider.js +1 -0
  20. package/dist/react/rules/react/no-use-no-memo.js +1 -0
  21. package/dist/react/rules/react/require-destructured-router.js +1 -0
  22. package/dist/react/rules/react/require-effect-cleanup.js +1 -0
  23. package/dist/react-native/index.d.ts +2 -2
  24. package/dist/react-native/index.js +1 -1
  25. package/dist/react-native/rules/gesture-handler/index.js +1 -0
  26. package/dist/react-native/rules/gesture-handler/modal-needs-root-view.js +1 -0
  27. package/dist/react-native/rules/legend-list/no-inline-render-item-props.js +1 -1
  28. package/dist/react-native/rules/legend-state/dispose-observe.js +1 -0
  29. package/dist/react-native/rules/legend-state/index.js +1 -1
  30. package/dist/react-native/rules/legend-state/no-peek-in-selector.js +1 -1
  31. package/dist/react-native/rules/legend-state/no-untracked-collection-read.js +1 -0
  32. package/dist/react-native/rules/legend-state/shared.js +1 -1
  33. package/dist/react-native/rules/react-native/hoist-stateless-function.js +1 -1
  34. package/dist/react-native/rules/react-native/index.js +1 -1
  35. package/dist/react-native/rules/react-native/no-dynamic-import.js +1 -1
  36. package/dist/react-native/rules/react-native/no-react-lazy.js +1 -0
  37. package/dist/react-native/rules/reanimated/check-finished.js +1 -0
  38. package/dist/react-native/rules/reanimated/gpu-properties-only.js +1 -1
  39. package/dist/react-native/rules/reanimated/index.js +1 -1
  40. package/dist/react-native/rules/reanimated/layout-animation-needs-animated-component.js +1 -0
  41. package/dist/react-native/rules/unistyles/index.js +1 -1
  42. package/dist/react-native/rules/unistyles/no-theme-runtime-args.js +1 -0
  43. package/dist/react-native/rules/worklets/index.js +1 -0
  44. package/dist/react-native/rules/worklets/no-inline-worklet-schedule.js +1 -0
  45. package/dist/react-native/rules/worklets/no-js-timer-schedule.js +1 -0
  46. package/dist/react-native/rules/worklets/no-runtime-in-render.js +1 -0
  47. package/dist/react-native/rules/worklets/no-sync-runtime-call.js +1 -0
  48. package/dist/react-native/rules/worklets/shared.js +1 -0
  49. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ashstack/lint
2
2
 
3
- Strict shared [oxlint](https://oxc.rs) config: <!-- rule-counts -->116 rules on plain TypeScript, 211 with React, 268 on React Native, 82 of them custom-built<!-- /rule-counts -->. Three entries, each containing the one before it: `core()`, `react()`, `react-native()`.
3
+ Strict shared [oxlint](https://oxc.rs) config: <!-- rule-counts -->116 rules on plain TypeScript, 219 with React, 287 on React Native, 101 of them custom-built<!-- /rule-counts -->. Three entries, each containing the one before it: `core()`, `react()`, `react-native()`.
4
4
 
5
5
  Library-specific rules ship only when you depend on that library, so nothing fires about code you don't have.
6
6
 
@@ -75,9 +75,9 @@ diagnostic that the rest are gone.
75
75
 
76
76
  ## Library-specific rules, auto-detected
77
77
 
78
- One module per library: one rule namespace, one toggle. A module turns on when its library is in your `package.json`, searched up to the repo root.
78
+ One module per library: one rule namespace, one toggle. A module turns on when its library is in your `package.json`, searched up to the repo root. `@ashstack/gesture-handler` also needs Gesture Handler 3 or later, read from `node_modules` or, before an install, from the declared range.
79
79
 
80
- `@ashstack/zod` · `@ashstack/query` · `@ashstack/zustand` · `@ashstack/i18n` · `@ashstack/stylex` · `@ashstack/unistyles` · `@ashstack/legend-list` · `@ashstack/legend-state` · `@ashstack/reanimated` · `@ashstack/turbo-image` · `@ashstack/skia` · `@ashstack/keyboard`
80
+ `@ashstack/zod` · `@ashstack/query` · `@ashstack/zustand` · `@ashstack/i18n` · `@ashstack/stylex` · `@ashstack/unistyles` · `@ashstack/legend-list` · `@ashstack/legend-state` · `@ashstack/reanimated` · `@ashstack/turbo-image` · `@ashstack/skia` · `@ashstack/keyboard` · `@ashstack/gesture-handler` · `@ashstack/worklets`
81
81
 
82
82
  Detection only sets the default. Turn any module on or off yourself, whatever your dependencies say:
83
83
 
@@ -87,6 +87,29 @@ reactNative({ unistyles: false, i18n: true });
87
87
 
88
88
  Import bans follow detection only; disable one by rule name.
89
89
 
90
+ ## Adding your own import bans
91
+
92
+ `reactNative()` ships its import bans as one `no-restricted-imports` setting.
93
+ A `no-restricted-imports` entry in your own `rules` block replaces that
94
+ setting rather than adding to it, so every shipped ban silently stops. Pass
95
+ your bans to the entry instead, and they join the shipped ones:
96
+
97
+ ```ts
98
+ reactNative({
99
+ restrictedImports: {
100
+ paths: [{ name: "lodash", message: "Use the standard library." }],
101
+ patterns: [{ group: ["@/legacy/*"], message: "Import from `@/features` instead." }],
102
+ allow: [{ files: ["src/native-host/**"], from: "react-native", importNames: ["Pressable"] }],
103
+ },
104
+ });
105
+ ```
106
+
107
+ `allow` lifts bans in some files only: the listed names from `from`, or every
108
+ ban on `from` when `importNames` is left out. It lifts path bans, not
109
+ `patterns`. Each distinct `files` list becomes one `overrides` entry that
110
+ replaces the setting for those files, so put every lift for a folder under the
111
+ same `files`; where two different globs match one file, the later one wins.
112
+
90
113
  ## Opt-in rules
91
114
 
92
115
  <!-- opt-in -->Off by default, since they need a team decision first: `@ashstack/react/prefer-design-system` and `@ashstack/react/components-tsx-only`.<!-- /opt-in -->
package/dist/lib/ast.js CHANGED
@@ -1 +1 @@
1
- const p=new Set(["parent","loc","range","start","end","type"]),o=(t,e)=>{for(const r of t){const n=findInSubtree(r,e);if(n)return n}return null},i=(t)=>{const e=[];for(const[r,n]of Object.entries(t)){if(p.has(r))continue;if(n!==null&&typeof n==="object")e.push(n)}return e};export const findInSubtree=(t,e)=>{if(t===null||typeof t!=="object")return null;if(Array.isArray(t))return o(t,e);const r=t;if(typeof r.type!=="string")return null;if(e(r))return r;return o(i(r),e)},subtreeHas=(t,e)=>findInSubtree(t,e)!==null,calleeName=(t)=>{if(t?.type!=="CallExpression")return"";const{callee:e}=t;if(e.type==="Identifier")return e.name;if(e.type==="MemberExpression"&&e.property.type==="Identifier")return e.property.name;return""},ancestors=function*(t){let e=t.parent;while(e){yield e;e=e.parent}},enclosingCall=(t,e)=>{for(const r of ancestors(t))if(r.type==="CallExpression"&&e.has(calleeName(r)))return r;return null},closestAncestor=(t,e)=>{for(const r of ancestors(t))if(e.has(r.type))return r;return null},hasAncestor=(t,e)=>{for(const r of ancestors(t))if(e(r))return!0;return!1},isWithin=(t,e)=>{for(const r of ancestors(t))if(r===e)return!0;return!1},crossesFunctionBefore=(t,e,r)=>{for(const n of ancestors(t)){if(n===e)return!1;if(r.has(n.type))return!0}return!1},isMemberCall=(t,e)=>t?.type==="CallExpression"&&t.callee.type==="MemberExpression"&&!t.callee.computed&&t.callee.property.type==="Identifier"&&t.callee.property.name===e,receiverName=(t)=>{if(t?.type!=="CallExpression"||t.callee.type!=="MemberExpression")return null;const{object:e}=t.callee;return e.type==="Identifier"?e.name:null},tagIdentifier=(t)=>{let e=t;while(e?.type==="JSXMemberExpression")e=e.property;if(e?.type==="JSXIdentifier"||e?.type==="Identifier")return e.name;return""},tagPath=(t)=>{if(t?.type==="JSXIdentifier"||t?.type==="Identifier")return t.name;if(t?.type!=="JSXMemberExpression")return"";const e=tagPath(t.object),r=tagPath(t.property);return e===""||r===""?"":`${e}.${r}`};const s=/^(?:Animated|Reanimated)/;export const componentName=(t)=>{const e=tagPath(t),r=e.lastIndexOf(".");if(r!==-1)return s.test(e.slice(0,r))?e.slice(r+1):"";const n=e.replace(s,"");return n===""?e:n},attributeName=(t)=>{if(t.type!=="JSXAttribute")return"";const{name:e}=t;return e.type==="JSXIdentifier"?e.name:e.name.name},importedSpecifiers=(t,e)=>t.type==="ImportDeclaration"&&t.source.value===e?[...t.specifiers]:[],importedNames=(t,e)=>{const r=[];for(const n of importedSpecifiers(t,e)){if(n.type!=="ImportSpecifier")continue;if(n.imported.type!=="Identifier")continue;r.push({imported:n.imported.name,local:n.local.name})}return r},propertyKeyName=(t)=>{if(t.type!=="Property"||t.computed)return"";const{key:e}=t;if(e.type==="Identifier")return e.name;return e.type==="Literal"?String(e.value):""},propertyValue=(t,e)=>{if(t?.type!=="ObjectExpression")return null;for(const r of t.properties)if(r.type==="Property"&&propertyKeyName(r)===e)return r.value;return null},FUNCTION_TYPES=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]),COMPONENT_OR_HOOK=/^(?:[A-Z]|use[A-Z])/,isFunction=(t)=>!!t&&FUNCTION_TYPES.has(t.type),gate=(t,...e)=>e.some((r)=>t.sourceCode.text.includes(r)),optionsOf=(t,e)=>t.options[0]??e,problem=(t,e)=>({...e,meta:{type:"problem",...e.meta,docs:{description:t}}});
1
+ const l=new Set(["parent","loc","range","start","end","type"]),s=(t,e)=>{for(const r of t){const n=findInSubtree(r,e);if(n)return n}return null},a=(t)=>{const e=[];for(const[r,n]of Object.entries(t)){if(l.has(r))continue;if(n!==null&&typeof n==="object")e.push(n)}return e};export const findInSubtree=(t,e)=>{if(t===null||typeof t!=="object")return null;if(Array.isArray(t))return s(t,e);const r=t;if(typeof r.type!=="string")return null;if(e(r))return r;return s(a(r),e)},subtreeHas=(t,e)=>findInSubtree(t,e)!==null,calleeName=(t)=>{if(t?.type!=="CallExpression")return"";const{callee:e}=t;if(e.type==="Identifier")return e.name;if(e.type==="MemberExpression"&&e.property.type==="Identifier")return e.property.name;return""},ancestors=function*(t){let e=t.parent;while(e){yield e;e=e.parent}},enclosingCall=(t,e)=>{for(const r of ancestors(t))if(r.type==="CallExpression"&&e.has(calleeName(r)))return r;return null},closestAncestor=(t,e)=>{for(const r of ancestors(t))if(e.has(r.type))return r;return null},hasAncestor=(t,e)=>{for(const r of ancestors(t))if(e(r))return!0;return!1},isWithin=(t,e)=>{for(const r of ancestors(t))if(r===e)return!0;return!1},crossesFunctionBefore=(t,e,r)=>{for(const n of ancestors(t)){if(n===e)return!1;if(r.has(n.type))return!0}return!1},isMemberCall=(t,e)=>t?.type==="CallExpression"&&t.callee.type==="MemberExpression"&&!t.callee.computed&&t.callee.property.type==="Identifier"&&t.callee.property.name===e,receiverName=(t)=>{if(t?.type!=="CallExpression"||t.callee.type!=="MemberExpression")return null;const{object:e}=t.callee;return e.type==="Identifier"?e.name:null},tagIdentifier=(t)=>{let e=t;while(e?.type==="JSXMemberExpression")e=e.property;if(e?.type==="JSXIdentifier"||e?.type==="Identifier")return e.name;return""},tagPath=(t)=>{if(t?.type==="JSXIdentifier"||t?.type==="Identifier")return t.name;if(t?.type!=="JSXMemberExpression")return"";const e=tagPath(t.object),r=tagPath(t.property);return e===""||r===""?"":`${e}.${r}`};const p=/^(?:Animated|Reanimated)/;export const componentName=(t)=>{const e=tagPath(t),r=e.lastIndexOf(".");if(r!==-1)return p.test(e.slice(0,r))?e.slice(r+1):"";const n=e.replace(p,"");return n===""?e:n},attributeName=(t)=>{if(t.type!=="JSXAttribute")return"";const{name:e}=t;return e.type==="JSXIdentifier"?e.name:e.name.name},importedSpecifiers=(t,e)=>t.type==="ImportDeclaration"&&t.source.value===e?[...t.specifiers]:[],importedNames=(t,e)=>{const r=[];for(const n of importedSpecifiers(t,e)){if(n.type!=="ImportSpecifier")continue;if(n.imported.type!=="Identifier")continue;r.push({imported:n.imported.name,local:n.local.name})}return r},importBinding=(t,e)=>{const r=new Set,n=new Set;return{clear(){r.clear();n.clear()},add(o){for(const i of importedSpecifiers(o,t))if(i.type==="ImportDefaultSpecifier"||i.type==="ImportNamespaceSpecifier")n.add(i.local.name);for(const{imported:i,local:c}of importedNames(o,t))if(i===e)r.add(c)},isCall(o){if(o?.type!=="CallExpression")return!1;if(o.callee.type==="Identifier")return r.has(o.callee.name);return isMemberCall(o,e)&&n.has(receiverName(o)??"")}}},propertyKeyName=(t)=>{if(t.type!=="Property"||t.computed)return"";const{key:e}=t;if(e.type==="Identifier")return e.name;return e.type==="Literal"?String(e.value):""},propertyValue=(t,e)=>{if(t?.type!=="ObjectExpression")return null;for(const r of t.properties)if(r.type==="Property"&&propertyKeyName(r)===e)return r.value;return null},FUNCTION_TYPES=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]),COMPONENT_OR_HOOK=/^(?:[A-Z]|use[A-Z])/,isFunction=(t)=>!!t&&FUNCTION_TYPES.has(t.type),boundFunctionName=(t)=>{if(t.type==="FunctionDeclaration")return t.id?.name??null;const{parent:e}=t;if(e===null||e.type!=="VariableDeclarator"||e.id.type!=="Identifier")return null;return e.id.name},enclosingComponentOrHook=(t)=>{for(const e of ancestors(t)){if(!isFunction(e))continue;const r=boundFunctionName(e);if(r!==null&&COMPONENT_OR_HOOK.test(r))return e}return null},gate=(t,...e)=>e.some((r)=>t.sourceCode.text.includes(r)),optionsOf=(t,e)=>t.options[0]??e,problem=(t,e)=>({...e,meta:{type:"problem",...e.meta,docs:{description:t}}});
@@ -0,0 +1 @@
1
+ import{problem as f}from"./ast.js";export const requireDestructured=(i,s,c)=>f(i,{createOnce(d){const t=new Set,r=[];return{before(){t.clear();r.length=0},ImportDeclaration(e){for(const o of s(e))t.add(o)},VariableDeclarator(e){const{id:o,init:a}=e;if(o.type!=="Identifier"||a?.type!=="CallExpression")return;const{callee:n}=a;if(n.type!=="Identifier"||!/^use[A-Z]/.test(n.name))return;r.push({node:o,hook:n.name})},"Program:exit"(){for(const e of r)if(t.has(e.hook))d.report({node:e.node,message:c(e.hook)})}}}});
@@ -1 +1 @@
1
- import{existsSync as i,readFileSync as p}from"node:fs";import{dirname as a,join as c}from"node:path";const f=(e)=>{try{const n=JSON.parse(p(c(e,"package.json"),"utf8"));return Object.keys({...n.dependencies,...n.devDependencies,...n.peerDependencies})}catch{return[]}},m=(e)=>i(c(e,".git")),o=new Map,u=()=>{const e=process.cwd(),n=o.get(e);if(n)return n;const t=new Set;let r=e;for(;;){for(const d of f(r))t.add(d);if(m(r))break;const s=a(r);if(s===r)break;r=s}o.set(e,t);return t};export const detect=(e,n)=>e??(n===void 0||n.some((t)=>u().has(t)));
1
+ import{existsSync as m,readFileSync as h}from"node:fs";import{dirname as y,join as o}from"node:path";const i=(e)=>{try{return JSON.parse(h(o(e,"package.json"),"utf8"))}catch{return null}},g=(e)=>m(o(e,".git")),x=(e)=>{const t=[];let n=e;for(;;){t.push(n);if(g(n))break;const r=y(n);if(r===n)break;n=r}return t},a=new Map,j=()=>{const e=process.cwd(),t=a.get(e);if(t)return t;const n=x(e),r=new Map;for(const f of n){const s=i(f),l=Object.entries({...s?.peerDependencies,...s?.devDependencies,...s?.dependencies});for(const[d,p]of l)if(!r.has(d))r.set(d,p)}const c={dirs:n,declared:r};a.set(e,c);return c},u=(e)=>{if(typeof e!=="string")return null;const t=e.slice(Math.max(e.lastIndexOf("@"),e.lastIndexOf(":"))+1),n=/^\s*(?:[~^]|>=?|=)?\s*v?(\d+)/.exec(t);return n?Number(n[1]):null},O=(e,t)=>{for(const n of e.dirs){const r=i(o(n,"node_modules",t));if(r!==null)return u(r.version)}return u(e.declared.get(t))},b=(e,t,n)=>{if(!e.declared.has(t))return!1;if(n===void 0)return!0;const r=O(e,t);return r!==null&&r>=n};export const detect=(e,t,n)=>e??(t===void 0||t.some((r)=>b(j(),r,n)));
@@ -1 +1 @@
1
- import{fileURLToPath as d}from"node:url";import{detect as r}from"./detect.js";export const defineModule=(e)=>e;const shortName=(e)=>e.meta.name.slice(10),p=(e,t)=>r(e.option===void 0?void 0:t[e.option],e.packages),u=(e)=>{const t=[];for(const[o,s]of Object.entries(e.rules)){if(s.defaultOff)continue;if(s.packages&&!r(void 0,s.packages))continue;t.push(`${e.meta.name}/${o}`)}return t},i=(e,t)=>{e.paths.push(...t?.paths??[]);e.patterns.push(...t?.patterns??[])};export const composeModules=(e,t,o=[])=>{const s={jsPlugins:[],rules:{},restricted:{paths:[],patterns:[]}};for(const n of e){if(!p(n,t))continue;const c=u(n);if(c.length>0)s.jsPlugins.push(d(n.url));for(const a of c)s.rules[a]="error";i(s.restricted,n.restrictedImports)}for(const n of o){if(!r(void 0,n.packages))continue;i(s.restricted,n.restrictedImports)}return s};export{shortName};
1
+ import{fileURLToPath as f}from"node:url";import{detect as a}from"./detect.js";export const defineModule=(e)=>e;const shortName=(e)=>e.meta.name.slice(10),d=(e,s)=>a(e.option===void 0?void 0:s[e.option],e.packages,e.minMajor),l=(e)=>{const s=[];for(const[n,t]of Object.entries(e.rules)){if(t.defaultOff)continue;if(t.packages&&!a(void 0,t.packages))continue;s.push(`${e.meta.name}/${n}`)}return s},c=(e,s)=>{e.paths.push(...s?.paths??[]);e.patterns.push(...s?.patterns??[])},u=(e,s)=>{const{importNames:n}=s;if(e.name!==s.from)return[e];if(n===void 0)return[];if(e.importNames===void 0)return[{...e,allowImportNames:[...e.allowImportNames??[],...n]}];const t=e.importNames.filter((r)=>!n.includes(r));return t.length===0?[]:[{...e,importNames:t}]};export const restrictedImportsConfig=(e,s={})=>{const n={paths:[...e.paths],patterns:[...e.patterns]};c(n,s);const t=new Map;for(const r of s.allow??[]){const o=JSON.stringify(r.files),i=t.get(o)??{files:r.files,paths:n.paths};i.paths=i.paths.flatMap((p)=>u(p,r));t.set(o,i)}return{rules:{"no-restricted-imports":["error",n]},overrides:[...t.values()].map(({files:r,paths:o})=>({files:r,rules:{"no-restricted-imports":["error",{paths:o,patterns:n.patterns}]}}))}},composeModules=(e,s,n=[])=>{const t={jsPlugins:[],rules:{},restricted:{paths:[],patterns:[]}};for(const r of e){if(!d(r,s))continue;const o=l(r);if(o.length>0)t.jsPlugins.push(f(r.url));for(const i of o)t.rules[i]="error";c(t.restricted,r.restrictedImports)}for(const r of n){if(!a(void 0,r.packages))continue;c(t.restricted,r.restrictedImports)}return t};export{shortName};
@@ -1 +1 @@
1
- const e=(t)=>new URL(t,import.meta.url).href;export const coreRegistry=[{meta:{name:"@ashstack/core"},url:e("../core/rules/core/index.js"),rules:{"no-comments":{},"no-naming-convention":{},"no-packed-condition":{},"max-lines":{},"max-complexity":{}}},{meta:{name:"@ashstack/zod"},url:e("../core/rules/zod/index.js"),option:"zod",packages:["zod"],rules:{"prefer-enum":{}}}],reactRegistry=[{meta:{name:"@ashstack/react"},url:e("../react/rules/react/index.js"),rules:{"no-unlabeled-icon-button":{},"no-svg-without-title":{},"hoist-intl":{},"prefer-design-system":{defaultOff:!0},"components-tsx-only":{defaultOff:!0}}},{meta:{name:"@ashstack/query"},url:e("../react/rules/query/index.js"),option:"query",packages:["@tanstack/react-query"],rules:{"no-inline-keys":{},"no-deprecated-filters":{},"require-destructured-hooks":{},"no-fetch-in-query-fn":{},"next-page-param-undefined":{}}},{meta:{name:"@ashstack/zustand"},url:e("../react/rules/zustand/index.js"),option:"zustand",packages:["zustand"],rules:{"require-selector":{}}},{meta:{name:"@ashstack/i18n"},url:e("../react/rules/i18n/index.js"),option:"i18n",packages:["i18next","react-i18next","@lingui/core","react-intl","use-intl","next-intl","expo-localization"],rules:{"no-bare-text":{},"no-bare-attrs":{},"no-bare-toast":{}}},{meta:{name:"@ashstack/stylex"},url:e("../react/rules/stylex/index.js"),option:"stylex",packages:["@stylexjs/stylex"],rules:{"inline-props":{},"no-conflicting-props":{},"no-duplicate-styles":{},"require-tokens":{},"spread-props":{}}},{meta:{name:"@ashstack/tailwind"},url:e("../react/rules/tailwind/index.js"),option:"tailwind",packages:["tailwindcss"],rules:{"prefer-cn":{},"use-logical-classes":{}}},{meta:{name:"@ashstack/tanstack-router"},url:e("../react/rules/tanstack-router/index.js"),option:"tanstackRouter",packages:["@tanstack/react-router"],rules:{"require-selector":{},"no-search-casts":{}}}],reactNativeRegistry=[{meta:{name:"@ashstack/react-native"},url:e("../react-native/rules/react-native/index.js"),restrictedImports:{paths:[{name:"react",importNames:["forwardRef"],message:"Accept `ref` as a regular prop and delete the `forwardRef` wrapper — React 19 passes `ref` like any other prop."},{name:"react",importNames:["useContext"],message:"Call `use(Context)` instead of `useContext(Context)`; React 19 replaces the hook with it."}],patterns:[{group:["expo-linear-gradient","react-native-linear-gradient"],message:"Apply the gradient through the `experimental_backgroundImage` style property instead of a gradient component."}]},rules:{"no-keyboard-will-events":{},"no-scroll-position-state":{},"no-conditional-style-array":{},"no-leaked-render":{},"no-rn-image-network-source":{},"no-redundant-view-nesting":{},"no-rn-namespace-import":{},"no-unlabeled-icon-pressable":{},"hoist-stateless-function":{},"no-manual-memo":{},"no-dynamic-import":{}}},{meta:{name:"@ashstack/unistyles"},url:e("../react-native/rules/unistyles/index.js"),option:"unistyles",packages:["react-native-unistyles"],restrictedImports:{paths:[{name:"react-native",importNames:["StyleSheet"],message:"Import `StyleSheet` from `react-native-unistyles` instead of `react-native`."},{name:"react-native",importNames:["useWindowDimensions","Dimensions"],message:"Read screen size from `rt.screen` inside `StyleSheet.create`, or `UnistylesRuntime.screen` outside it, instead of the `Dimensions` APIs."},{name:"react-native",importNames:["SafeAreaView"],message:'Set `contentInsetAdjustmentBehavior="automatic"` on the scroll view, or apply `rt.insets` from `react-native-unistyles`, instead of `SafeAreaView`.'},{name:"react-native-safe-area-context",importNames:["useSafeAreaInsets","useSafeAreaFrame","SafeAreaView"],message:"Read safe-area values from `rt.insets`, or `UnistylesRuntime.insets` outside a stylesheet, in `react-native-unistyles`."}]},rules:{"animated-theme":{},"content-container":{},"in-sheet":{},insets:{},"no-hardcoded-color":{},"no-hardcoded-spacing":{},"no-margin":{},"no-paramless-dynamic-function":{},"no-style-spread":{},"no-unused-styles":{},"rtl-style-call":{},"theme-screen-component":{},"theme-style-attr":{}}},{meta:{name:"@ashstack/legend-list"},url:e("../react-native/rules/legend-list/index.js"),option:"legendList",packages:["@legendapp/list"],restrictedImports:{paths:[{name:"react-native",importNames:["FlatList","SectionList","VirtualizedList"],message:"Render this list with `LegendList` from `@legendapp/list/react-native`; a `ScrollView` plus `map` is fine for fewer than 20 static items."},{name:"@shopify/flash-list",message:"Import `LegendList` from `@legendapp/list/react-native` — Legend List replaced FlashList in this stack."}],patterns:[{group:["@legendapp/list"],message:"Import from the platform entrypoint `@legendapp/list/react-native`, not the package root."}]},rules:{"required-props":{},"no-index-key-extractor":{},"no-remount-key":{},"no-inline-render-item-props":{},"no-mixed-children":{},"no-flex-in-content-container":{},"typed-items-need-item-type":{},"no-scrollview-map":{},"no-unsupported-props":{}}},{meta:{name:"@ashstack/legend-state"},url:e("../react-native/rules/legend-state/index.js"),option:"legendState",packages:["@legendapp/state"],restrictedImports:{paths:[{name:"@legendapp/state/react",importNames:["use$","useSelector"],message:"Use `useValue` from `@legendapp/state/react`; `use$` and `useSelector` are deprecated."}]},rules:{"no-assignment":{},naming:{},"no-nested-observable":{},"no-react-mirror":{},"no-untracked-get-in-jsx":{},"no-peek-in-selector":{},"no-object-selector":{},"no-observable-in-component":{}}},{meta:{name:"@ashstack/reanimated"},url:e("../react-native/rules/reanimated/index.js"),option:"reanimated",packages:["react-native-reanimated"],restrictedImports:{paths:[{name:"react-native",importNames:["Animated"],message:"Use `react-native-reanimated` instead of React Native's `Animated` API."},{name:"react-native-reanimated",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."},{name:"react-native-worklets",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."}]},rules:{"animated-reaction-safety":{},"animated-style-needs-animated-component":{},"animated-updater-purity":{},"gpu-properties-only":{},"hoist-layout-animation-builder":{},"interpolate-needs-clamp":{},"no-shared-value-dot-value":{},"no-react-state-from-continuous-worklet":{},"prefer-lazy-shared-value-initializer":{},"schedule-on-rn-scope":{},"shared-value-usage":{}}},{meta:{name:"@ashstack/turbo-image"},url:e("../react-native/rules/turbo-image/index.js"),option:"turboImage",packages:["react-native-turbo-image"],rules:{"require-resize":{},"require-cache-policy":{}}},{meta:{name:"@ashstack/skia"},url:e("../react-native/rules/skia/index.js"),option:"skia",packages:["@shopify/react-native-skia"],restrictedImports:{paths:[{name:"@shopify/react-native-skia",importNames:["usePathValue","usePathInterpolation"],message:"Keep one stable `SkPath` buffer and mutate it inside `useDerivedValue`, with consumers reading the driving shared value."}]},rules:{"canvas-opaque":{}}},{meta:{name:"@ashstack/keyboard"},url:e("../react-native/rules/keyboard/index.js"),option:"keyboard",packages:["react-native-keyboard-controller"],restrictedImports:{paths:[{name:"react-native",importNames:["KeyboardAvoidingView"],message:"Import `KeyboardAvoidingView` from `react-native-keyboard-controller` — same props, tracked per frame. For a scrolling form, its `KeyboardAwareScrollView`."}]},rules:{}}];
1
+ const e=(t)=>new URL(t,import.meta.url).href;export const coreRegistry=[{meta:{name:"@ashstack/core"},url:e("../core/rules/core/index.js"),rules:{"no-comments":{},"no-naming-convention":{},"no-packed-condition":{},"max-lines":{},"max-complexity":{}}},{meta:{name:"@ashstack/zod"},url:e("../core/rules/zod/index.js"),option:"zod",packages:["zod"],rules:{"prefer-enum":{}}}],reactRegistry=[{meta:{name:"@ashstack/react"},url:e("../react/rules/react/index.js"),rules:{"no-unlabeled-icon-button":{},"no-svg-without-title":{},"hoist-intl":{},"prefer-design-system":{defaultOff:!0},"components-tsx-only":{defaultOff:!0},"no-use-no-memo":{},"no-context-provider":{},"require-destructured-router":{},"require-effect-cleanup":{}}},{meta:{name:"@ashstack/query"},url:e("../react/rules/query/index.js"),option:"query",packages:["@tanstack/react-query"],rules:{"no-inline-keys":{},"no-deprecated-filters":{},"require-destructured-hooks":{},"no-fetch-in-query-fn":{},"next-page-param-undefined":{},"exhaustive-key":{},"no-overridden-callbacks":{},"optimistic-update-complete":{},"forward-signal":{}}},{meta:{name:"@ashstack/zustand"},url:e("../react/rules/zustand/index.js"),option:"zustand",packages:["zustand"],rules:{"require-selector":{}}},{meta:{name:"@ashstack/i18n"},url:e("../react/rules/i18n/index.js"),option:"i18n",packages:["i18next","react-i18next","@lingui/core","react-intl","use-intl","next-intl","expo-localization"],rules:{"no-bare-text":{},"no-bare-attrs":{},"no-bare-toast":{}}},{meta:{name:"@ashstack/stylex"},url:e("../react/rules/stylex/index.js"),option:"stylex",packages:["@stylexjs/stylex"],rules:{"inline-props":{},"no-conflicting-props":{},"no-duplicate-styles":{},"require-tokens":{},"spread-props":{}}},{meta:{name:"@ashstack/tailwind"},url:e("../react/rules/tailwind/index.js"),option:"tailwind",packages:["tailwindcss"],rules:{"prefer-cn":{},"use-logical-classes":{}}},{meta:{name:"@ashstack/tanstack-router"},url:e("../react/rules/tanstack-router/index.js"),option:"tanstackRouter",packages:["@tanstack/react-router"],rules:{"require-selector":{},"no-search-casts":{}}}],reactNativeRegistry=[{meta:{name:"@ashstack/react-native"},url:e("../react-native/rules/react-native/index.js"),restrictedImports:{paths:[{name:"react",importNames:["forwardRef"],message:"Accept `ref` as a regular prop and delete the `forwardRef` wrapper — React 19 passes `ref` like any other prop."},{name:"react",importNames:["useContext"],message:"Call `use(Context)` instead of `useContext(Context)`; React 19 replaces the hook with it."}],patterns:[{group:["expo-linear-gradient","react-native-linear-gradient"],message:"Apply the gradient through the `experimental_backgroundImage` style property instead of a gradient component."}]},rules:{"no-keyboard-will-events":{},"no-scroll-position-state":{},"no-conditional-style-array":{},"no-leaked-render":{},"no-rn-image-network-source":{},"no-redundant-view-nesting":{},"no-rn-namespace-import":{},"no-unlabeled-icon-pressable":{},"hoist-stateless-function":{},"no-manual-memo":{},"no-dynamic-import":{},"no-react-lazy":{}}},{meta:{name:"@ashstack/unistyles"},url:e("../react-native/rules/unistyles/index.js"),option:"unistyles",packages:["react-native-unistyles"],restrictedImports:{paths:[{name:"react-native",importNames:["StyleSheet"],message:"Import `StyleSheet` from `react-native-unistyles` instead of `react-native`."},{name:"react-native",importNames:["useWindowDimensions","Dimensions"],message:"Read screen size from `rt.screen` inside `StyleSheet.create`, or `UnistylesRuntime.screen` outside it, instead of the `Dimensions` APIs."},{name:"react-native",importNames:["SafeAreaView"],message:'Set `contentInsetAdjustmentBehavior="automatic"` on the scroll view, or apply `rt.insets` from `react-native-unistyles`, instead of `SafeAreaView`.'},{name:"react-native-safe-area-context",importNames:["useSafeAreaInsets","useSafeAreaFrame","SafeAreaView"],message:"Read safe-area values from `rt.insets`, or `UnistylesRuntime.insets` outside a stylesheet, in `react-native-unistyles`."}]},rules:{"animated-theme":{},"content-container":{},"in-sheet":{},insets:{},"no-hardcoded-color":{},"no-hardcoded-spacing":{},"no-margin":{},"no-paramless-dynamic-function":{},"no-style-spread":{},"no-theme-runtime-args":{},"no-unused-styles":{},"rtl-style-call":{},"theme-screen-component":{},"theme-style-attr":{}}},{meta:{name:"@ashstack/legend-list"},url:e("../react-native/rules/legend-list/index.js"),option:"legendList",packages:["@legendapp/list"],restrictedImports:{paths:[{name:"react-native",importNames:["FlatList","SectionList","VirtualizedList"],message:"Render this list with `LegendList` from `@legendapp/list/react-native`; a `ScrollView` plus `map` is fine for fewer than 20 static items."},{name:"@shopify/flash-list",message:"Import `LegendList` from `@legendapp/list/react-native` — Legend List replaced FlashList in this stack."}],patterns:[{group:["@legendapp/list"],message:"Import from the platform entrypoint `@legendapp/list/react-native`, not the package root."}]},rules:{"required-props":{},"no-index-key-extractor":{},"no-remount-key":{},"no-inline-render-item-props":{},"no-mixed-children":{},"no-flex-in-content-container":{},"typed-items-need-item-type":{},"no-scrollview-map":{},"no-unsupported-props":{}}},{meta:{name:"@ashstack/legend-state"},url:e("../react-native/rules/legend-state/index.js"),option:"legendState",packages:["@legendapp/state"],restrictedImports:{paths:[{name:"@legendapp/state/react",importNames:["use$","useSelector"],message:"Use `useValue` from `@legendapp/state/react`; `use$` and `useSelector` are deprecated."},{name:"@legendapp/state/react",importNames:["observer"],message:"Read the value with `useValue` instead of wrapping the component in `observer`; the React Compiler and `useValue` cover what it did. Inside `observer` a bare `.get()` tracks, and moved out of it the same line silently stops updating."}]},rules:{"no-assignment":{},naming:{},"no-nested-observable":{},"no-react-mirror":{},"no-untracked-get-in-jsx":{},"no-peek-in-selector":{},"no-object-selector":{},"no-observable-in-component":{},"no-untracked-collection-read":{},"dispose-observe":{}}},{meta:{name:"@ashstack/reanimated"},url:e("../react-native/rules/reanimated/index.js"),option:"reanimated",packages:["react-native-reanimated"],restrictedImports:{paths:[{name:"react-native",importNames:["Animated"],message:"Use `react-native-reanimated` instead of React Native's `Animated` API."},{name:"react-native-reanimated",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."},{name:"react-native-worklets",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."}]},rules:{"animated-reaction-safety":{},"animated-style-needs-animated-component":{},"animated-updater-purity":{},"gpu-properties-only":{},"hoist-layout-animation-builder":{},"interpolate-needs-clamp":{},"no-shared-value-dot-value":{},"no-react-state-from-continuous-worklet":{},"prefer-lazy-shared-value-initializer":{},"schedule-on-rn-scope":{},"shared-value-usage":{},"layout-animation-needs-animated-component":{},"check-finished":{}}},{meta:{name:"@ashstack/turbo-image"},url:e("../react-native/rules/turbo-image/index.js"),option:"turboImage",packages:["react-native-turbo-image"],rules:{"require-resize":{},"require-cache-policy":{}}},{meta:{name:"@ashstack/skia"},url:e("../react-native/rules/skia/index.js"),option:"skia",packages:["@shopify/react-native-skia"],restrictedImports:{paths:[{name:"@shopify/react-native-skia",importNames:["usePathValue","usePathInterpolation"],message:"Keep one stable `SkPath` buffer and mutate it inside `useDerivedValue`, with consumers reading the driving shared value."}]},rules:{"canvas-opaque":{}}},{meta:{name:"@ashstack/keyboard"},url:e("../react-native/rules/keyboard/index.js"),option:"keyboard",packages:["react-native-keyboard-controller"],restrictedImports:{paths:[{name:"react-native",importNames:["KeyboardAvoidingView"],message:"Import `KeyboardAvoidingView` from `react-native-keyboard-controller` — same props, tracked per frame. For a scrolling form, its `KeyboardAwareScrollView`."}]},rules:{}},{meta:{name:"@ashstack/gesture-handler"},url:e("../react-native/rules/gesture-handler/index.js"),option:"gestureHandler",packages:["react-native-gesture-handler"],minMajor:3,restrictedImports:{paths:[{name:"react-native-gesture-handler",importNames:["Gesture"],message:"`Gesture.*()` builders are the Gesture Handler 2 API. Create each gesture with its hook (`Gesture.Pan()` → `usePanGesture`) and pass it to `GestureDetector`; combine gestures with `useSimultaneousGestures`, `useCompetingGestures` (was `Race`) or `useExclusiveGestures`."},{name:"react-native-gesture-handler",importNames:["PanGestureHandler","TapGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","ForceTouchGestureHandler","NativeViewGestureHandler"],message:"`*GestureHandler` components are the Gesture Handler 2 API. Create the gesture with its hook (`PanGestureHandler` → `usePanGesture`, `NativeViewGestureHandler` → `useNativeGesture`) and wrap the view in `GestureDetector`. Force touch has no Gesture Handler 3 gesture."},{name:"react-native-gesture-handler",importNames:["RawButton","BaseButton","RectButton","BorderlessButton","LegacyRawButton","LegacyBaseButton","LegacyRectButton","LegacyBorderlessButton","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","RawButtonProps","LegacyRawButtonProps","LegacyRawButtonProperties","BaseButtonProps","LegacyBaseButtonProps","LegacyBaseButtonProperties","RectButtonProps","LegacyRectButtonProps","LegacyRectButtonProperties","BorderlessButtonProps","LegacyBorderlessButtonProps","LegacyBorderlessButtonProperties","TouchableOpacityProps","TouchableHighlightProps","TouchableWithoutFeedbackProps"],message:"Use `Touchable` from `react-native-gesture-handler`, typed `TouchableProps`: `activeOpacity` for an opacity press effect, `activeUnderlayOpacity` for a highlight, `androidRipple` for a ripple. Gesture Handler 3 deprecates its buttons and `Touchable*` components."},{name:"react-native-gesture-handler",importNames:["LegacyPressable","LegacyScrollView","LegacyFlatList","LegacyRefreshControl","LegacySwitch","LegacyTextInput","LegacyPressableProps","LegacyFlingGesture","LegacyHoverGesture","LegacyLongPressGesture","LegacyManualGesture","LegacyPanGesture","LegacyPinchGesture","LegacyRotationGesture","LegacyTapGesture","LegacyComposedGesture","LegacyGestureStateManager"],message:"Import the name without the `Legacy` prefix (`LegacyScrollView` → `ScrollView`, `LegacyPanGesture` → `PanGesture`). `Legacy*` names are the Gesture Handler 2 API."},{name:"react-native-gesture-handler",importNames:["LegacyText"],message:"Use React Native's `Text` and wrap it in `GestureDetector` or `VirtualGestureDetector`."},{name:"react-native-gesture-handler",importNames:["LegacyDrawerLayoutAndroid"],message:"Use `ReanimatedDrawerLayout` from `react-native-gesture-handler/ReanimatedDrawerLayout`, or React Native's `DrawerLayoutAndroid`."},{name:"react-native-gesture-handler",importNames:["createNativeWrapper","legacy_createNativeWrapper"],message:"Create the gesture with `useNativeGesture` and wrap the native component in `GestureDetector`, instead of wrapping the component with `createNativeWrapper`."},{name:"react-native-gesture-handler",importNames:["GestureType"],message:"Type a Gesture Handler 3 gesture as `SingleGesture`, `ComposedGesture` for a combination, or the hook's own type (`PanGesture`, `TapGesture`, …). `GestureType` describes the Gesture Handler 2 builders."},{name:"react-native-gesture-handler",importNames:["GestureHandlerGestureEvent","GestureHandlerStateChangeEvent","PanGestureHandlerGestureEvent","PanGestureHandlerStateChangeEvent","PanGestureHandlerProps","PanGestureHandlerProperties","TapGestureHandlerGestureEvent","TapGestureHandlerStateChangeEvent","TapGestureHandlerProps","TapGestureHandlerProperties","LongPressGestureHandlerGestureEvent","LongPressGestureHandlerStateChangeEvent","LongPressGestureHandlerProps","LongPressGestureHandlerProperties","PinchGestureHandlerGestureEvent","PinchGestureHandlerStateChangeEvent","PinchGestureHandlerProps","PinchGestureHandlerProperties","RotationGestureHandlerGestureEvent","RotationGestureHandlerStateChangeEvent","RotationGestureHandlerProps","RotationGestureHandlerProperties","FlingGestureHandlerGestureEvent","FlingGestureHandlerStateChangeEvent","FlingGestureHandlerProps","FlingGestureHandlerProperties","ForceTouchGestureHandlerGestureEvent","ForceTouchGestureHandlerStateChangeEvent","ForceTouchGestureHandlerProps","ForceTouchGestureHandlerProperties","NativeViewGestureHandlerGestureEvent","NativeViewGestureHandlerStateChangeEvent","NativeViewGestureHandlerProps","NativeViewGestureHandlerProperties"],message:"Use the Gesture Handler 3 type for the gesture: `PanGestureConfig` for its config, `PanGestureEvent` (or `PanGestureActiveEvent`, `PanGestureBeginEvent`, …) for its callbacks. These types describe the Gesture Handler 2 handler components."},{name:"react-native-gesture-handler",importNames:["LegacyExclusiveGesture","LegacyRaceGesture","LegacySimultaneousGesture"],message:"Type a combined gesture as `ComposedGesture`, what `useSimultaneousGestures`, `useCompetingGestures` and `useExclusiveGestures` return."},{name:"react-native-gesture-handler",importNames:["LegacyForceTouchGesture"],message:"Gesture Handler 3 has no force touch gesture; `LegacyForceTouchGesture` types the Gesture Handler 2 one."}]},rules:{"modal-needs-root-view":{}}},{meta:{name:"@ashstack/worklets"},url:e("../react-native/rules/worklets/index.js"),option:"worklets",packages:["react-native-worklets"],rules:{"no-runtime-in-render":{},"no-inline-worklet-schedule":{},"no-sync-runtime-call":{},"no-js-timer-schedule":{}}}];
@@ -2,7 +2,7 @@ import type { AllowWarnDeny } from "oxlint";
2
2
  /** A severity, or a severity followed by as many of the rule's options as you want to set. */
3
3
  type RuleSetting<Options extends unknown[] = []> = AllowWarnDeny | [AllowWarnDeny, ...Partial<Options>];
4
4
  /** Every rule id `react-native()` adds on top of the entry below it. */
5
- export type ReactNativeRuleId = "@ashstack/react-native/no-keyboard-will-events" | "@ashstack/react-native/no-scroll-position-state" | "@ashstack/react-native/no-conditional-style-array" | "@ashstack/react-native/no-leaked-render" | "@ashstack/react-native/no-rn-image-network-source" | "@ashstack/react-native/no-redundant-view-nesting" | "@ashstack/react-native/no-rn-namespace-import" | "@ashstack/react-native/no-unlabeled-icon-pressable" | "@ashstack/react-native/hoist-stateless-function" | "@ashstack/react-native/no-manual-memo" | "@ashstack/react-native/no-dynamic-import" | "@ashstack/unistyles/animated-theme" | "@ashstack/unistyles/content-container" | "@ashstack/unistyles/in-sheet" | "@ashstack/unistyles/insets" | "@ashstack/unistyles/no-hardcoded-color" | "@ashstack/unistyles/no-hardcoded-spacing" | "@ashstack/unistyles/no-margin" | "@ashstack/unistyles/no-paramless-dynamic-function" | "@ashstack/unistyles/no-style-spread" | "@ashstack/unistyles/no-unused-styles" | "@ashstack/unistyles/rtl-style-call" | "@ashstack/unistyles/theme-screen-component" | "@ashstack/unistyles/theme-style-attr" | "@ashstack/legend-list/required-props" | "@ashstack/legend-list/no-index-key-extractor" | "@ashstack/legend-list/no-remount-key" | "@ashstack/legend-list/no-inline-render-item-props" | "@ashstack/legend-list/no-mixed-children" | "@ashstack/legend-list/no-flex-in-content-container" | "@ashstack/legend-list/typed-items-need-item-type" | "@ashstack/legend-list/no-scrollview-map" | "@ashstack/legend-list/no-unsupported-props" | "@ashstack/legend-state/no-assignment" | "@ashstack/legend-state/naming" | "@ashstack/legend-state/no-nested-observable" | "@ashstack/legend-state/no-react-mirror" | "@ashstack/legend-state/no-untracked-get-in-jsx" | "@ashstack/legend-state/no-peek-in-selector" | "@ashstack/legend-state/no-object-selector" | "@ashstack/legend-state/no-observable-in-component" | "@ashstack/reanimated/animated-reaction-safety" | "@ashstack/reanimated/animated-style-needs-animated-component" | "@ashstack/reanimated/animated-updater-purity" | "@ashstack/reanimated/gpu-properties-only" | "@ashstack/reanimated/hoist-layout-animation-builder" | "@ashstack/reanimated/interpolate-needs-clamp" | "@ashstack/reanimated/no-shared-value-dot-value" | "@ashstack/reanimated/no-react-state-from-continuous-worklet" | "@ashstack/reanimated/prefer-lazy-shared-value-initializer" | "@ashstack/reanimated/schedule-on-rn-scope" | "@ashstack/reanimated/shared-value-usage" | "@ashstack/turbo-image/require-resize" | "@ashstack/turbo-image/require-cache-policy" | "@ashstack/skia/canvas-opaque";
5
+ export type ReactNativeRuleId = "@ashstack/react-native/no-keyboard-will-events" | "@ashstack/react-native/no-scroll-position-state" | "@ashstack/react-native/no-conditional-style-array" | "@ashstack/react-native/no-leaked-render" | "@ashstack/react-native/no-rn-image-network-source" | "@ashstack/react-native/no-redundant-view-nesting" | "@ashstack/react-native/no-rn-namespace-import" | "@ashstack/react-native/no-unlabeled-icon-pressable" | "@ashstack/react-native/hoist-stateless-function" | "@ashstack/react-native/no-manual-memo" | "@ashstack/react-native/no-dynamic-import" | "@ashstack/react-native/no-react-lazy" | "@ashstack/unistyles/animated-theme" | "@ashstack/unistyles/content-container" | "@ashstack/unistyles/in-sheet" | "@ashstack/unistyles/insets" | "@ashstack/unistyles/no-hardcoded-color" | "@ashstack/unistyles/no-hardcoded-spacing" | "@ashstack/unistyles/no-margin" | "@ashstack/unistyles/no-paramless-dynamic-function" | "@ashstack/unistyles/no-style-spread" | "@ashstack/unistyles/no-theme-runtime-args" | "@ashstack/unistyles/no-unused-styles" | "@ashstack/unistyles/rtl-style-call" | "@ashstack/unistyles/theme-screen-component" | "@ashstack/unistyles/theme-style-attr" | "@ashstack/legend-list/required-props" | "@ashstack/legend-list/no-index-key-extractor" | "@ashstack/legend-list/no-remount-key" | "@ashstack/legend-list/no-inline-render-item-props" | "@ashstack/legend-list/no-mixed-children" | "@ashstack/legend-list/no-flex-in-content-container" | "@ashstack/legend-list/typed-items-need-item-type" | "@ashstack/legend-list/no-scrollview-map" | "@ashstack/legend-list/no-unsupported-props" | "@ashstack/legend-state/no-assignment" | "@ashstack/legend-state/naming" | "@ashstack/legend-state/no-nested-observable" | "@ashstack/legend-state/no-react-mirror" | "@ashstack/legend-state/no-untracked-get-in-jsx" | "@ashstack/legend-state/no-peek-in-selector" | "@ashstack/legend-state/no-object-selector" | "@ashstack/legend-state/no-observable-in-component" | "@ashstack/legend-state/no-untracked-collection-read" | "@ashstack/legend-state/dispose-observe" | "@ashstack/reanimated/animated-reaction-safety" | "@ashstack/reanimated/animated-style-needs-animated-component" | "@ashstack/reanimated/animated-updater-purity" | "@ashstack/reanimated/gpu-properties-only" | "@ashstack/reanimated/hoist-layout-animation-builder" | "@ashstack/reanimated/interpolate-needs-clamp" | "@ashstack/reanimated/no-shared-value-dot-value" | "@ashstack/reanimated/no-react-state-from-continuous-worklet" | "@ashstack/reanimated/prefer-lazy-shared-value-initializer" | "@ashstack/reanimated/schedule-on-rn-scope" | "@ashstack/reanimated/shared-value-usage" | "@ashstack/reanimated/layout-animation-needs-animated-component" | "@ashstack/reanimated/check-finished" | "@ashstack/turbo-image/require-resize" | "@ashstack/turbo-image/require-cache-policy" | "@ashstack/skia/canvas-opaque" | "@ashstack/gesture-handler/modal-needs-root-view" | "@ashstack/worklets/no-runtime-in-render" | "@ashstack/worklets/no-inline-worklet-schedule" | "@ashstack/worklets/no-sync-runtime-call" | "@ashstack/worklets/no-js-timer-schedule";
6
6
  declare module "oxlint" {
7
7
  interface DummyRuleMap {
8
8
  /**
@@ -86,13 +86,21 @@ declare module "oxlint" {
86
86
  */
87
87
  "@ashstack/react-native/no-manual-memo"?: RuleSetting;
88
88
  /**
89
- * Disallow dynamic `import()` outside a `React.lazy` or `dynamic` wrapper. Metro inlines it into the same bundle, so nothing is deferred and the module is hidden from the typechecker.
89
+ * Disallow dynamic `import()`. Metro inlines it into the same bundle, so nothing is deferred and the module is hidden from the typechecker.
90
90
  *
91
91
  * **Default: on.**
92
92
  *
93
93
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react-native.md#ashstackreact-nativeno-dynamic-import
94
94
  */
95
95
  "@ashstack/react-native/no-dynamic-import"?: RuleSetting;
96
+ /**
97
+ * Disallow `lazy` and `React.lazy` from `react`. The router already loads screens lazily, and the Suspense boundary `lazy` adds holds its fallback for up to 300ms and can loop forever inside a frozen screen.
98
+ *
99
+ * **Default: on.**
100
+ *
101
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react-native.md#ashstackreact-nativeno-react-lazy
102
+ */
103
+ "@ashstack/react-native/no-react-lazy"?: RuleSetting;
96
104
  /**
97
105
  * A Reanimated worklet hook cannot see `useUnistyles()` theme changes on the UI thread. Read the shared value from `useAnimatedTheme()` there instead.
98
106
  *
@@ -165,6 +173,14 @@ declare module "oxlint" {
165
173
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/unistyles.md#ashstackunistylesno-style-spread
166
174
  */
167
175
  "@ashstack/unistyles/no-style-spread"?: RuleSetting;
176
+ /**
177
+ * Disallow passing theme or Unistyles runtime values into dynamic style functions, including screen dimensions, safe-area insets, RTL, pixel/font scale, color scheme, derived values and aliases. Read `theme` and `rt` inside the `StyleSheet.create` callback instead.
178
+ *
179
+ * **Default: on**, when `react-native-unistyles` is a dependency.
180
+ *
181
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/unistyles.md#ashstackunistylesno-theme-runtime-args
182
+ */
183
+ "@ashstack/unistyles/no-theme-runtime-args"?: RuleSetting;
168
184
  /**
169
185
  * Disallow stylesheet keys that nothing in the file reads. A computed key, a computed read, or a sheet that leaves the module skips the whole file.
170
186
  *
@@ -222,7 +238,7 @@ declare module "oxlint" {
222
238
  */
223
239
  "@ashstack/legend-list/no-remount-key"?: RuleSetting;
224
240
  /**
225
- * Disallow inline object and array literals on props nested inside `renderItem`. A row whose props take a new identity every render can never be skipped.
241
+ * Disallow inline object literals, array literals and functions on props nested inside `renderItem`. A row whose props take a new identity every render can never be skipped.
226
242
  *
227
243
  * **Default: on**, when `@legendapp/list` is a dependency.
228
244
  *
@@ -333,6 +349,22 @@ declare module "oxlint" {
333
349
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/legend-state.md#ashstacklegend-stateno-observable-in-component
334
350
  */
335
351
  "@ashstack/legend-state/no-observable-in-component"?: RuleSetting;
352
+ /**
353
+ * Disallow `has`, `entries`, `keys` or `values` called on an observable inside a tracking context. On an observable `Map` or `Set` they read the raw collection and subscribe to nothing, so the selector never re-runs.
354
+ *
355
+ * **Default: on**, when `@legendapp/state` is a dependency.
356
+ *
357
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/legend-state.md#ashstacklegend-stateno-untracked-collection-read
358
+ */
359
+ "@ashstack/legend-state/no-untracked-collection-read"?: RuleSetting;
360
+ /**
361
+ * Disallow an `observe(...)` statement inside a component or hook that drops the dispose function it returns. Each run starts an observer nothing ever stops.
362
+ *
363
+ * **Default: on**, when `@legendapp/state` is a dependency.
364
+ *
365
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/legend-state.md#ashstacklegend-statedispose-observe
366
+ */
367
+ "@ashstack/legend-state/dispose-observe"?: RuleSetting;
336
368
  /**
337
369
  * A `useAnimatedReaction` result callback loops forever if it writes a shared value the prepare callback reads. Guard `scheduleOnRN` there on the current result differing from the previous one.
338
370
  *
@@ -358,7 +390,7 @@ declare module "oxlint" {
358
390
  */
359
391
  "@ashstack/reanimated/animated-updater-purity"?: RuleSetting;
360
392
  /**
361
- * Animate `transform` and `opacity` in `useAnimatedStyle` and `useAnimatedProps`. Layout properties such as `width` or `margin` recalculate layout every frame.
393
+ * Animate `transform` and `opacity` in `useAnimatedStyle` and `useAnimatedProps`, and `boxShadow` for a shadow. Layout properties such as `width` or `margin` recalculate layout every frame, and `shadowOffset`, `shadowOpacity`, `shadowRadius` and `elevation` each render on one platform only.
362
394
  *
363
395
  * **Default: on**, when `react-native-reanimated` is a dependency.
364
396
  *
@@ -421,6 +453,22 @@ declare module "oxlint" {
421
453
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/reanimated.md#ashstackreanimatedshared-value-usage
422
454
  */
423
455
  "@ashstack/reanimated/shared-value-usage"?: RuleSetting;
456
+ /**
457
+ * Disallow `entering`, `exiting` or `layout` on a component imported from `react-native`. Only an `Animated.*` component or a `createAnimatedComponent` wrapper runs a layout animation; a plain one ignores the prop.
458
+ *
459
+ * **Default: on**, when `react-native-reanimated` is a dependency.
460
+ *
461
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/reanimated.md#ashstackreanimatedlayout-animation-needs-animated-component
462
+ */
463
+ "@ashstack/reanimated/layout-animation-needs-animated-component"?: RuleSetting;
464
+ /**
465
+ * Require an animation completion callback that calls `scheduleOnRN` to read its `finished` argument. The callback also runs when the animation is cancelled, and then `finished` is false.
466
+ *
467
+ * **Default: on**, when `react-native-reanimated` is a dependency.
468
+ *
469
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/reanimated.md#ashstackreanimatedcheck-finished
470
+ */
471
+ "@ashstack/reanimated/check-finished"?: RuleSetting;
424
472
  /**
425
473
  * Require `resize` on a TurboImage so the native decoder downsamples before the bitmap reaches memory. A full-resolution decode wastes tens of megabytes and stalls the first frame.
426
474
  *
@@ -445,6 +493,46 @@ declare module "oxlint" {
445
493
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/skia.md#ashstackskiacanvas-opaque
446
494
  */
447
495
  "@ashstack/skia/canvas-opaque"?: RuleSetting;
496
+ /**
497
+ * Require a `GestureHandlerRootView` around every Gesture Handler component inside a React Native `Modal`. A `Modal` renders outside the app's root view, so those gestures never fire without one.
498
+ *
499
+ * **Default: on**, when `react-native-gesture-handler` 3 or later is a dependency.
500
+ *
501
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/gesture-handler.md#ashstackgesture-handlermodal-needs-root-view
502
+ */
503
+ "@ashstack/gesture-handler/modal-needs-root-view"?: RuleSetting;
504
+ /**
505
+ * Disallow `createWorkletRuntime` inside a component or hook. Each call starts a new JavaScript runtime and, with the default queue, a new thread; create it once at module scope and reuse it.
506
+ *
507
+ * **Default: on**, when `react-native-worklets` is a dependency.
508
+ *
509
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-runtime-in-render
510
+ */
511
+ "@ashstack/worklets/no-runtime-in-render"?: RuleSetting;
512
+ /**
513
+ * Disallow an inline function as the worklet of `scheduleOnUI`, `scheduleOnRuntime`, `runOnUIAsync`, `runOnUISync`, `runOnRuntimeAsync` or `runOnRuntimeSync` inside a function. The serialized copy is cached by function identity, so a new function object is serialized again on every call. Module scope runs once and is allowed.
514
+ *
515
+ * **Default: on**, when `react-native-worklets` is a dependency.
516
+ *
517
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-inline-worklet-schedule
518
+ */
519
+ "@ashstack/worklets/no-inline-worklet-schedule"?: RuleSetting;
520
+ /**
521
+ * Disallow `runOnUISync` and `runOnRuntimeSync`. They block the calling thread until the worklet finishes; `runOnUIAsync` and `runOnRuntimeAsync` return the same value as a promise.
522
+ *
523
+ * **Default: on**, when `react-native-worklets` is a dependency.
524
+ *
525
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-sync-runtime-call
526
+ */
527
+ "@ashstack/worklets/no-sync-runtime-call"?: RuleSetting;
528
+ /**
529
+ * Disallow a React Native Runtime `setInterval` or `setTimeout` callback that calls `scheduleOnUI` or `scheduleOnRuntime`. Each time the timer fires it waits for the JavaScript thread and sends a new job; start the timer on the target runtime instead.
530
+ *
531
+ * **Default: on**, when `react-native-worklets` is a dependency.
532
+ *
533
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-js-timer-schedule
534
+ */
535
+ "@ashstack/worklets/no-js-timer-schedule"?: RuleSetting;
448
536
  }
449
537
  }
450
538
  export {};
@@ -2,7 +2,7 @@ import type { AllowWarnDeny } from "oxlint";
2
2
  /** A severity, or a severity followed by as many of the rule's options as you want to set. */
3
3
  type RuleSetting<Options extends unknown[] = []> = AllowWarnDeny | [AllowWarnDeny, ...Partial<Options>];
4
4
  /** Every rule id `react()` adds on top of the entry below it. */
5
- export type ReactRuleId = "@ashstack/react/no-unlabeled-icon-button" | "@ashstack/react/no-svg-without-title" | "@ashstack/react/hoist-intl" | "@ashstack/react/prefer-design-system" | "@ashstack/react/components-tsx-only" | "@ashstack/query/no-inline-keys" | "@ashstack/query/no-deprecated-filters" | "@ashstack/query/require-destructured-hooks" | "@ashstack/query/no-fetch-in-query-fn" | "@ashstack/query/next-page-param-undefined" | "@ashstack/zustand/require-selector" | "@ashstack/i18n/no-bare-text" | "@ashstack/i18n/no-bare-attrs" | "@ashstack/i18n/no-bare-toast" | "@ashstack/stylex/inline-props" | "@ashstack/stylex/no-conflicting-props" | "@ashstack/stylex/no-duplicate-styles" | "@ashstack/stylex/require-tokens" | "@ashstack/stylex/spread-props" | "@ashstack/tailwind/prefer-cn" | "@ashstack/tailwind/use-logical-classes" | "@ashstack/tanstack-router/require-selector" | "@ashstack/tanstack-router/no-search-casts" | "@ashstack/effects/no-derived-state" | "@ashstack/effects/no-chain-state-updates" | "@ashstack/effects/no-event-handler" | "@ashstack/effects/no-adjust-state-on-prop-change" | "@ashstack/effects/no-reset-all-state-on-prop-change" | "@ashstack/effects/no-pass-live-state-to-parent" | "@ashstack/effects/no-pass-data-to-parent" | "@ashstack/effects/no-external-store-subscription" | "@ashstack/effects/no-initialize-state";
5
+ export type ReactRuleId = "@ashstack/react/no-unlabeled-icon-button" | "@ashstack/react/no-svg-without-title" | "@ashstack/react/hoist-intl" | "@ashstack/react/prefer-design-system" | "@ashstack/react/components-tsx-only" | "@ashstack/react/no-use-no-memo" | "@ashstack/react/no-context-provider" | "@ashstack/react/require-destructured-router" | "@ashstack/react/require-effect-cleanup" | "@ashstack/query/no-inline-keys" | "@ashstack/query/no-deprecated-filters" | "@ashstack/query/require-destructured-hooks" | "@ashstack/query/no-fetch-in-query-fn" | "@ashstack/query/next-page-param-undefined" | "@ashstack/query/exhaustive-key" | "@ashstack/query/no-overridden-callbacks" | "@ashstack/query/optimistic-update-complete" | "@ashstack/query/forward-signal" | "@ashstack/zustand/require-selector" | "@ashstack/i18n/no-bare-text" | "@ashstack/i18n/no-bare-attrs" | "@ashstack/i18n/no-bare-toast" | "@ashstack/stylex/inline-props" | "@ashstack/stylex/no-conflicting-props" | "@ashstack/stylex/no-duplicate-styles" | "@ashstack/stylex/require-tokens" | "@ashstack/stylex/spread-props" | "@ashstack/tailwind/prefer-cn" | "@ashstack/tailwind/use-logical-classes" | "@ashstack/tanstack-router/require-selector" | "@ashstack/tanstack-router/no-search-casts" | "@ashstack/effects/no-derived-state" | "@ashstack/effects/no-chain-state-updates" | "@ashstack/effects/no-event-handler" | "@ashstack/effects/no-adjust-state-on-prop-change" | "@ashstack/effects/no-reset-all-state-on-prop-change" | "@ashstack/effects/no-pass-live-state-to-parent" | "@ashstack/effects/no-pass-data-to-parent" | "@ashstack/effects/no-external-store-subscription" | "@ashstack/effects/no-initialize-state";
6
6
  declare module "oxlint" {
7
7
  interface DummyRuleMap {
8
8
  /**
@@ -59,6 +59,38 @@ declare module "oxlint" {
59
59
  "@ashstack/react/components-tsx-only"?: RuleSetting<[{
60
60
  dir?: string;
61
61
  }]>;
62
+ /**
63
+ * Disallow the `"use no memo"` directive, and its older `"use no forget"` spelling. It removes a component or file from the React Compiler, which clears the bailout report without fixing it.
64
+ *
65
+ * **Default: on.**
66
+ *
67
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react.md#ashstackreactno-use-no-memo
68
+ */
69
+ "@ashstack/react/no-use-no-memo"?: RuleSetting;
70
+ /**
71
+ * Disallow `<Context.Provider>` for a context made by React's `createContext`. React 19 renders the context itself as the provider, and React plans to deprecate `.Provider`.
72
+ *
73
+ * **Default: on.**
74
+ *
75
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react.md#ashstackreactno-context-provider
76
+ */
77
+ "@ashstack/react/no-context-provider"?: RuleSetting;
78
+ /**
79
+ * Require destructuring the result of `useRouter` and `useNavigation` at the call site. A method called on the whole object makes the React Compiler cache on that object instead of on the function.
80
+ *
81
+ * **Default: on.**
82
+ *
83
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react.md#ashstackreactrequire-destructured-router
84
+ */
85
+ "@ashstack/react/require-destructured-router"?: RuleSetting;
86
+ /**
87
+ * Require a `useEffect` or `useLayoutEffect` that adds a listener, subscribes, starts an interval, or opens a `WebSocket` or `AbortController` to return a cleanup. Without one, every re-run and unmount leaves the previous one running.
88
+ *
89
+ * **Default: on.**
90
+ *
91
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/react.md#ashstackreactrequire-effect-cleanup
92
+ */
93
+ "@ashstack/react/require-effect-cleanup"?: RuleSetting;
62
94
  /**
63
95
  * Disallow a query key written as an array literal at the call site instead of coming from a keys factory.
64
96
  *
@@ -99,6 +131,38 @@ declare module "oxlint" {
99
131
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/query.md#ashstackquerynext-page-param-undefined
100
132
  */
101
133
  "@ashstack/query/next-page-param-undefined"?: RuleSetting;
134
+ /**
135
+ * Require every value a `queryFn` reads from the function around it in that query's `queryKey` array. The cache keeps one entry per key, so a value left out shares one result across all of its values and never triggers a refetch.
136
+ *
137
+ * **Default: on**, when `@tanstack/react-query` is a dependency.
138
+ *
139
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/query.md#ashstackqueryexhaustive-key
140
+ */
141
+ "@ashstack/query/exhaustive-key"?: RuleSetting;
142
+ /**
143
+ * Disallow a spread after `onMutate`, `onSuccess`, `onError`, `onSettled`, `mutationFn`, `queryFn` or `queryKey` in a query or mutation options object. Whatever the spread carries under those keys replaces the ones written before it.
144
+ *
145
+ * **Default: on**, when `@tanstack/react-query` is a dependency.
146
+ *
147
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/query.md#ashstackqueryno-overridden-callbacks
148
+ */
149
+ "@ashstack/query/no-overridden-callbacks"?: RuleSetting;
150
+ /**
151
+ * Require a mutation whose `onMutate` writes the query cache to await `cancelQueries` before the write, return a snapshot, and roll back in `onError`. Skip one and the UI looks right until the next refresh.
152
+ *
153
+ * **Default: on**, when `@tanstack/react-query` is a dependency.
154
+ *
155
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/query.md#ashstackqueryoptimistic-update-complete
156
+ */
157
+ "@ashstack/query/optimistic-update-complete"?: RuleSetting;
158
+ /**
159
+ * Require an inline `queryFn` that calls a `*.requests` function to take the `signal` from its context. TanStack Query aborts that signal when the query is cancelled or nothing uses it any more, and only a request that received it can stop.
160
+ *
161
+ * **Default: on**, when `@tanstack/react-query` is a dependency.
162
+ *
163
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/query.md#ashstackqueryforward-signal
164
+ */
165
+ "@ashstack/query/forward-signal"?: RuleSetting;
102
166
  /**
103
167
  * Require a selector on a store hook, rather than no arguments or `undefined` in its place.
104
168
  *
@@ -13,6 +13,9 @@ export type AstNode = Parameters<NonNullable<OxVisitor[string]>>[0];
13
13
  /** What a rule receives: `options`, `sourceCode`, `report`, `filename`. */
14
14
  export type RuleContext = Parameters<CreateRule["create"]>[0];
15
15
  export type Visitor = OxVisitor;
16
+ export type Scope = ReturnType<RuleContext["sourceCode"]["getScope"]>;
17
+ /** A binding in a `Scope`, with every reference to it. */
18
+ export type Variable = Scope["variables"][number];
16
19
  /**
17
20
  * oxlint's rule metadata plus the two fields this package reads: `defaultOff`
18
21
  * for rules a consumer opts into, `packages` for a rule gated on a dependency
@@ -37,6 +40,8 @@ export type RuleBody = (Pick<CreateRule, "create"> | {
37
40
  export interface RestrictedPath {
38
41
  name: string;
39
42
  importNames?: string[];
43
+ /** On a whole-module ban: the names still allowed. */
44
+ allowImportNames?: string[];
40
45
  message: string;
41
46
  }
42
47
  export interface RestrictedPattern {
@@ -47,6 +52,19 @@ export interface RestrictedImports {
47
52
  paths?: RestrictedPath[];
48
53
  patterns?: RestrictedPattern[];
49
54
  }
55
+ /** Files where some of the shipped or added import bans do not apply. */
56
+ export interface ImportAllowance {
57
+ /** Globs, as in an oxlint `overrides` entry. */
58
+ files: string[];
59
+ /** The module whose bans are lifted there. */
60
+ from: string;
61
+ /** Only these names; leave it out to lift every ban on `from`. */
62
+ importNames?: string[];
63
+ }
64
+ /** A project's own import bans, merged into the ones the enabled modules ship. */
65
+ export interface ConsumerRestrictedImports extends RestrictedImports {
66
+ allow?: ImportAllowance[];
67
+ }
50
68
  /**
51
69
  * A module is the unit of rule organization: one rule namespace, one plugin
52
70
  * file, one optional toggle. The default export of a module's index file IS
@@ -62,6 +80,8 @@ export interface ModuleManifest {
62
80
  url: string;
63
81
  /** enable when one of these is a dependency; absent = always on */
64
82
  packages?: string[];
83
+ /** and only at this major of that dependency or later, installed or else declared */
84
+ minMajor?: number;
65
85
  /** key in the entry options that forces the module on/off; absent = auto-only */
66
86
  option?: string;
67
87
  /** activation line for RULES.md, e.g. "auto-enabled when `zod` is a dependency" */
@@ -83,6 +103,8 @@ export interface ModuleMeta {
83
103
  url: string;
84
104
  /** Enable when one of these is a dependency; absent = always on. */
85
105
  packages?: string[];
106
+ /** And only at this major of that dependency or later, installed or else declared. */
107
+ minMajor?: number;
86
108
  /** Key in the entry options that forces the module on/off; absent = auto-only. */
87
109
  option?: string;
88
110
  restrictedImports?: RestrictedImports;
@@ -141,6 +163,16 @@ export type ReactNativeOptions = ReactOptions & {
141
163
  skia?: boolean;
142
164
  /** [`@ashstack/keyboard` import bans](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/keyboard.md#ashstackkeyboard) — `react-native-keyboard-controller` */
143
165
  keyboard?: boolean;
166
+ /** [`@ashstack/gesture-handler` import bans](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/gesture-handler.md#ashstackgesture-handler) on the Gesture Handler 2 API — `react-native-gesture-handler` 3 or later */
167
+ gestureHandler?: boolean;
168
+ /** [`@ashstack/worklets/` rules](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworklets) — `react-native-worklets` */
169
+ worklets?: boolean;
170
+ /**
171
+ * Your own import bans, added to the ones the enabled modules ship. A
172
+ * `no-restricted-imports` entry in your `rules` block replaces the shipped
173
+ * bans instead, so add bans here. `allow` lifts bans in some files only.
174
+ */
175
+ restrictedImports?: ConsumerRestrictedImports;
144
176
  };
145
177
  /** The config object an entry returns: oxlint's own shape, so `defineConfig({ extends: [core()] })` typechecks. */
146
178
  export type OxlintConfig = OxlintNativeConfig;
package/dist/modules.js CHANGED
@@ -1 +1 @@
1
- import o from"./core/rules/core/index.js";import r from"./core/rules/zod/index.js";import e from"./react-native/rules/keyboard/index.js";import t from"./react-native/rules/legend-list/index.js";import m from"./react-native/rules/legend-state/index.js";import d from"./react-native/rules/react-native/index.js";import i from"./react-native/rules/reanimated/index.js";import l from"./react-native/rules/skia/index.js";import u from"./react-native/rules/turbo-image/index.js";import p from"./react-native/rules/unistyles/index.js";import M from"./react/rules/i18n/index.js";import f from"./react/rules/query/index.js";import a from"./react/rules/react/index.js";import s from"./react/rules/stylex/index.js";import n from"./react/rules/tailwind/index.js";import c from"./react/rules/tanstack-router/index.js";import x from"./react/rules/zustand/index.js";export const coreModules=[o,r],reactModules=[a,f,x,M,s,n,c],reactNativeModules=[d,p,t,m,i,u,l,e];
1
+ import o from"./core/rules/core/index.js";import r from"./core/rules/zod/index.js";import e from"./react-native/rules/gesture-handler/index.js";import t from"./react-native/rules/keyboard/index.js";import m from"./react-native/rules/legend-list/index.js";import d from"./react-native/rules/legend-state/index.js";import l from"./react-native/rules/react-native/index.js";import i from"./react-native/rules/reanimated/index.js";import u from"./react-native/rules/skia/index.js";import p from"./react-native/rules/turbo-image/index.js";import M from"./react-native/rules/unistyles/index.js";import f from"./react-native/rules/worklets/index.js";import a from"./react/rules/i18n/index.js";import s from"./react/rules/query/index.js";import n from"./react/rules/react/index.js";import c from"./react/rules/stylex/index.js";import g from"./react/rules/tailwind/index.js";import k from"./react/rules/tanstack-router/index.js";import x from"./react/rules/zustand/index.js";export const coreModules=[o,r],reactModules=[n,s,x,a,c,g,k],reactNativeModules=[l,M,m,d,i,p,u,t,e,f];
@@ -0,0 +1 @@
1
+ import{calleeName as p,gate as u,isFunction as y,isWithin as l,problem as f,propertyValue as i}from"../../../lib/ast.js";import{optionsArgument as h,QUERY_OPTIONS_CALLS as d,queryFunctions as m}from"./shared.js";const v=(r)=>{let e=r;while(e?.type==="TSAsExpression"||e?.type==="TSSatisfiesExpression")e=e.expression;return e?.type==="ArrayExpression"?e:null},S=(r)=>{let e=r;while(e.parent?.type==="MemberExpression"&&e.parent.object===e)e=e.parent;return e.parent?.type==="CallExpression"&&e.parent.callee===e},g=(r)=>r.parent?.type==="TSTypeReference"||r.parent?.type==="TSQualifiedName",q=(r)=>r.defs.some(({node:e})=>e.type==="FunctionDeclaration"||e.type==="VariableDeclarator"&&(y(e.init)||p(e.init)==="useQueryClient")),b=(r,e)=>{const o=new Set;for(const t of r.sourceCode.getScope(e).through){const s=t.resolved;if(s?.scope.variableScope.type!=="function"||q(s))continue;const{identifier:n}=t;if(t.isRead()&&!S(n)&&!g(n))o.add(s)}return o};export const exhaustiveKey=f("Require every value a `queryFn` reads from the function around it in that query's `queryKey` array. The cache keeps one entry per key, so a value left out shares one result across all of its values and never triggers a refetch.",{createOnce(r){return{before(){return u(r,"queryKey")},CallExpression(e){const o=h(e,d),t=v(i(o,"queryKey"));if(t===null)return;const s=new Set;for(const n of m(i(o,"queryFn")))for(const a of b(r,n))if(!a.references.some((c)=>l(c.identifier,t)))s.add(a);for(const{name:n}of s)r.report({node:t,message:`Add \`${n}\` to this \`queryKey\`; the \`queryFn\` reads it. The cache keeps one entry per key, so without it every \`${n}\` shares one result and changing it never refetches.`})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as u,findInSubtree as l,gate as c,problem as p,propertyKeyName as f,propertyValue as y,receiverName as m}from"../../../lib/ast.js";import{optionsArgument as d,QUERY_OPTIONS_CALLS as h,queryFunctions as q}from"./shared.js";const g=/\.requests$/,S=(r)=>{if(r.type!=="ArrowFunctionExpression"&&r.type!=="FunctionExpression")return!1;const[e]=r.params;if(e===void 0)return!0;if(e.type!=="ObjectPattern")return!1;return e.properties.every((t)=>t.type==="Property"&&f(t)!=="signal")};export const forwardSignal=p("Require an inline `queryFn` that calls a `*.requests` function to take the `signal` from its context. TanStack Query aborts that signal when the query is cancelled or nothing uses it any more, and only a request that received it can stop.",{createOnce(r){const e=new Set;return{before(){e.clear();return c(r,".requests")},ImportDeclaration(t){if(!g.test(t.source.value))return;for(const s of t.specifiers)e.add(s.local.name)},CallExpression(t){const s=d(t,h);for(const o of q(y(s,"queryFn"))){if(!S(o))continue;const a=l(o,(n)=>{if(n.type!=="CallExpression")return!1;const i=n.callee.type==="Identifier"?n.callee.name:m(n);return i!==null&&e.has(i)});if(a===null)continue;r.report({node:o,message:`Take \`{ signal }\` in this \`queryFn\` and pass it to \`${u(a)}\`, on through to the client. TanStack Query aborts it when the query is cancelled or unused, and only a request that received it stops.`})}}}}});
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{nextPageParamUndefined as r}from"./next-page-param-undefined.js";import{noDeprecatedFilters as t}from"./no-deprecated-filters.js";import{noFetchInQueryFn as n}from"./no-fetch-in-query-fn.js";import{noInlineKeys as o}from"./no-inline-keys.js";import{requireDestructuredHooks as a}from"./require-destructured-hooks.js";export default e({meta:{name:"@ashstack/query"},url:import.meta.url,packages:["@tanstack/react-query"],option:"query",docsWhen:"auto-enabled by `react()` when `@tanstack/react-query` is a dependency",rules:{"no-inline-keys":o,"no-deprecated-filters":t,"require-destructured-hooks":a,"no-fetch-in-query-fn":n,"next-page-param-undefined":r}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{exhaustiveKey as r}from"./exhaustive-key.js";import{forwardSignal as t}from"./forward-signal.js";import{nextPageParamUndefined as o}from"./next-page-param-undefined.js";import{noDeprecatedFilters as a}from"./no-deprecated-filters.js";import{noFetchInQueryFn as i}from"./no-fetch-in-query-fn.js";import{noInlineKeys as n}from"./no-inline-keys.js";import{noOverriddenCallbacks as m}from"./no-overridden-callbacks.js";import{optimisticUpdateComplete as d}from"./optimistic-update-complete.js";import{requireDestructuredHooks as p}from"./require-destructured-hooks.js";export default e({meta:{name:"@ashstack/query"},url:import.meta.url,packages:["@tanstack/react-query"],option:"query",docsWhen:"auto-enabled by `react()` when `@tanstack/react-query` is a dependency",rules:{"no-inline-keys":n,"no-deprecated-filters":a,"require-destructured-hooks":p,"no-fetch-in-query-fn":i,"next-page-param-undefined":o,"exhaustive-key":r,"no-overridden-callbacks":m,"optimistic-update-complete":d,"forward-signal":t}});
@@ -0,0 +1 @@
1
+ import{gate as u,problem as f,propertyKeyName as c}from"../../../lib/ast.js";import{MUTATION_OPTIONS_CALLS as l,optionsArgument as d,QUERY_OPTIONS_CALLS as m}from"./shared.js";const p=new Set(["onSuccess","onError","onSettled"]),y=new Set(["onMutate",...p,"mutationFn","queryFn","queryKey"]),S=new Set([...m,...l]),h=(t,r)=>{if(r.type!=="SpreadElement"||r.argument.type!=="Identifier")return new Set;const{argument:n}=r,e=t.sourceCode.getScope(r).references.find((i)=>i.identifier===n)?.resolved?.defs[0]?.name.parent,s=e?.type==="RestElement"?e.parent:null;if(s?.type!=="ObjectPattern")return new Set;return new Set(s.properties.map(c))},O=(t)=>{const r=t.map((e)=>`\`${e}\``).join(", "),n=t.find((e)=>p.has(e)),o=n===void 0?"":` To keep the caller's \`${n}\` too, destructure it out (\`const { ${n}, ...rest } = config\`) and call it from yours.`;return`Move this spread above ${r}: a spread replaces every key it shares with the properties written before it.${o}`};export const noOverriddenCallbacks=f("Disallow a spread after `onMutate`, `onSuccess`, `onError`, `onSettled`, `mutationFn`, `queryFn` or `queryKey` in a query or mutation options object. Whatever the spread carries under those keys replaces the ones written before it.",{createOnce(t){return{before(){return u(t,"...")},CallExpression(r){const n=d(r,S);if(n?.type!=="ObjectExpression")return;const o=[];for(const e of n.properties){if(e.type==="Property"){const a=c(e);if(y.has(a))o.push(a);continue}const s=h(t,e),i=o.filter((a)=>!s.has(a));if(i.length>0)t.report({node:e,message:O(i)})}}}}});
@@ -0,0 +1 @@
1
+ import{crossesFunctionBefore as l,findInSubtree as h,FUNCTION_TYPES as p,gate as f,isFunction as m,isMemberCall as o,problem as w,propertyValue as c,subtreeHas as s}from"../../../lib/ast.js";import{MUTATION_OPTIONS_CALLS as y,optionsArgument as b}from"./shared.js";const i={cancel:"Await `queryClient.cancelQueries({ queryKey })` before this first cache write. A refetch already in flight can otherwise land after it and silently revert the optimistic value.",snapshot:"Return the snapshot from `onMutate`: `return { previous }`. It reaches `onError` as its third argument, the only record of what to restore.",rollback:"Add an `onError` that writes the `onMutate` snapshot back. Without it a failed mutation leaves the optimistic value in the cache."},u=(e)=>o(e,"setQueryData")||o(e,"setQueriesData"),d=(e,r)=>s(e,(n)=>n.type==="AwaitExpression"&&n.end<=r.start&&s(n.argument,(t)=>o(t,"cancelQueries"))),g=(e)=>{if(e.type==="ArrowFunctionExpression"&&e.expression)return!u(e.body);return s(e,(r)=>r.type==="ReturnStatement"&&r.argument!==null&&!u(r.argument)&&!l(r,e,p))};export const optimisticUpdateComplete=w("Require a mutation whose `onMutate` writes the query cache to await `cancelQueries` before the write, return a snapshot, and roll back in `onError`. Skip one and the UI looks right until the next refresh.",{createOnce(e){return{before(){return f(e,"onMutate")},CallExpression(r){const n=b(r,y),t=c(n,"onMutate");if(t===null||!m(t))return;const a=h(t,u);if(a===null)return;if(!d(t,a))e.report({node:a,message:i.cancel});if(!g(t))e.report({node:t,message:i.snapshot});if(c(n,"onError")===null)e.report({node:t,message:i.rollback})}}}});
@@ -1 +1 @@
1
- import{problem as a}from"../../../lib/ast.js";const c="Destructure this hook at the call site: `const { data } = useFooQuery()`.",u=/^@\/api\/.*\.(?:queries|mutations)$/;export const requireDestructuredHooks=a("Require destructuring the result of a hook imported from an `@/api/*.queries` or `@/api/*.mutations` module.",{createOnce(n){const o=new Set,r=[];return{before(){o.clear();r.length=0},ImportDeclaration(e){if(!u.test(e.source.value))return;for(const t of e.specifiers)if(t.type==="ImportSpecifier")o.add(t.local.name)},VariableDeclarator(e){const{id:t,init:s}=e;if(t.type!=="Identifier")return;if(s?.type!=="CallExpression")return;const{callee:i}=s;if(i.type!=="Identifier"||!/^use[A-Z]/.test(i.name))return;r.push({node:t,hook:i.name})},"Program:exit"(){for(const e of r){if(!o.has(e.hook))continue;n.report({node:e.node,message:c})}}}}});
1
+ import{requireDestructured as r}from"../../../lib/destructured-hooks.js";const o="Destructure this hook at the call site: `const { data } = useFooQuery()`.",u=/^@\/api\/.*\.(?:queries|mutations)$/;export const requireDestructuredHooks=r("Require destructuring the result of a hook imported from an `@/api/*.queries` or `@/api/*.mutations` module.",(e)=>u.test(e.source.value)?e.specifiers.flatMap((t)=>t.type==="ImportSpecifier"?[t.local.name]:[]):[],()=>o);
@@ -0,0 +1 @@
1
+ import{calleeName as r,isFunction as n}from"../../../lib/ast.js";export const QUERY_OPTIONS_CALLS=new Set(["queryOptions","infiniteQueryOptions","useQuery","useInfiniteQuery","useSuspenseQuery","useSuspenseInfiniteQuery"]),MUTATION_OPTIONS_CALLS=new Set(["useMutation","mutationOptions"]),optionsArgument=(e,s)=>{if(e.type!=="CallExpression"||!s.has(r(e)))return null;const[t]=e.arguments;return t?.type==="ObjectExpression"?t:null},queryFunctions=(e)=>{if(e?.type==="ConditionalExpression")return[e.consequent,e.alternate].filter(n);return e!==null&&n(e)?[e]:[]};
@@ -1 +1 @@
1
- import{defineModule as t}from"../../../lib/module.js";import{componentsTsxOnly as o}from"./components-tsx-only.js";import{hoistIntl as e}from"./hoist-intl.js";import{noSvgWithoutTitle as n}from"./no-svg-without-title.js";import{noUnlabeledIconButton as r}from"./no-unlabeled-icon-button.js";import{preferDesignSystem as i}from"./prefer-design-system.js";export default t({meta:{name:"@ashstack/react"},url:import.meta.url,docsWhen:"always on via `react()` and every entry above it",rules:{"no-unlabeled-icon-button":r,"no-svg-without-title":n,"hoist-intl":e,"prefer-design-system":i,"components-tsx-only":o}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{componentsTsxOnly as o}from"./components-tsx-only.js";import{hoistIntl as r}from"./hoist-intl.js";import{noContextProvider as t}from"./no-context-provider.js";import{noSvgWithoutTitle as n}from"./no-svg-without-title.js";import{noUnlabeledIconButton as m}from"./no-unlabeled-icon-button.js";import{noUseNoMemo as i}from"./no-use-no-memo.js";import{preferDesignSystem as u}from"./prefer-design-system.js";import{requireDestructuredRouter as s}from"./require-destructured-router.js";import{requireEffectCleanup as p}from"./require-effect-cleanup.js";export default e({meta:{name:"@ashstack/react"},url:import.meta.url,docsWhen:"always on via `react()` and every entry above it",rules:{"no-unlabeled-icon-button":m,"no-svg-without-title":n,"hoist-intl":r,"prefer-design-system":u,"components-tsx-only":o,"no-use-no-memo":i,"no-context-provider":t,"require-destructured-router":s,"require-effect-cleanup":p}});
@@ -0,0 +1 @@
1
+ import{gate as i,importBinding as c,problem as d}from"../../../lib/ast.js";export const noContextProvider=d("Disallow `<Context.Provider>` for a context made by React's `createContext`. React 19 renders the context itself as the provider, and React plans to deprecate `.Provider`.",{createOnce(a){const r=c("react","createContext"),o=new Set;return{before(){r.clear();o.clear();return i(a,".Provider")},ImportDeclaration(e){r.add(e)},VariableDeclarator(e){if(e.id.type==="Identifier"&&r.isCall(e.init))o.add(e.id.name)},JSXOpeningElement(e){const{name:t}=e;if(t.type!=="JSXMemberExpression"||t.property.name!=="Provider")return;if(t.object.type!=="JSXIdentifier"||!o.has(t.object.name))return;const n=t.object.name;a.report({node:t,message:`Render \`<${n} value={…}>\` instead of \`<${n}.Provider>\`. React 19 makes the context its own provider, and React plans to deprecate \`.Provider\`.`})}}}});
@@ -0,0 +1 @@
1
+ import{gate as o,problem as i}from"../../../lib/ast.js";const r=new Set(["use no memo","use no forget"]);export const noUseNoMemo=i('Disallow the `"use no memo"` directive, and its older `"use no forget"` spelling. It removes a component or file from the React Compiler, which clears the bailout report without fixing it.',{createOnce(t){return{before(){return o(t,"use no ")},ExpressionStatement(e){if(!r.has(e.directive??""))return;t.report({node:e,message:`Delete \`"${e.directive??""}"\` and fix what the compiler bails out on. The directive opts this code out of the React Compiler, so it alone stops being memoised and the bailout is hidden instead of fixed.`})}}}});
@@ -0,0 +1 @@
1
+ import{importedNames as a}from"../../../lib/ast.js";import{requireDestructured as r}from"../../../lib/destructured-hooks.js";const u={"expo-router":new Set(["useRouter","useNavigation"]),"@react-navigation/native":new Set(["useNavigation"])};export const requireDestructuredRouter=r("Require destructuring the result of `useRouter` and `useNavigation` at the call site. A method called on the whole object makes the React Compiler cache on that object instead of on the function.",(e)=>a(e,e.source.value).flatMap(({imported:t,local:o})=>u[e.source.value]?.has(t)?[o]:[]),(e)=>`Destructure the methods you call from \`${e}()\`, as in \`const { push } = ${e}()\`. Called on the whole object, the React Compiler caches on the object instead of on the function.`);
@@ -0,0 +1 @@
1
+ import{calleeName as n,crossesFunctionBefore as a,findInSubtree as i,FUNCTION_TYPES as c,gate as l,problem as p,subtreeHas as E}from"../../../lib/ast.js";const f=new Set(["useEffect","useLayoutEffect"]),b=new Set(["addEventListener","addListener","subscribe","setInterval"]),m=new Set(["WebSocket","AbortController"]),o=(e)=>e.type==="NewExpression"&&e.callee.type==="Identifier"&&m.has(e.callee.name),y=(e)=>b.has(n(e))||o(e),S=(e)=>e.type==="NewExpression"&&e.callee.type==="Identifier"?`new ${e.callee.name}`:n(e),u=(e)=>n(e)!=="setInterval"&&!o(e),g=(e)=>{if(e.type==="ArrowFunctionExpression"&&e.expression)return u(e.body);return E(e,(t)=>t.type==="ReturnStatement"&&t.argument!==null&&u(t.argument)&&!a(t,e,c))};export const requireEffectCleanup=p("Require a `useEffect` or `useLayoutEffect` that adds a listener, subscribes, starts an interval, or opens a `WebSocket` or `AbortController` to return a cleanup. Without one, every re-run and unmount leaves the previous one running.",{createOnce(e){return{before(){return l(e,"Effect")},CallExpression(t){if(!f.has(n(t)))return;const[r]=t.arguments;if(r?.type!=="ArrowFunctionExpression"&&r?.type!=="FunctionExpression")return;const s=i(r.body,y);if(s===null||g(r))return;e.report({node:s,message:`Return a cleanup from this effect that undoes \`${S(s)}\`: remove the listener, unsubscribe, \`clearInterval\`, \`close()\` or \`abort()\`. Without one, every re-run and unmount leaves the previous one running.`})}}}});
@@ -3,12 +3,12 @@ export declare const banGroups: BanGroup[];
3
3
  /**
4
4
  * React Native / Expo entry — everything in react plus generic RN rules, with
5
5
  * per-library modules (unistyles, legendList, legendState, reanimated,
6
- * turboImage, skia, keyboard) auto-detected from your dependencies. Your
6
+ * turboImage, skia, keyboard, gestureHandler, worklets) auto-detected from your dependencies. Your
7
7
  * `rules` block always overrides.
8
8
  *
9
9
  * @see [every rule `react-native()` sets](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/entries/react-native.md#react-native)
10
10
  */
11
- declare const reactNative: (options?: ReactNativeOptions) => OxlintConfig;
11
+ declare const reactNative: ({ restrictedImports, ...options }?: ReactNativeOptions) => OxlintConfig;
12
12
  export { reactNative };
13
13
  export type { CoreRuleId } from "../lib/rule-types/core.js";
14
14
  export type { ReactRuleId } from "../lib/rule-types/react.js";
@@ -1 +1 @@
1
- import{TEST_FILES as a}from"../core/index.js";import{mergeConfigs as r}from"../lib/merge.js";import{composeModules as s}from"../lib/module.js";import{coreRegistry as o,reactNativeRegistry as i,reactRegistry as n}from"../lib/registry.js";import c,{COMPONENT_MAX_COMPLEXITY as p,COMPONENT_MAX_LINES as m}from"../react/index.js";export const banGroups=[{packages:["react-native-gesture-handler"],restrictedImports:{paths:[{name:"react-native",importNames:["Pressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback"],message:"Import `Pressable` from `react-native-gesture-handler`. Inside a SwiftUI/Compose host view, keep React Native's `Pressable` and suppress this rule naming the host."}]}},{packages:["expo-router"],restrictedImports:{patterns:[{group:["@react-navigation/stack","@react-navigation/bottom-tabs"],message:"Use expo-router's `Stack` / `NativeTabs` instead of a raw react-navigation navigator."}]}},{packages:["expo-font"],restrictedImports:{paths:[{name:"expo-font",importNames:["useFonts","loadAsync"],message:"Declare the fonts in the `expo-font` config plugin so they load at build time, instead of `useFonts`/`loadAsync` at runtime."}]}},{packages:["react-native-quick-crypto"],restrictedImports:{paths:[{name:"crypto-js",message:"Use `react-native-quick-crypto` instead — `crypto-js` is pure JavaScript and runs orders of magnitude slower."}]}}];const l={"eslint/no-empty":"error","eslint/no-empty-function":"error"},u={"@ashstack/effects/no-event-handler":"off"},d=(e)=>e?{}:{"@ashstack/react-native/no-manual-memo":"off"},reactNative=(e={})=>{const t=s([...o,...n,...i],e,banGroups);return r(c(e),{jsPlugins:t.jsPlugins,globals:{__DEV__:"readonly"},rules:{...l,...u,"no-restricted-imports":["error",t.restricted],...t.rules,"@ashstack/core/max-lines":["error",m],"@ashstack/core/max-complexity":["error",p],...d(e.reactCompiler??!0)},ignorePatterns:["**/.expo/**","**/android/**","**/ios/**"],overrides:[{files:a,rules:{"@ashstack/react-native/no-dynamic-import":"off","@ashstack/react-native/hoist-stateless-function":"off"}}]})};export{reactNative};export default reactNative;
1
+ import{TEST_FILES as s}from"../core/index.js";import{mergeConfigs as o}from"../lib/merge.js";import{composeModules as i,restrictedImportsConfig as n}from"../lib/module.js";import{coreRegistry as c,reactNativeRegistry as p,reactRegistry as m}from"../lib/registry.js";import l,{COMPONENT_MAX_COMPLEXITY as u,COMPONENT_MAX_LINES as f}from"../react/index.js";export const banGroups=[{packages:["react-native-gesture-handler"],restrictedImports:{paths:[{name:"react-native",importNames:["Pressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback"],message:"Import `Pressable` from `react-native-gesture-handler`; on Gesture Handler 3, its `Touchable` for an opacity or highlight press effect. Inside a SwiftUI/Compose host view, keep React Native's `Pressable` and suppress this rule naming the host."}]}},{packages:["expo-router"],restrictedImports:{patterns:[{group:["@react-navigation/stack","@react-navigation/bottom-tabs"],message:"Use expo-router's `Stack` / `NativeTabs` instead of a raw react-navigation navigator."}]}},{packages:["expo-font"],restrictedImports:{paths:[{name:"expo-font",importNames:["useFonts","loadAsync"],message:"Declare the fonts in the `expo-font` config plugin so they load at build time, instead of `useFonts`/`loadAsync` at runtime."}]}},{packages:["react-native-quick-crypto"],restrictedImports:{paths:[{name:"crypto-js",message:"Use `react-native-quick-crypto` instead — `crypto-js` is pure JavaScript and runs orders of magnitude slower."}]}}];const d={"eslint/no-empty":"error","eslint/no-empty-function":"error"},g={"@ashstack/effects/no-event-handler":"off"},h=(e)=>e?{}:{"@ashstack/react-native/no-manual-memo":"off"},reactNative=({restrictedImports:e,...t}={})=>{const a=i([...c,...m,...p],t,banGroups),r=n(a.restricted,e);return o(l(t),{jsPlugins:a.jsPlugins,globals:{__DEV__:"readonly"},rules:{...d,...g,...r.rules,...a.rules,"@ashstack/core/max-lines":["error",f],"@ashstack/core/max-complexity":["error",u],...h(t.reactCompiler??!0)},ignorePatterns:["**/.expo/**","**/android/**","**/ios/**"],overrides:[{files:s,rules:{"@ashstack/react-native/no-dynamic-import":"off","@ashstack/react-native/hoist-stateless-function":"off"}},...r.overrides]})};export{reactNative};export default reactNative;
@@ -0,0 +1 @@
1
+ import{defineModule as s}from"../../../lib/module.js";import{modalNeedsRootView as o}from"./modal-needs-root-view.js";const e="react-native-gesture-handler",r=["PanGestureHandler","TapGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","ForceTouchGestureHandler","NativeViewGestureHandler"],n=["GestureHandlerGestureEvent","GestureHandlerStateChangeEvent",...r.flatMap((t)=>[`${t}GestureEvent`,`${t}StateChangeEvent`,`${t}Props`,`${t}Properties`])],a=["RawButton","BaseButton","RectButton","BorderlessButton"],u=["TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback"],c=[...a.flatMap((t)=>[`${t}Props`,`Legacy${t}Props`,`Legacy${t}Properties`]),"TouchableOpacityProps","TouchableHighlightProps","TouchableWithoutFeedbackProps"],i=["LegacyPressable","LegacyScrollView","LegacyFlatList","LegacyRefreshControl","LegacySwitch","LegacyTextInput","LegacyPressableProps","LegacyFlingGesture","LegacyHoverGesture","LegacyLongPressGesture","LegacyManualGesture","LegacyPanGesture","LegacyPinchGesture","LegacyRotationGesture","LegacyTapGesture","LegacyComposedGesture","LegacyGestureStateManager"];export default s({meta:{name:"@ashstack/gesture-handler"},url:import.meta.url,packages:[e],minMajor:3,option:"gestureHandler",docsWhen:"auto-enabled when `react-native-gesture-handler` 3 or later is a dependency",rules:{"modal-needs-root-view":o},restrictedImports:{paths:[{name:e,importNames:["Gesture"],message:"`Gesture.*()` builders are the Gesture Handler 2 API. Create each gesture with its hook (`Gesture.Pan()` → `usePanGesture`) and pass it to `GestureDetector`; combine gestures with `useSimultaneousGestures`, `useCompetingGestures` (was `Race`) or `useExclusiveGestures`."},{name:e,importNames:r,message:"`*GestureHandler` components are the Gesture Handler 2 API. Create the gesture with its hook (`PanGestureHandler` → `usePanGesture`, `NativeViewGestureHandler` → `useNativeGesture`) and wrap the view in `GestureDetector`. Force touch has no Gesture Handler 3 gesture."},{name:e,importNames:[...a,...a.map((t)=>`Legacy${t}`),...u,...c],message:"Use `Touchable` from `react-native-gesture-handler`, typed `TouchableProps`: `activeOpacity` for an opacity press effect, `activeUnderlayOpacity` for a highlight, `androidRipple` for a ripple. Gesture Handler 3 deprecates its buttons and `Touchable*` components."},{name:e,importNames:i,message:"Import the name without the `Legacy` prefix (`LegacyScrollView` → `ScrollView`, `LegacyPanGesture` → `PanGesture`). `Legacy*` names are the Gesture Handler 2 API."},{name:e,importNames:["LegacyText"],message:"Use React Native's `Text` and wrap it in `GestureDetector` or `VirtualGestureDetector`."},{name:e,importNames:["LegacyDrawerLayoutAndroid"],message:"Use `ReanimatedDrawerLayout` from `react-native-gesture-handler/ReanimatedDrawerLayout`, or React Native's `DrawerLayoutAndroid`."},{name:e,importNames:["createNativeWrapper","legacy_createNativeWrapper"],message:"Create the gesture with `useNativeGesture` and wrap the native component in `GestureDetector`, instead of wrapping the component with `createNativeWrapper`."},{name:e,importNames:["GestureType"],message:"Type a Gesture Handler 3 gesture as `SingleGesture`, `ComposedGesture` for a combination, or the hook's own type (`PanGesture`, `TapGesture`, …). `GestureType` describes the Gesture Handler 2 builders."},{name:e,importNames:n,message:"Use the Gesture Handler 3 type for the gesture: `PanGestureConfig` for its config, `PanGestureEvent` (or `PanGestureActiveEvent`, `PanGestureBeginEvent`, …) for its callbacks. These types describe the Gesture Handler 2 handler components."},{name:e,importNames:["LegacyExclusiveGesture","LegacyRaceGesture","LegacySimultaneousGesture"],message:"Type a combined gesture as `ComposedGesture`, what `useSimultaneousGestures`, `useCompetingGestures` and `useExclusiveGestures` return."},{name:e,importNames:["LegacyForceTouchGesture"],message:"Gesture Handler 3 has no force touch gesture; `LegacyForceTouchGesture` types the Gesture Handler 2 one."}]}});
@@ -0,0 +1 @@
1
+ import{ancestors as p,findInSubtree as m,gate as h,importedNames as l,problem as w}from"../../../lib/ast.js";const d="react-native-gesture-handler",u="GestureHandlerRootView",g=`Wrap this \`Modal\`'s content in \`${u}\` with \`style={{ flex: 1 }}\`. A \`Modal\` renders outside the app's root view, so the gestures inside it never fire without one.`,c=(n,r)=>r.type==="JSXElement"&&r.openingElement.name.type==="JSXIdentifier"&&n.has(r.openingElement.name.name);export const modalNeedsRootView=w("Require a `GestureHandlerRootView` around every Gesture Handler component inside a React Native `Modal`. A `Modal` renders outside the app's root view, so those gestures never fire without one.",{createOnce(n){const r=new Set,s=new Set,i=new Set,f=(e,o)=>{for(const t of p(e)){if(t===o)return!1;if(c(i,t))return!0}return!1};return{before(){r.clear();s.clear();i.clear();return h(n,"Modal")},ImportDeclaration(e){for(const{imported:t,local:a}of l(e,"react-native"))if(t==="Modal")r.add(a);const{value:o}=e.source;if(o!==d&&!o.startsWith(`${d}/`))return;for(const t of e.specifiers)s.add(t.local.name);for(const{imported:t,local:a}of l(e,o)){if(t!==u)continue;s.delete(a);i.add(a)}},JSXElement(e){if(!c(r,e))return;if(m(e.children,(t)=>c(s,t)&&!f(t,e))!==null)n.report({node:e.openingElement.name,message:g})}}}});
@@ -1 +1 @@
1
- import{attributeName as o,gate as s,problem as a}from"../../../lib/ast.js";import{literalKind as d}from"./shared.js";export const noInlineRenderItemProps=a("Disallow inline object and array literals on props nested inside `renderItem`. A row whose props take a new identity every render can never be skipped.",{createOnce(n){let e=0;return{before(){e=0;return s(n,"renderItem")},JSXAttribute(r){if(o(r)==="renderItem"){e++;return}if(e===0)return;const{value:t}=r;if(t?.type!=="JSXExpressionContainer")return;const i=d(t.expression);if(i===null)return;n.report({node:t,message:`Pass \`item\` or its primitive fields and build this ${i} inside the row, or hoist it to module scope when static — a fresh ${i} each render blocks row skipping.`})},"JSXAttribute:exit"(r){if(o(r)==="renderItem")e--}}}});
1
+ import{attributeName as s,gate as o,isFunction as l,problem as a}from"../../../lib/ast.js";import{literalKind as d}from"./shared.js";const c="Pass the handler itself with `item` or its id (`onSelect={select}`) and build this callback inside the row — a fresh function each render blocks row skipping.",p=(r)=>{if(l(r))return c;const e=d(r);if(e===null)return null;return`Pass \`item\` or its primitive fields and build this ${e} inside the row, or hoist it to module scope when static — a fresh ${e} each render blocks row skipping.`};export const noInlineRenderItemProps=a("Disallow inline object literals, array literals and functions on props nested inside `renderItem`. A row whose props take a new identity every render can never be skipped.",{createOnce(r){let e=0;return{before(){e=0;return o(r,"renderItem")},JSXAttribute(t){if(s(t)==="renderItem"){e++;return}if(e===0)return;const{value:i}=t;if(i?.type!=="JSXExpressionContainer")return;const n=p(i.expression);if(n!==null)r.report({node:i,message:n})},"JSXAttribute:exit"(t){if(s(t)==="renderItem")e--}}}});
@@ -0,0 +1 @@
1
+ import{enclosingComponentOrHook as n,gate as a,importedNames as i,problem as p}from"../../../lib/ast.js";const c="Use `useObserve` here, which disposes on unmount, or keep the function `observe` returns and call it in a cleanup. Dropped, each run starts another observer that nothing ever stops.";export const disposeObserve=p("Disallow an `observe(...)` statement inside a component or hook that drops the dispose function it returns. Each run starts an observer nothing ever stops.",{createOnce(t){const o=new Set;return{before(){o.clear();return a(t,"observe")},ImportDeclaration(r){for(const{imported:e,local:s}of i(r,"@legendapp/state"))if(e==="observe")o.add(s)},ExpressionStatement(r){const{expression:e}=r;if(e.type!=="CallExpression"||e.callee.type!=="Identifier")return;if(!o.has(e.callee.name)||n(r)===null)return;t.report({node:e,message:c})}}}});
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{naming as o}from"./naming.js";import{noAssignment as t}from"./no-assignment.js";import{noNestedObservable as n}from"./no-nested-observable.js";import{noObjectSelector as r}from"./no-object-selector.js";import{noObservableInComponent as a}from"./no-observable-in-component.js";import{noPeekInSelector as s}from"./no-peek-in-selector.js";import{noReactMirror as m}from"./no-react-mirror.js";import{noUntrackedGetInJsx as p}from"./no-untracked-get-in-jsx.js";export default e({meta:{name:"@ashstack/legend-state"},url:import.meta.url,packages:["@legendapp/state"],option:"legendState",docsWhen:"auto-enabled when `@legendapp/state` is a dependency",rules:{"no-assignment":t,naming:o,"no-nested-observable":n,"no-react-mirror":m,"no-untracked-get-in-jsx":p,"no-peek-in-selector":s,"no-object-selector":r,"no-observable-in-component":a},restrictedImports:{paths:[{name:"@legendapp/state/react",importNames:["use$","useSelector"],message:"Use `useValue` from `@legendapp/state/react`; `use$` and `useSelector` are deprecated."}]}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{disposeObserve as t}from"./dispose-observe.js";import{naming as o}from"./naming.js";import{noAssignment as r}from"./no-assignment.js";import{noNestedObservable as n}from"./no-nested-observable.js";import{noObjectSelector as a}from"./no-object-selector.js";import{noObservableInComponent as s}from"./no-observable-in-component.js";import{noPeekInSelector as m}from"./no-peek-in-selector.js";import{noReactMirror as i}from"./no-react-mirror.js";import{noUntrackedCollectionRead as p}from"./no-untracked-collection-read.js";import{noUntrackedGetInJsx as d}from"./no-untracked-get-in-jsx.js";export default e({meta:{name:"@ashstack/legend-state"},url:import.meta.url,packages:["@legendapp/state"],option:"legendState",docsWhen:"auto-enabled when `@legendapp/state` is a dependency",rules:{"no-assignment":r,naming:o,"no-nested-observable":n,"no-react-mirror":i,"no-untracked-get-in-jsx":d,"no-peek-in-selector":m,"no-object-selector":a,"no-observable-in-component":s,"no-untracked-collection-read":p,"dispose-observe":t},restrictedImports:{paths:[{name:"@legendapp/state/react",importNames:["use$","useSelector"],message:"Use `useValue` from `@legendapp/state/react`; `use$` and `useSelector` are deprecated."},{name:"@legendapp/state/react",importNames:["observer"],message:"Read the value with `useValue` instead of wrapping the component in `observer`; the React Compiler and `useValue` cover what it did. Inside `observer` a bare `.get()` tracks, and moved out of it the same line silently stops updating."}]}});
@@ -1 +1 @@
1
- import{gate as u,isFunction as l,problem as p}from"../../../lib/ast.js";import{isObservableRef as f,textOf as k}from"./shared.js";const b=new Set(["useValue","observe","useObserve","useObserveEffect","when","whenReady"]),g=(e)=>{const{callee:r}=e;if(r.type!=="Identifier")return null;if(!b.has(r.name))return null;const n=e.arguments[0];return n&&l(n)?n:null},h=(e)=>{if(e.type!=="MemberExpression"||e.computed)return null;if(e.property.type!=="Identifier"||e.property.name!=="peek")return null;const{object:r}=e;return f(r)?r:null};export const noPeekInSelector=p("`peek()` never subscribes, so a selector or tracking callback that uses it never re-runs. Call `get()` there and keep `peek()` for handlers.",{createOnce(e){let r=new WeakSet,n=0;const s=(t)=>{if(r.has(t))n++},o=(t)=>{if(r.has(t))n--};return{before(){r=new WeakSet;n=0;return u(e,".peek()")},CallExpression(t){const i=g(t);if(i)r.add(i);if(n===0)return;const a=h(t.callee);if(!a)return;const c=k(e,a);e.report({node:t,message:`Use \`${c}.get()\` inside this selector and keep \`peek()\` for handlers and async work — \`peek()\` never subscribes, so nothing re-runs.`})},ArrowFunctionExpression:s,"ArrowFunctionExpression:exit":o,FunctionExpression:s,"FunctionExpression:exit":o}}});
1
+ import{gate as s,problem as o}from"../../../lib/ast.js";import{inTrackingContext as p,isObservableRef as i,textOf as a}from"./shared.js";const b=(e)=>{if(e.type!=="MemberExpression"||e.computed)return null;if(e.property.type!=="Identifier"||e.property.name!=="peek")return null;const{object:r}=e;return i(r)?r:null};export const noPeekInSelector=o("`peek()` never subscribes, so a selector or tracking callback that uses it never re-runs. Call `get()` there and keep `peek()` for handlers.",{createOnce(e){return{before(){return s(e,".peek()")},CallExpression(r){const t=b(r.callee);if(!t||!p(r))return;const n=a(e,t);e.report({node:r,message:`Use \`${n}.get()\` inside this selector and keep \`peek()\` for handlers and async work — \`peek()\` never subscribes, so nothing re-runs.`})}}}});
@@ -0,0 +1 @@
1
+ import{gate as s,problem as a}from"../../../lib/ast.js";import{inTrackingContext as i,isObservableRef as c,textOf as l}from"./shared.js";const p=new Set(["has","entries","keys","values"]);export const noUntrackedCollectionRead=a("Disallow `has`, `entries`, `keys` or `values` called on an observable inside a tracking context. On an observable `Map` or `Set` they read the raw collection and subscribe to nothing, so the selector never re-runs.",{createOnce(r){return{before(){return s(r,"$.")},CallExpression(t){const{callee:e}=t;if(e.type!=="MemberExpression"||e.computed||e.property.type!=="Identifier")return;const o=e.property.name;if(!p.has(o)||!c(e.object))return;if(!i(t))return;const n=l(r,e.object);r.report({node:t,message:`Read \`${n}.get().${o}(…)\` to track the collection, or keep per-item flags in a record and read one key (\`flags$[id].get()\`). \`${o}\` on an observable \`Map\` or \`Set\` subscribes to nothing, so this never re-runs.`})}}}});
@@ -1 +1 @@
1
- export const OBSERVABLE_FACTORIES=new Set(["observable","useObservable"]),OBS=/\$$/;const r=(t)=>{let e=t;while(e?.type==="MemberExpression")e=e.object;return e?.type==="Identifier"?e.name:null};export const isObservableRef=(t)=>{const e=r(t);return e!=null&&OBS.test(e)},factoryCalled=(t)=>{if(t?.type!=="CallExpression")return null;const{callee:e}=t;return e.type==="Identifier"&&OBSERVABLE_FACTORIES.has(e.name)?e.name:null},textOf=(t,e)=>t.sourceCode.getText(e);
1
+ import{hasAncestor as n,isFunction as r}from"../../../lib/ast.js";export const OBSERVABLE_FACTORIES=new Set(["observable","useObservable"]),OBS=/\$$/;const s=(t)=>{let e=t;while(e?.type==="MemberExpression")e=e.object;return e?.type==="Identifier"?e.name:null};export const isObservableRef=(t)=>{const e=s(t);return e!=null&&OBS.test(e)},factoryCalled=(t)=>{if(t?.type!=="CallExpression")return null;const{callee:e}=t;return e.type==="Identifier"&&OBSERVABLE_FACTORIES.has(e.name)?e.name:null},textOf=(t,e)=>t.sourceCode.getText(e);const o=new Set(["useValue","observe","useObserve","useObserveEffect","when","whenReady","useWhen","useWhenReady","observable","useObservable","useComputed"]),l=(t)=>{const e=t.parent;return r(t)&&e?.type==="CallExpression"&&e.callee.type==="Identifier"&&o.has(e.callee.name)&&e.arguments[0]===t};export const inTrackingContext=(t)=>n(t,l);
@@ -1 +1 @@
1
- import{ancestors as u,COMPONENT_OR_HOOK as a,isFunction as p,problem as l}from"../../../lib/ast.js";const f=/^[A-Z]/,c=(t)=>{if(t.type==="FunctionDeclaration")return t.id?.name??null;const{parent:e}=t;if(e===null||e.type!=="VariableDeclarator"||e.id.type!=="Identifier")return null;return e.id.name},m=(t)=>{for(const e of u(t)){if(!p(e))continue;const n=c(e);if(n!==null&&a.test(n))return e}return null},d=(t,e)=>{for(let n=t;n!==null&&n!==void 0;n=n.upper)if(n===e)return!0;return!1},h=(t,e)=>{for(const n of t.through)if(d(n.resolved?.scope,e))return!0;return!1};export const hoistStatelessFunction=l("Require module scope for a non-component function that reads nothing from the component around it. Out there it is created once, keeps a stable identity, and can be tested without rendering.",{createOnce(t){const e=(n)=>{const o=c(n);if(o===null||f.test(o))return;const r=m(n);if(r===null)return;const s=t.sourceCode.getScope(n),i=t.sourceCode.getScope(r);if(h(s,i))return;t.report({node:n,message:`Move \`${o}\` to module scope — it reads nothing from the component. If it was meant to read a prop or a piece of state, wire that read up instead.`})};return{FunctionDeclaration:e,FunctionExpression:e,ArrowFunctionExpression:e}}});
1
+ import{boundFunctionName as i,enclosingComponentOrHook as u,problem as a}from"../../../lib/ast.js";const p=/^[A-Z]/,f=(o,t)=>{for(let e=o;e!==null&&e!==void 0;e=e.upper)if(e===t)return!0;return!1},m=(o,t)=>{for(const e of o.through)if(f(e.resolved?.scope,t))return!0;return!1};export const hoistStatelessFunction=a("Require module scope for a non-component function that reads nothing from the component around it. Out there it is created once, keeps a stable identity, and can be tested without rendering.",{createOnce(o){const t=(e)=>{const n=i(e);if(n===null||p.test(n))return;const r=u(e);if(r===null)return;const c=o.sourceCode.getScope(e),s=o.sourceCode.getScope(r);if(m(c,s))return;o.report({node:e,message:`Move \`${n}\` to module scope — it reads nothing from the component. If it was meant to read a prop or a piece of state, wire that read up instead.`})};return{FunctionDeclaration:t,FunctionExpression:t,ArrowFunctionExpression:t}}});
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{hoistStatelessFunction as o}from"./hoist-stateless-function.js";import{noConditionalStyleArray as t}from"./no-conditional-style-array.js";import{noDynamicImport as r}from"./no-dynamic-import.js";import{noKeyboardWillEvents as a}from"./no-keyboard-will-events.js";import{noLeakedRender as n}from"./no-leaked-render.js";import{noManualMemo as i}from"./no-manual-memo.js";import{noRedundantViewNesting as m}from"./no-redundant-view-nesting.js";import{noRnImageNetworkSource as s}from"./no-rn-image-network-source.js";import{noRnNamespaceImport as p}from"./no-rn-namespace-import.js";import{noScrollPositionState as l}from"./no-scroll-position-state.js";import{noUnlabeledIconPressable as d}from"./no-unlabeled-icon-pressable.js";export default e({meta:{name:"@ashstack/react-native"},url:import.meta.url,docsWhen:"always on via `reactNative()`",rules:{"no-keyboard-will-events":a,"no-scroll-position-state":l,"no-conditional-style-array":t,"no-leaked-render":n,"no-rn-image-network-source":s,"no-redundant-view-nesting":m,"no-rn-namespace-import":p,"no-unlabeled-icon-pressable":d,"hoist-stateless-function":o,"no-manual-memo":i,"no-dynamic-import":r},restrictedImports:{paths:[{name:"react",importNames:["forwardRef"],message:"Accept `ref` as a regular prop and delete the `forwardRef` wrapper — React 19 passes `ref` like any other prop."},{name:"react",importNames:["useContext"],message:"Call `use(Context)` instead of `useContext(Context)`; React 19 replaces the hook with it."}],patterns:[{group:["expo-linear-gradient","react-native-linear-gradient"],message:"Apply the gradient through the `experimental_backgroundImage` style property instead of a gradient component."}]}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{hoistStatelessFunction as o}from"./hoist-stateless-function.js";import{noConditionalStyleArray as t}from"./no-conditional-style-array.js";import{noDynamicImport as r}from"./no-dynamic-import.js";import{noKeyboardWillEvents as a}from"./no-keyboard-will-events.js";import{noLeakedRender as n}from"./no-leaked-render.js";import{noManualMemo as i}from"./no-manual-memo.js";import{noReactLazy as m}from"./no-react-lazy.js";import{noRedundantViewNesting as s}from"./no-redundant-view-nesting.js";import{noRnImageNetworkSource as p}from"./no-rn-image-network-source.js";import{noRnNamespaceImport as l}from"./no-rn-namespace-import.js";import{noScrollPositionState as d}from"./no-scroll-position-state.js";import{noUnlabeledIconPressable as c}from"./no-unlabeled-icon-pressable.js";export default e({meta:{name:"@ashstack/react-native"},url:import.meta.url,docsWhen:"always on via `reactNative()`",rules:{"no-keyboard-will-events":a,"no-scroll-position-state":d,"no-conditional-style-array":t,"no-leaked-render":n,"no-rn-image-network-source":p,"no-redundant-view-nesting":s,"no-rn-namespace-import":l,"no-unlabeled-icon-pressable":c,"hoist-stateless-function":o,"no-manual-memo":i,"no-dynamic-import":r,"no-react-lazy":m},restrictedImports:{paths:[{name:"react",importNames:["forwardRef"],message:"Accept `ref` as a regular prop and delete the `forwardRef` wrapper — React 19 passes `ref` like any other prop."},{name:"react",importNames:["useContext"],message:"Call `use(Context)` instead of `useContext(Context)`; React 19 replaces the hook with it."}],patterns:[{group:["expo-linear-gradient","react-native-linear-gradient"],message:"Apply the gradient through the `experimental_backgroundImage` style property instead of a gradient component."}]}});
@@ -1 +1 @@
1
- import{calleeName as r,gate as i,hasAncestor as n,problem as s}from"../../../lib/ast.js";const a=new Set(["lazy","dynamic"]),m="Turn this into a static `import` — Metro inlines `import()` into the same bundle, so it buys no laziness. `React.lazy(() => import(...))` stays allowed.";export const noDynamicImport=s("Disallow dynamic `import()` outside a `React.lazy` or `dynamic` wrapper. Metro inlines it into the same bundle, so nothing is deferred and the module is hidden from the typechecker.",{createOnce(e){return{before(){return i(e,"import(")},ImportExpression(t){if(n(t,(o)=>o.type==="CallExpression"&&a.has(r(o))))return;e.report({node:t,message:m})}}}});
1
+ import{gate as t,problem as o}from"../../../lib/ast.js";const i="Turn this into a static `import`, or a `require` at first use for a heavy module — Metro inlines `import()` into the same bundle, so it buys no laziness.";export const noDynamicImport=o("Disallow dynamic `import()`. Metro inlines it into the same bundle, so nothing is deferred and the module is hidden from the typechecker.",{createOnce(e){return{before(){return t(e,"import(")},ImportExpression(r){e.report({node:r,message:i})}}}});
@@ -0,0 +1 @@
1
+ import{gate as o,importBinding as l,problem as n}from"../../../lib/ast.js";const s="Import this component statically, or `require` a heavy one at first use. The router already loads each screen lazily, and the Suspense boundary `lazy` adds holds a blank fallback for up to 300ms and can loop rendering forever inside a frozen screen.";export const noReactLazy=n("Disallow `lazy` and `React.lazy` from `react`. The router already loads screens lazily, and the Suspense boundary `lazy` adds holds its fallback for up to 300ms and can loop forever inside a frozen screen.",{createOnce(r){const e=l("react","lazy");return{before(){e.clear();return o(r,"lazy")},ImportDeclaration(a){e.add(a)},CallExpression(a){if(e.isCall(a))r.report({node:a,message:s})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as s,gate as r,isFunction as o,problem as c,subtreeHas as a}from"../../../lib/ast.js";const d=new Map([["withTiming",2],["withSpring",2],["withDecay",1],["withRepeat",3],["withCallback",0]]),l="Take `finished` and call `scheduleOnRN` only `if (finished)`. The callback also runs when the animation is cancelled or interrupted, with `finished` false, so this fires for an animation that never landed.",h=(e)=>s(e)==="scheduleOnRN",u=(e)=>{if(e.type!=="ArrowFunctionExpression"&&e.type!=="FunctionExpression")return!1;const[i]=e.params;if(i?.type!=="Identifier")return!1;const{name:t}=i;return a(e.body,(n)=>n.type==="Identifier"&&n.name===t)};export const checkFinished=c("Require an animation completion callback that calls `scheduleOnRN` to read its `finished` argument. The callback also runs when the animation is cancelled, and then `finished` is false.",{createOnce(e){return{before(){return r(e,"scheduleOnRN")},CallExpression(i){const t=d.get(s(i)),n=t===void 0?void 0:i.arguments[t];if(n===void 0||!o(n))return;if(!a(n,h)||u(n))return;e.report({node:n,message:l})}}}});
@@ -1 +1 @@
1
- import{calleeName as i,gate as o,problem as s}from"../../../lib/ast.js";import{ANIMATED_STYLE_HOOKS as n}from"./shared.js";const p="Animate `transform` and `opacity` instead — a panel that grows is `scaleY` with `transformOrigin`, a slide is `translateY`. This property relayouts every frame.",m=new Set(["width","height","minWidth","minHeight","maxWidth","maxHeight","top","left","right","bottom","start","end","flex","flexBasis","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingStart","paddingEnd","paddingHorizontal","paddingVertical","margin","marginTop","marginBottom","marginLeft","marginRight","marginStart","marginEnd","marginHorizontal","marginVertical","gap","rowGap","columnGap"]),l=(a)=>{if(a.type!=="Property")return null;const{key:t}=a;if(t.type==="Identifier")return t.name;if(t.type==="Literal")return String(t.value);return null};export const gpuPropertiesOnly=s("Animate `transform` and `opacity` in `useAnimatedStyle` and `useAnimatedProps`. Layout properties such as `width` or `margin` recalculate layout every frame.",{createOnce(a){let t=0;return{before(){t=0;return o(a,"useAnimatedStyle","useAnimatedProps")},CallExpression(e){if(n.has(i(e)))t+=1},"CallExpression:exit"(e){if(n.has(i(e)))t-=1},Property(e){if(t===0)return;if(e.parent.type!=="ObjectExpression")return;const r=l(e);if(r!==null&&m.has(r))a.report({node:e,message:p})}}}});
1
+ import{calleeName as i,gate as d,problem as p,propertyKeyName as o}from"../../../lib/ast.js";import{ANIMATED_STYLE_HOOKS as s}from"./shared.js";const m="Animate `transform` and `opacity` instead — a panel that grows is `scaleY` with `transformOrigin`, a slide is `translateY`. This property relayouts every frame.",h="Animate `boxShadow` instead, which renders on both platforms. `shadowOffset`, `shadowOpacity` and `shadowRadius` render on iOS only, and `elevation` on Android only.",l=new Set(["shadowOffset","shadowOpacity","shadowRadius","elevation"]),f=new Set(["width","height","minWidth","minHeight","maxWidth","maxHeight","top","left","right","bottom","start","end","flex","flexBasis","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingStart","paddingEnd","paddingHorizontal","paddingVertical","margin","marginTop","marginBottom","marginLeft","marginRight","marginStart","marginEnd","marginHorizontal","marginVertical","gap","rowGap","columnGap"]),g=(e)=>e.parent!==null&&o(e.parent)==="shadowOffset";export const gpuPropertiesOnly=p("Animate `transform` and `opacity` in `useAnimatedStyle` and `useAnimatedProps`, and `boxShadow` for a shadow. Layout properties such as `width` or `margin` recalculate layout every frame, and `shadowOffset`, `shadowOpacity`, `shadowRadius` and `elevation` each render on one platform only.",{createOnce(e){let t=0;return{before(){t=0;return d(e,"useAnimatedStyle","useAnimatedProps")},CallExpression(a){if(s.has(i(a)))t+=1},"CallExpression:exit"(a){if(s.has(i(a)))t-=1},Property(a){if(t===0)return;const{parent:n}=a;if(n.type!=="ObjectExpression"||g(n))return;const r=o(a);if(f.has(r))e.report({node:a,message:m});else if(l.has(r))e.report({node:a,message:h})}}}});
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{animatedReactionSafety as a}from"./animated-reaction-safety.js";import{animatedStyleNeedsAnimatedComponent as t}from"./animated-style-needs-animated-component.js";import{animatedUpdaterPurity as r}from"./animated-updater-purity.js";import{gpuPropertiesOnly as n}from"./gpu-properties-only.js";import{hoistLayoutAnimationBuilder as o}from"./hoist-layout-animation-builder.js";import{interpolateNeedsClamp as i}from"./interpolate-needs-clamp.js";import{noReactStateFromContinuousWorklet as m}from"./no-react-state-from-continuous-worklet.js";import{noSharedValueDotValue as d}from"./no-shared-value-dot-value.js";import{preferLazySharedValueInitializer as s}from"./prefer-lazy-shared-value-initializer.js";import{scheduleOnRnScope as p}from"./schedule-on-rn-scope.js";import{sharedValueUsage as u}from"./shared-value-usage.js";export default e({meta:{name:"@ashstack/reanimated"},url:import.meta.url,packages:["react-native-reanimated"],option:"reanimated",docsWhen:"auto-enabled when `react-native-reanimated` is a dependency",rules:{"animated-reaction-safety":a,"animated-style-needs-animated-component":t,"animated-updater-purity":r,"gpu-properties-only":n,"hoist-layout-animation-builder":o,"interpolate-needs-clamp":i,"no-shared-value-dot-value":d,"no-react-state-from-continuous-worklet":m,"prefer-lazy-shared-value-initializer":s,"schedule-on-rn-scope":p,"shared-value-usage":u},restrictedImports:{paths:[{name:"react-native",importNames:["Animated"],message:"Use `react-native-reanimated` instead of React Native's `Animated` API."},{name:"react-native-reanimated",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."},{name:"react-native-worklets",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."}]}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{animatedReactionSafety as a}from"./animated-reaction-safety.js";import{animatedStyleNeedsAnimatedComponent as t}from"./animated-style-needs-animated-component.js";import{animatedUpdaterPurity as n}from"./animated-updater-purity.js";import{checkFinished as r}from"./check-finished.js";import{gpuPropertiesOnly as o}from"./gpu-properties-only.js";import{hoistLayoutAnimationBuilder as i}from"./hoist-layout-animation-builder.js";import{interpolateNeedsClamp as m}from"./interpolate-needs-clamp.js";import{layoutAnimationNeedsAnimatedComponent as d}from"./layout-animation-needs-animated-component.js";import{noReactStateFromContinuousWorklet as s}from"./no-react-state-from-continuous-worklet.js";import{noSharedValueDotValue as p}from"./no-shared-value-dot-value.js";import{preferLazySharedValueInitializer as u}from"./prefer-lazy-shared-value-initializer.js";import{scheduleOnRnScope as l}from"./schedule-on-rn-scope.js";import{sharedValueUsage as c}from"./shared-value-usage.js";export default e({meta:{name:"@ashstack/reanimated"},url:import.meta.url,packages:["react-native-reanimated"],option:"reanimated",docsWhen:"auto-enabled when `react-native-reanimated` is a dependency",rules:{"animated-reaction-safety":a,"animated-style-needs-animated-component":t,"animated-updater-purity":n,"gpu-properties-only":o,"hoist-layout-animation-builder":i,"interpolate-needs-clamp":m,"no-shared-value-dot-value":p,"no-react-state-from-continuous-worklet":s,"prefer-lazy-shared-value-initializer":u,"schedule-on-rn-scope":l,"shared-value-usage":c,"layout-animation-needs-animated-component":d,"check-finished":r},restrictedImports:{paths:[{name:"react-native",importNames:["Animated"],message:"Use `react-native-reanimated` instead of React Native's `Animated` API."},{name:"react-native-reanimated",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."},{name:"react-native-worklets",importNames:["runOnJS","runOnUI"],message:"Use `scheduleOnRN` and `scheduleOnUI` from `react-native-worklets`; `runOnJS` and `runOnUI` are deprecated."}]}});
@@ -0,0 +1 @@
1
+ import{attributeName as i,gate as m,importedNames as p,problem as s}from"../../../lib/ast.js";const c=new Set(["entering","exiting","layout"]),l=new Set(["View","Text","Image","ScrollView","FlatList"]),d=(e)=>l.has(e)?`Render this as \`Animated.${e}\``:`Render \`createAnimatedComponent(${e})\`, created once at module scope`;export const layoutAnimationNeedsAnimatedComponent=s("Disallow `entering`, `exiting` or `layout` on a component imported from `react-native`. Only an `Animated.*` component or a `createAnimatedComponent` wrapper runs a layout animation; a plain one ignores the prop.",{createOnce(e){const a=new Map;return{before(){a.clear();return m(e,"entering","exiting","layout")},ImportDeclaration(t){for(const{imported:n,local:o}of p(t,"react-native"))a.set(o,n)},JSXAttribute(t){const n=i(t);if(!c.has(n)||t.parent.type!=="JSXOpeningElement")return;const{name:o}=t.parent,r=o.type==="JSXIdentifier"?a.get(o.name):void 0;if(r===void 0)return;e.report({node:t,message:`${d(r)}. A plain \`${r}\` ignores \`${n}\`, so nothing animates.`})}}}});
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{animatedTheme as t}from"./animated-theme.js";import{contentContainer as n}from"./content-container.js";import{inSheet as a}from"./in-sheet.js";import{insets as r}from"./insets.js";import{noHardcodedColor as s}from"./no-hardcoded-color.js";import{noHardcodedSpacing as o}from"./no-hardcoded-spacing.js";import{noMargin as i}from"./no-margin.js";import{noParamlessDynamicFunction as m}from"./no-paramless-dynamic-function.js";import{noStyleSpread as c}from"./no-style-spread.js";import{noUnusedStyles as l}from"./no-unused-styles.js";import{rtlStyleCall as d}from"./rtl-style-call.js";import{themeScreenComponent as p}from"./theme-screen-component.js";import{themeStyleAttr as f}from"./theme-style-attr.js";export default e({meta:{name:"@ashstack/unistyles"},rules:{"animated-theme":t,"content-container":n,"in-sheet":a,insets:r,"no-hardcoded-color":s,"no-hardcoded-spacing":o,"no-margin":i,"no-paramless-dynamic-function":m,"no-style-spread":c,"no-unused-styles":l,"rtl-style-call":d,"theme-screen-component":p,"theme-style-attr":f},url:import.meta.url,packages:["react-native-unistyles"],option:"unistyles",docsWhen:"auto-enabled when `react-native-unistyles` is a dependency",restrictedImports:{paths:[{name:"react-native",importNames:["StyleSheet"],message:"Import `StyleSheet` from `react-native-unistyles` instead of `react-native`."},{name:"react-native",importNames:["useWindowDimensions","Dimensions"],message:"Read screen size from `rt.screen` inside `StyleSheet.create`, or `UnistylesRuntime.screen` outside it, instead of the `Dimensions` APIs."},{name:"react-native",importNames:["SafeAreaView"],message:'Set `contentInsetAdjustmentBehavior="automatic"` on the scroll view, or apply `rt.insets` from `react-native-unistyles`, instead of `SafeAreaView`.'},{name:"react-native-safe-area-context",importNames:["useSafeAreaInsets","useSafeAreaFrame","SafeAreaView"],message:"Read safe-area values from `rt.insets`, or `UnistylesRuntime.insets` outside a stylesheet, in `react-native-unistyles`."}]}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{animatedTheme as t}from"./animated-theme.js";import{contentContainer as n}from"./content-container.js";import{inSheet as r}from"./in-sheet.js";import{insets as a}from"./insets.js";import{noHardcodedColor as o}from"./no-hardcoded-color.js";import{noHardcodedSpacing as s}from"./no-hardcoded-spacing.js";import{noMargin as i}from"./no-margin.js";import{noParamlessDynamicFunction as m}from"./no-paramless-dynamic-function.js";import{noStyleSpread as c}from"./no-style-spread.js";import{noThemeRuntimeArgs as l}from"./no-theme-runtime-args.js";import{noUnusedStyles as d}from"./no-unused-styles.js";import{rtlStyleCall as p}from"./rtl-style-call.js";import{themeScreenComponent as f}from"./theme-screen-component.js";import{themeStyleAttr as u}from"./theme-style-attr.js";export default e({meta:{name:"@ashstack/unistyles"},rules:{"animated-theme":t,"content-container":n,"in-sheet":r,insets:a,"no-hardcoded-color":o,"no-hardcoded-spacing":s,"no-margin":i,"no-paramless-dynamic-function":m,"no-style-spread":c,"no-theme-runtime-args":l,"no-unused-styles":d,"rtl-style-call":p,"theme-screen-component":f,"theme-style-attr":u},url:import.meta.url,packages:["react-native-unistyles"],option:"unistyles",docsWhen:"auto-enabled when `react-native-unistyles` is a dependency",restrictedImports:{paths:[{name:"react-native",importNames:["StyleSheet"],message:"Import `StyleSheet` from `react-native-unistyles` instead of `react-native`."},{name:"react-native",importNames:["useWindowDimensions","Dimensions"],message:"Read screen size from `rt.screen` inside `StyleSheet.create`, or `UnistylesRuntime.screen` outside it, instead of the `Dimensions` APIs."},{name:"react-native",importNames:["SafeAreaView"],message:'Set `contentInsetAdjustmentBehavior="automatic"` on the scroll view, or apply `rt.insets` from `react-native-unistyles`, instead of `SafeAreaView`.'},{name:"react-native-safe-area-context",importNames:["useSafeAreaInsets","useSafeAreaFrame","SafeAreaView"],message:"Read safe-area values from `rt.insets`, or `UnistylesRuntime.insets` outside a stylesheet, in `react-native-unistyles`."}]}});
@@ -0,0 +1 @@
1
+ import{gate as d,problem as h,subtreeHas as S}from"../../../lib/ast.js";const l=new Map([["useUnistyles","hook"],["UnistylesRuntime","runtime"],["StyleSheet","create"]]),M=new Map([["react-native-unistyles",l],["react-native",new Map([["useWindowDimensions","hook"],["useColorScheme","hook"],["Dimensions","Dimensions"],["PixelRatio","PixelRatio"],["Appearance","Appearance"],["I18nManager","I18nManager"],["StatusBar","StatusBar"]])],["react-native-safe-area-context",new Map([["useSafeAreaInsets","hook"],["useSafeAreaFrame","hook"]])]]),b=new Map([["namespace",l],["Dimensions",new Map([["get","hook"]])],["PixelRatio",new Map([["get","hook"],["getFontScale","hook"]])],["Appearance",new Map([["getColorScheme","hook"]])],["I18nManager",new Map([["isRTL","runtime"]])],["StatusBar",new Map([["currentHeight","runtime"]])]]),f=(e,t)=>{if(t.type!=="Identifier")return;for(let s=e.sourceCode.getScope(t);s;s=s.upper){const a=s.set.get(t.name);if(a)return a}return},m=(e)=>{if(e.type!=="MemberExpression")return"";if(!e.computed&&e.property.type==="Identifier")return e.property.name;return e.property.type==="Literal"?String(e.property.value):""},I=(e)=>{if(e.parent?.type!=="ImportDeclaration")return;const t=e.parent.source.value;if(e.type==="ImportNamespaceSpecifier"&&t==="react-native-unistyles")return"namespace";if(e.type!=="ImportSpecifier"||e.imported.type!=="Identifier")return;return M.get(t)?.get(e.imported.name)},R=(e,t)=>{if(e==="hook")return"runtime";if(e==="create"&&m(t)==="create")return"sheet";return},x=(e)=>{const t=e.parent;if(t?.type==="MemberExpression"&&t.property===e&&!t.computed)return!1;return!(t?.type==="Property"&&t.key===e&&!t.computed&&!t.shorthand)},k=(e)=>{const t=new WeakMap,s=new Set,a=new Set,y=(r)=>{const n=f(e,r);if(!n||s.has(n))return;s.add(n);const i=n.defs.find((u)=>u.type==="ImportBinding"||u.node.type==="VariableDeclarator");let o;if(i?.type==="ImportBinding")o=I(i.node);else if(i?.node.type==="VariableDeclarator")o=p(i.node.init);s.delete(n);return o},g=(r)=>{if(!r)return;if(r.type==="Identifier")return y(r);if(r.type==="MemberExpression"){const i=p(r.object);if(!i)return;const o=b.get(i);return o?o.get(m(r)):i}if(r.type==="CallExpression")return R(p(r.callee),r.callee);if(r.type==="TSAsExpression"||r.type==="TSNonNullExpression"||r.type==="TSSatisfiesExpression"||r.type==="ChainExpression")return p(r.expression);return},p=(r)=>{if(!r)return;if(t.has(r))return t.get(r);const n=g(r);t.set(r,n);return n},c=(r)=>S(r,(n)=>{if(n.type==="MemberExpression"||n.type==="CallExpression")return p(n)==="runtime";if(n.type!=="Identifier"||!x(n))return!1;if(p(n)==="runtime")return!0;const i=f(e,n);if(!i||a.has(i))return!1;a.add(i);const o=i.defs.some((u)=>u.node.type==="VariableDeclarator"&&u.node.init!==null&&c(u.node.init));a.delete(i);return o});return{originOf:p,readsRuntime:c}};export const noThemeRuntimeArgs=h("Disallow passing theme or Unistyles runtime values into dynamic style functions, including screen dimensions, safe-area insets, RTL, pixel/font scale, color scheme, derived values and aliases. Read `theme` and `rt` inside the `StyleSheet.create` callback instead.",{createOnce(e){let t;return{before(){if(!d(e,"react-native-unistyles"))return!1;t=k(e);return!0},CallExpression(s){if(s.arguments.length===0||s.callee.type!=="MemberExpression")return;if(t.originOf(s.callee.object)!=="sheet")return;for(const a of s.arguments){if(!t.readsRuntime(a))continue;e.report({node:a,message:"Read `theme` and `rt` inside `StyleSheet.create` instead of passing them into a style function."})}}}}});
@@ -0,0 +1 @@
1
+ import{defineModule as e}from"../../../lib/module.js";import{noInlineWorkletSchedule as n}from"./no-inline-worklet-schedule.js";import{noJsTimerSchedule as o}from"./no-js-timer-schedule.js";import{noRuntimeInRender as r}from"./no-runtime-in-render.js";import{noSyncRuntimeCall as t}from"./no-sync-runtime-call.js";export default e({meta:{name:"@ashstack/worklets"},url:import.meta.url,packages:["react-native-worklets"],option:"worklets",docsWhen:"auto-enabled when `react-native-worklets` is a dependency",rules:{"no-runtime-in-render":r,"no-inline-worklet-schedule":n,"no-sync-runtime-call":t,"no-js-timer-schedule":o}});
@@ -0,0 +1 @@
1
+ import{calleeName as t,closestAncestor as o,FUNCTION_TYPES as r,gate as s,isFunction as l,problem as c}from"../../../lib/ast.js";import{workletArgument as a}from"./shared.js";export const noInlineWorkletSchedule=c("Disallow an inline function as the worklet of `scheduleOnUI`, `scheduleOnRuntime`, `runOnUIAsync`, `runOnUISync`, `runOnRuntimeAsync` or `runOnRuntimeSync` inside a function. The serialized copy is cached by function identity, so a new function object is serialized again on every call. Module scope runs once and is allowed.",{createOnce(i){return{before(){return s(i,"OnUI","OnRuntime")},CallExpression(e){const n=a(e);if(n===void 0||!l(n)||o(e,r)===null)return;i.report({node:n,message:`Define this worklet once, outside the call, and pass what it needs as \`${t(e)}\`'s extra arguments. A new function object here is serialized on every call.`})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as i,closestAncestor as o,FUNCTION_TYPES as c,gate as l,hasAncestor as m,problem as h}from"../../../lib/ast.js";import{isWorklet as u}from"./shared.js";const d=new Set(["scheduleOnUI","scheduleOnRuntime","scheduleOnRuntimeWithId"]),p=new Set(["setInterval","setTimeout"]);export const noJsTimerSchedule=h("Disallow a React Native Runtime `setInterval` or `setTimeout` callback that calls `scheduleOnUI` or `scheduleOnRuntime`. Each time the timer fires it waits for the JavaScript thread and sends a new job; start the timer on the target runtime instead.",{createOnce(a){return{before(){return l(a,"setInterval","setTimeout")},CallExpression(t){const s=i(t);if(!d.has(s))return;const n=o(t,c),e=n?.parent;if(e?.type!=="CallExpression"||e.arguments[0]!==n)return;const r=i(e);if(!p.has(r)||m(e,u))return;a.report({node:t,message:`Start the timer on the target runtime: \`${s}\` a worklet that calls \`${r}\` there. A \`${r}\` on the React Native Runtime waits for the JavaScript thread and sends a new job each time it fires.`})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as r,enclosingComponentOrHook as a,gate as n,problem as o}from"../../../lib/ast.js";export const noRuntimeInRender=o("Disallow `createWorkletRuntime` inside a component or hook. Each call starts a new JavaScript runtime and, with the default queue, a new thread; create it once at module scope and reuse it.",{createOnce(t){return{before(){return n(t,"createWorkletRuntime")},CallExpression(e){if(r(e)!=="createWorkletRuntime"||a(e)===null)return;t.report({node:e,message:"Create this runtime once at module scope and reuse it. Inside a component or hook, each `createWorkletRuntime` call starts a new JavaScript runtime and, with the default queue, a new thread."})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as a,gate as l,problem as u}from"../../../lib/ast.js";const c=new Map([["runOnUISync","runOnUIAsync"],["runOnRuntimeSync","runOnRuntimeAsync"],["runOnRuntimeSyncWithId","runOnRuntimeAsyncWithId"]]);export const noSyncRuntimeCall=u("Disallow `runOnUISync` and `runOnRuntimeSync`. They block the calling thread until the worklet finishes; `runOnUIAsync` and `runOnRuntimeAsync` return the same value as a promise.",{createOnce(n){return{before(){return l(n,"Sync")},CallExpression(e){const t=a(e),r=c.get(t);if(r===void 0)return;n.report({node:e.callee,message:`Call \`${r}\` and await the result. \`${t}\` blocks the calling thread until the worklet finishes.`})}}}});
@@ -0,0 +1 @@
1
+ import{calleeName as t}from"../../../lib/ast.js";const r=new Map([["scheduleOnUI",0],["runOnUIAsync",0],["runOnUISync",0],["scheduleOnRuntime",1],["runOnRuntimeAsync",1],["runOnRuntimeSync",1],["scheduleOnRuntimeWithId",1],["runOnRuntimeAsyncWithId",1],["runOnRuntimeSyncWithId",1]]);export const workletArgument=(n)=>{const e=r.get(t(n));return e===void 0?void 0:n.arguments[e]},isWorklet=(n)=>{if(n.type!=="FunctionDeclaration"&&n.type!=="FunctionExpression"&&n.type!=="ArrowFunctionExpression")return!1;const e=n.body?.type==="BlockStatement"?n.body.body[0]:void 0;if(e?.type==="ExpressionStatement"&&e.directive==="worklet")return!0;return n.parent.type==="CallExpression"&&workletArgument(n.parent)===n};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ashstack/lint",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "ashStack shared oxlint configuration and custom rules. Entries: core, react, react-native, with per-library rule groups auto-detected from your dependencies. Consume from oxlint.config.mts.",
5
5
  "type": "module",
6
6
  "license": "MIT",