@ashstack/lint 0.11.0 → 0.12.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.
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, 211 with React, 273 on React Native, 87 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
 
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 i=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},p=(t)=>{const e=[];for(const[r,n]of Object.entries(t)){if(i.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(p(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),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}}});
@@ -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 p}from"node:url";import{detect as r}from"./detect.js";export const defineModule=(e)=>e;const shortName=(e)=>e.meta.name.slice(10),d=(e,t)=>r(e.option===void 0?void 0:t[e.option],e.packages,e.minMajor),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(!d(n,t))continue;const c=u(n);if(c.length>0)s.jsPlugins.push(p(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 +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}}},{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-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."}]},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:{}},{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:{}},{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/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/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" | "@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
  /**
@@ -165,6 +165,14 @@ declare module "oxlint" {
165
165
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/unistyles.md#ashstackunistylesno-style-spread
166
166
  */
167
167
  "@ashstack/unistyles/no-style-spread"?: RuleSetting;
168
+ /**
169
+ * 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.
170
+ *
171
+ * **Default: on**, when `react-native-unistyles` is a dependency.
172
+ *
173
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/unistyles.md#ashstackunistylesno-theme-runtime-args
174
+ */
175
+ "@ashstack/unistyles/no-theme-runtime-args"?: RuleSetting;
168
176
  /**
169
177
  * 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
178
  *
@@ -445,6 +453,38 @@ declare module "oxlint" {
445
453
  * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/skia.md#ashstackskiacanvas-opaque
446
454
  */
447
455
  "@ashstack/skia/canvas-opaque"?: RuleSetting;
456
+ /**
457
+ * 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.
458
+ *
459
+ * **Default: on**, when `react-native-worklets` is a dependency.
460
+ *
461
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-runtime-in-render
462
+ */
463
+ "@ashstack/worklets/no-runtime-in-render"?: RuleSetting;
464
+ /**
465
+ * 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.
466
+ *
467
+ * **Default: on**, when `react-native-worklets` is a dependency.
468
+ *
469
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-inline-worklet-schedule
470
+ */
471
+ "@ashstack/worklets/no-inline-worklet-schedule"?: RuleSetting;
472
+ /**
473
+ * Disallow `runOnUISync` and `runOnRuntimeSync`. They block the calling thread until the worklet finishes; `runOnUIAsync` and `runOnRuntimeAsync` return the same value as a promise.
474
+ *
475
+ * **Default: on**, when `react-native-worklets` is a dependency.
476
+ *
477
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-sync-runtime-call
478
+ */
479
+ "@ashstack/worklets/no-sync-runtime-call"?: RuleSetting;
480
+ /**
481
+ * 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.
482
+ *
483
+ * **Default: on**, when `react-native-worklets` is a dependency.
484
+ *
485
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworkletsno-js-timer-schedule
486
+ */
487
+ "@ashstack/worklets/no-js-timer-schedule"?: RuleSetting;
448
488
  }
449
489
  }
450
490
  export {};
@@ -62,6 +62,8 @@ export interface ModuleManifest {
62
62
  url: string;
63
63
  /** enable when one of these is a dependency; absent = always on */
64
64
  packages?: string[];
65
+ /** and only at this major of that dependency or later, installed or else declared */
66
+ minMajor?: number;
65
67
  /** key in the entry options that forces the module on/off; absent = auto-only */
66
68
  option?: string;
67
69
  /** activation line for RULES.md, e.g. "auto-enabled when `zod` is a dependency" */
@@ -83,6 +85,8 @@ export interface ModuleMeta {
83
85
  url: string;
84
86
  /** Enable when one of these is a dependency; absent = always on. */
85
87
  packages?: string[];
88
+ /** And only at this major of that dependency or later, installed or else declared. */
89
+ minMajor?: number;
86
90
  /** Key in the entry options that forces the module on/off; absent = auto-only. */
87
91
  option?: string;
88
92
  restrictedImports?: RestrictedImports;
@@ -141,6 +145,10 @@ export type ReactNativeOptions = ReactOptions & {
141
145
  skia?: boolean;
142
146
  /** [`@ashstack/keyboard` import bans](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/keyboard.md#ashstackkeyboard) — `react-native-keyboard-controller` */
143
147
  keyboard?: boolean;
148
+ /** [`@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 */
149
+ gestureHandler?: boolean;
150
+ /** [`@ashstack/worklets/` rules](https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/worklets.md#ashstackworklets) — `react-native-worklets` */
151
+ worklets?: boolean;
144
152
  };
145
153
  /** The config object an entry returns: oxlint's own shape, so `defineConfig({ extends: [core()] })` typechecks. */
146
154
  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];
@@ -3,7 +3,7 @@ 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)
@@ -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 r}from"../core/index.js";import{mergeConfigs as a}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`; 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 l={"eslint/no-empty":"error","eslint/no-empty-function":"error"},u={"@ashstack/effects/no-event-handler":"off"},f=(e)=>e?{}:{"@ashstack/react-native/no-manual-memo":"off"},reactNative=(e={})=>{const t=s([...o,...n,...i],e,banGroups);return a(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],...f(e.reactCompiler??!0)},ignorePatterns:["**/.expo/**","**/android/**","**/ios/**"],overrides:[{files:r,rules:{"@ashstack/react-native/no-dynamic-import":"off","@ashstack/react-native/hoist-stateless-function":"off"}}]})};export{reactNative};export default reactNative;
@@ -0,0 +1 @@
1
+ import{defineModule as s}from"../../../lib/module.js";const e="react-native-gesture-handler",r=["PanGestureHandler","TapGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","ForceTouchGestureHandler","NativeViewGestureHandler"],o=["GestureHandlerGestureEvent","GestureHandlerStateChangeEvent",...r.flatMap((t)=>[`${t}GestureEvent`,`${t}StateChangeEvent`,`${t}Props`,`${t}Properties`])],a=["RawButton","BaseButton","RectButton","BorderlessButton"],n=["TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback"],u=[...a.flatMap((t)=>[`${t}Props`,`Legacy${t}Props`,`Legacy${t}Properties`]),"TouchableOpacityProps","TouchableHighlightProps","TouchableWithoutFeedbackProps"],c=["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:{},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}`),...n,...u],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:c,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:o,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."}]}});
@@ -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{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.12.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",