#1893·stylex

@stylexjs/eslint-plugin 对 propLimits 的更多选项

作者: ysulyma创建于 2026年9月17日更新于 2026年9月17日
标签enhancement

// eslint.config.js export default [ { ignores: ["dist/**"], }, { files: ["src/**/*.{ts,tsx}"], plugins: { "@stylexjs": stylexPlugin }, rules: { "@stylexjs/valid-styles": [ "error", { propLimits: { backgroundColor: { limit: { variable: true }, reason: "must pass a StyleX variable", }, borderColor: { limit: { variable: { name: ["colors", "scales"] }, }, reason: "must pass one of the StyleX variables `colors` or `scales`", }, color: { limit: { variable: { from: "./src/lib/tokens.stylex.ts", name: ["colors", "scales"] }, }, reason: "must pass one of the StyleX variables `colors` or `scales`", }, marginLeft: { // array for unions of acceptable values, similar to existing behavior limit: [ "auto", { variable: true }, ], reason: "must pass a StyleX variable, or the literal string 'auto'", }, outlineColor: { limit: [ { null: true }, { variable: { from: "./src/lib/tokens.stylex.ts", name: ["colors"], property: ["destructive", "success"] }, }, ], reason: "must pass one of the StyleX variables `colors` or `scales`", }, paddingLeft: { limit: { cssVar: true }, reason: "must pass a CSS variable", }, paddingRight: { limit: { cssVar: ["--padding-sm", "--padding-lg"], }, reason: "must pass one of the CSS variables `--padding-sm` or `--padding-lg`", }, zIndex: { limit: [ { const: { from: "./src/lib/tokens.stylex.ts", // name can be a string if there is only one name: "layers", }, }, { calc: true }, ], reason: "must pass a `layers.*` constant from …", }, }, }, ], },

内容来源: facebook/stylex