@ashstack/lint 0.10.3 → 0.10.4

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.
@@ -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":{},"use-sx-prop":{}}},{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-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:{}}];
@@ -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/use-sx-prop" | "@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/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";
6
6
  declare module "oxlint" {
7
7
  interface DummyRuleMap {
8
8
  /**
@@ -172,13 +172,13 @@ declare module "oxlint" {
172
172
  }
173
173
  ]>;
174
174
  /**
175
- * Name StyleX override props `sx` or `<slot>Sx` and pass styles through them.
175
+ * Spread complete `stylex.props(...)` results to style custom components.
176
176
  *
177
177
  * **Default: on**, when `@stylexjs/stylex` is a dependency.
178
178
  *
179
- * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/stylex.md#ashstackstylexuse-sx-prop
179
+ * @see https://github.com/AlshehriAli0/ashStack/blob/main/packages/lint/rules/stylex.md#ashstackstylexspread-props
180
180
  */
181
- "@ashstack/stylex/use-sx-prop"?: RuleSetting;
181
+ "@ashstack/stylex/spread-props"?: RuleSetting;
182
182
  /**
183
183
  * Require a dynamic class value to go through `cn(...)` before it reaches a `class`, `className` or `*ClassName` prop. Reports both where the value reaches the prop and where a variable named after classes is declared.
184
184
  *
@@ -1 +1 @@
1
- import{defineModule as e}from"../../../lib/module.js";import{inlineProps as o}from"./inline-props.js";import{noConflictingProps as r}from"./no-conflicting-props.js";import{noDuplicateStyles as t}from"./no-duplicate-styles.js";import{requireTokens as s}from"./require-tokens.js";import{useSxProp as i}from"./use-sx-prop.js";export default e({meta:{name:"@ashstack/stylex"},url:import.meta.url,packages:["@stylexjs/stylex"],option:"stylex",docsWhen:"auto-enabled by `react()` when `@stylexjs/stylex` is a dependency",rules:{"inline-props":o,"no-conflicting-props":r,"no-duplicate-styles":t,"require-tokens":s,"use-sx-prop":i}});
1
+ import{defineModule as e}from"../../../lib/module.js";import{inlineProps as o}from"./inline-props.js";import{noConflictingProps as r}from"./no-conflicting-props.js";import{noDuplicateStyles as t}from"./no-duplicate-styles.js";import{requireTokens as s}from"./require-tokens.js";import{spreadProps as p}from"./spread-props.js";export default e({meta:{name:"@ashstack/stylex"},url:import.meta.url,packages:["@stylexjs/stylex"],option:"stylex",docsWhen:"auto-enabled by `react()` when `@stylexjs/stylex` is a dependency",rules:{"inline-props":o,"no-conflicting-props":r,"no-duplicate-styles":t,"require-tokens":s,"spread-props":p}});
@@ -0,0 +1 @@
1
+ import{attributeName as x,problem as z}from"../../../lib/ast.js";import{collectImports as c,isImportedBinding as g,isStylexCall as S}from"./imports.js";const b=(s,a)=>{if(a.type!=="Identifier")return null;let i=s.sourceCode.getScope(a);while(i){const l=i.set.get(a.name);if(l){const o=l.defs.find((f)=>f.node.type==="VariableDeclarator")?.node;return o?.type==="VariableDeclarator"?o.init??null:null}i=i.upper}return null};export const spreadProps=z("Spread complete `stylex.props(...)` results to style custom components.",{meta:{hasSuggestions:!0},createOnce(s){const a={namespaces:new Set,named:new Set},i={namespaces:new Set,named:new Set},l={namespaces:new Set,named:new Set},o=new Set,f=(e)=>{if(e.type==="TSTypeReference"){const t=e.typeName;if(t.type==="Identifier")return a.named.has(t.name)&&g(s,t);return t.type==="TSQualifiedName"&&t.left.type==="Identifier"&&a.namespaces.has(t.left.name)&&(t.right.name==="StyleXStyles"||t.right.name==="StyleXStylesWithout")&&g(s,t.left)}if(e.type==="TSUnionType"||e.type==="TSIntersectionType")return e.types.some(f);if(e.type==="TSParenthesizedType")return f(e.typeAnnotation);return!1},n=(e,t=!1)=>{if(e.type==="Identifier"){const r=b(s,e);if(r===null||o.has(r))return!1;o.add(r);return n(r,t)}if(e.type==="MemberExpression"){const r=b(s,e.object);if(r!==null&&S(s,r,"create",l))return!0;return n(e.object,t)}if(e.type==="CallExpression")return S(s,e,"props",i)||n(e.callee,t)||t&&e.arguments.some((r)=>n(r,!0));return T(e,t)},T=(e,t)=>{if(e.type==="ArrayExpression")return e.elements.some((r)=>r!==null&&n(r,t));if(e.type==="ObjectExpression")return e.properties.some((r)=>r.type==="Property"&&n(r.value,t));if(e.type==="ConditionalExpression")return n(e.consequent,t)||n(e.alternate,t);if(e.type==="LogicalExpression")return n(e.left,t)||n(e.right,t);if(e.type==="BinaryExpression")return n(e.left,t)||n(e.right,t);if(e.type==="TemplateLiteral")return e.expressions.some((r)=>n(r,t));if(e.type==="SpreadElement")return n(e.argument,t);if(e.type==="ChainExpression")return n(e.expression,t);if(e.type==="TSAsExpression"||e.type==="TSSatisfiesExpression"||e.type==="TSNonNullExpression")return n(e.expression,t);return!1},m=(e)=>{if(e.type==="ArrayExpression")return e.elements.every((r)=>r===null||m(r));if(e.type==="LogicalExpression"&&e.operator==="&&")return m(e.right);if(e.type==="ConditionalExpression")return m(e.consequent)&&m(e.alternate);if(e.type==="Literal")return e.value===null||e.value===!1;if(e.type==="CallExpression")return m(e.callee);if(e.type!=="MemberExpression")return!1;const t=b(s,e.object);return t!==null&&S(s,t,"create",l)},E=(e,t)=>{let r=s.sourceCode.getScope(e);while(r){const y=r.set.get(t);if(y)return y.defs.some((u)=>{if(u.type!=="ImportBinding")return!1;const p=u.node;return p.parent?.type==="ImportDeclaration"&&p.parent.importKind!=="type"&&(p.type!=="ImportSpecifier"||p.importKind!=="type")});r=r.upper}return!1},h=(e)=>{for(const t of i.namespaces)if(E(e,t))return`${t}.props`;for(const t of i.named)if(E(e,t))return t;return null},X=(e,t,r,y)=>{if(/^[a-z][a-zA-Z0-9]*Sx$/.test(y)||e.type!=="JSXOpeningElement")return null;if(e.attributes.some((p)=>p!==t&&(p.type==="JSXSpreadAttribute"||["className","style"].includes(x(p)))))return null;if(r.type==="MemberExpression"&&!r.computed&&r.property.type==="Identifier"){const{object:p,property:I}=r;if(p.type==="CallExpression"&&["className","style"].includes(I.name)&&S(s,p,"props",i))return s.sourceCode.getText(p)}const u=h(t);return u&&m(r)?`${u}(${s.sourceCode.getText(r)})`:null};return{before(){a.namespaces.clear();a.named.clear();i.namespaces.clear();i.named.clear();l.namespaces.clear();l.named.clear();o.clear();return s.sourceCode.text.includes("stylex")},Program(e){c(e.body,"StyleXStyles",a);c(e.body,"StyleXStylesWithout",a);c(e.body,"props",i);c(e.body,"create",l)},TSPropertySignature(e){if(a.named.size===0&&a.namespaces.size===0)return;if(e.computed||!e.typeAnnotation||!f(e.typeAnnotation.typeAnnotation))return;s.report({node:e.key,message:"Spread `stylex.props(...)` at the call site instead of defining a StyleX style prop."})},JSXOpeningElement(e){if(e.name.type==="JSXIdentifier"&&!/^[A-Z]/.test(e.name.name))return;if(!l.namespaces.size&&!l.named.size&&!i.namespaces.size&&!i.named.size)return;for(const t of e.attributes){if(t.type==="JSXSpreadAttribute")continue;o.clear();const r=x(t);if(t.value?.type!=="JSXExpressionContainer")continue;const y=t.value.expression;if(!n(y,r==="className"))continue;const u=X(e,t,y,r);s.report({node:t,message:`Spread \`stylex.props(...)\` on this component instead of passing a StyleX style as \`${r}\`.`,suggest:u===null?void 0:[{desc:"Spread complete StyleX props",fix:(p)=>p.replaceText(t,`{...${u}}`)}]})}}}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ashstack/lint",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
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",
@@ -1 +0,0 @@
1
- import{attributeName as x,problem as h}from"../../../lib/ast.js";import{collectImports as l,isImportedBinding as m,isStylexCall as o}from"./imports.js";const f=/^[a-z][a-zA-Z0-9]*Sx$/,S=(i,n)=>{if(n.type!=="Identifier")return null;let a=i.sourceCode.getScope(n);while(a){const p=a.set.get(n.name);if(p){const y=p.defs.find((u)=>u.node.type==="VariableDeclarator")?.node;return y?.type==="VariableDeclarator"?y.init??null:null}a=a.upper}return null};export const useSxProp=h("Name StyleX override props `sx` or `<slot>Sx` and pass styles through them.",{createOnce(i){const n={namespaces:new Set,named:new Set},a={namespaces:new Set,named:new Set},p={namespaces:new Set,named:new Set},y=new Set,u=(e)=>{if(e.type==="TSTypeReference"){const t=e.typeName;if(t.type==="Identifier")return n.named.has(t.name)&&m(i,t);return t.type==="TSQualifiedName"&&t.left.type==="Identifier"&&n.namespaces.has(t.left.name)&&(t.right.name==="StyleXStyles"||t.right.name==="StyleXStylesWithout")&&m(i,t.left)}if(e.type==="TSUnionType"||e.type==="TSIntersectionType")return e.types.some(u);if(e.type==="TSParenthesizedType")return u(e.typeAnnotation);return!1},r=(e,t=!1)=>{if(e.type==="Identifier"){const s=S(i,e);if(s===null||y.has(s))return!1;y.add(s);return r(s,t)}if(e.type==="MemberExpression"){const s=S(i,e.object);if(s!==null&&o(i,s,"create",p))return!0;return r(e.object,t)}if(e.type==="CallExpression")return o(i,e,"props",a)||r(e.callee,t)||t&&e.arguments.some((s)=>r(s,!0));return c(e,t)},c=(e,t)=>{if(e.type==="ArrayExpression")return e.elements.some((s)=>s!==null&&r(s,t));if(e.type==="ObjectExpression")return e.properties.some((s)=>s.type==="Property"&&r(s.value,t));if(e.type==="ConditionalExpression")return r(e.consequent,t)||r(e.alternate,t);if(e.type==="LogicalExpression")return r(e.left,t)||r(e.right,t);if(e.type==="BinaryExpression")return r(e.left,t)||r(e.right,t);if(e.type==="TemplateLiteral")return e.expressions.some((s)=>r(s,t));if(e.type==="SpreadElement")return r(e.argument,t);if(e.type==="ChainExpression")return r(e.expression,t);if(e.type==="TSAsExpression"||e.type==="TSSatisfiesExpression"||e.type==="TSNonNullExpression")return r(e.expression,t);return!1};return{before(){n.namespaces.clear();n.named.clear();a.namespaces.clear();a.named.clear();p.namespaces.clear();p.named.clear();y.clear();return i.sourceCode.text.includes("stylex")},Program(e){l(e.body,"StyleXStyles",n);l(e.body,"StyleXStylesWithout",n);l(e.body,"props",a);l(e.body,"create",p)},TSPropertySignature(e){if(n.named.size===0&&n.namespaces.size===0)return;if(e.computed||!e.typeAnnotation||!u(e.typeAnnotation.typeAnnotation))return;let t=null;if(e.key.type==="Identifier")t=e.key.name;if(e.key.type==="Literal"&&typeof e.key.value==="string")t=e.key.value;if(t===null||t==="sx"||f.test(t))return;const s=t.startsWith("style")?"sx":`${t.replace(/Style$/,"")}Sx`;i.report({node:e.key,message:`Rename \`${t}\` to \`${s}\` for a StyleX override prop.`})},JSXOpeningElement(e){if(e.name.type==="JSXIdentifier"&&!/^[A-Z]/.test(e.name.name))return;if(!p.namespaces.size&&!p.named.size&&!a.namespaces.size&&!a.named.size)return;for(const t of e.attributes){y.clear();if(t.type==="JSXSpreadAttribute"){if(r(t.argument))i.report({node:t,message:"Pass StyleX styles as `sx` to this component."});continue}const s=x(t);if(s==="sx"||f.test(s)||t.value?.type!=="JSXExpressionContainer")continue;if(r(t.value.expression,s==="className"))i.report({node:t,message:`Pass this StyleX style as \`sx\` or a named \`<slot>Sx\` prop, not \`${s}\`.`})}}}}});