Skip to content

Commit 548ccb3

Browse files
committed
Replace ESLint config file overrides with inline eslint-disable comments
Move stylex/valid-styles suppression from a centralized file list in eslint.config.js to inline comments in each affected test-case output file. This keeps all other ESLint rules active for those files and makes false-positive reasons self-documenting at the point of suppression. Test normalizeCode() now strips eslint-disable/enable comments before comparison so the inline annotations don't affect codemod output matching. https://claude.ai/code/session_01XiDLahA95gukTrVrvaBU6e
1 parent e64780e commit 548ccb3

23 files changed

Lines changed: 41 additions & 35 deletions

eslint.config.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,5 @@ export default [
4343
"stylex/valid-styles": "error",
4444
},
4545
},
46-
{
47-
// stylex/valid-styles false positives: @stylexjs/eslint-plugin limitations
48-
// - Dynamic style fn params: rule can't validate runtime values
49-
// - Multi-animation comma values: rule only validates single values
50-
// - !important suffix: rule doesn't parse !important from value
51-
// - Computed stylex.when.*() keys: rule reports "Keys must be strings"
52-
// - outlineOffset/strokeDasharray numeric values: rule rejects valid numbers
53-
files: [
54-
"test-cases/conditional-nullishCoalescingWithUnit.output.tsx",
55-
"test-cases/conditional-runtimeCallBranch.output.tsx",
56-
"test-cases/conditional-runtimeCallLocal.output.tsx",
57-
"test-cases/conditional-runtimeCallThemeBool.output.tsx",
58-
"test-cases/css-important.output.tsx",
59-
"test-cases/helper-callPropArg.output.tsx",
60-
"test-cases/helper-memberCalleeMultiArg.output.tsx",
61-
"test-cases/interpolation-destructuredDefaults.output.tsx",
62-
"test-cases/interpolation-destructuredRename.output.tsx",
63-
"test-cases/keyframes-inlineDefinition.output.tsx",
64-
"test-cases/keyframes-multipleAnimations.output.tsx",
65-
"test-cases/keyframes-unionComplexity.output.tsx",
66-
"test-cases/mixin-dynamicArgDefault.output.tsx",
67-
"test-cases/selector-descendantComponent.output.tsx",
68-
"test-cases/selector-dynamicPseudoElement.output.tsx",
69-
"test-cases/selector-pseudoChained.output.tsx",
70-
"test-cases/selector-pseudoComma.output.tsx",
71-
"test-cases/selector-siblingMedia.output.tsx",
72-
"test-cases/theme-indexedLookupPropFallback.output.tsx",
73-
"test-cases/transientProp-memberExpression.output.tsx",
74-
],
75-
rules: {
76-
"stylex/valid-styles": "off",
77-
},
78-
},
7946
...storybook.configs["flat/recommended"],
8047
];

src/__tests__/run.e2e.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1616
const testCasesDir = join(__dirname, "..", "..", "test-cases");
1717

1818
async function normalizeCode(code: string): Promise<string> {
19-
const { code: formatted } = await format("test.tsx", code);
19+
// Strip eslint-disable comments so .output.tsx files can annotate
20+
// stylex plugin false positives without affecting codemod comparison
21+
const stripped = code
22+
.replace(/^\s*\/[/*] eslint-(?:disable|enable).*\n/gm, "")
23+
.replace(/ \/\/ eslint-disable.*$/gm, "");
24+
const { code: formatted } = await format("test.tsx", stripped);
2025
return formatted.replace(/\n{3,}/g, "\n\n").trim();
2126
}
2227

src/__tests__/transform.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ function runTransformWithDiagnostics(
219219
* Normalize code for comparison using oxfmt formatter
220220
*/
221221
async function normalizeCode(code: string, filePath: string = "test.tsx"): Promise<string> {
222-
const { code: formatted } = await format(filePath, code);
222+
// Strip eslint-disable comments so .output.tsx files can annotate
223+
// stylex plugin false positives without affecting codemod comparison
224+
const stripped = code
225+
.replace(/^\s*\/[/*] eslint-(?:disable|enable).*\n/gm, "")
226+
.replace(/ \/\/ eslint-disable.*$/gm, "")
227+
.replace(/\n{3,}/g, "\n\n");
228+
const { code: formatted } = await format(filePath, stripped);
223229
return formatted;
224230
}
225231

test-cases/conditional-nullishCoalescingWithUnit.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const styles = stylex.create({
3232
transitionProperty: "opacity",
3333
transitionDuration: "200ms",
3434
transitionTimingFunction: "ease-out",
35+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
3536
transitionDelay: props.transitionDelay,
3637
}),
3738
});

test-cases/conditional-runtimeCallBranch.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const styles = stylex.create({
3636
cardContainer: (props: { backgroundColor: string }) => ({
3737
paddingBlock: 8,
3838
paddingInline: 12,
39+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
3940
backgroundColor: props.backgroundColor,
4041
}),
4142
});

test-cases/conditional-runtimeCallLocal.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const styles = stylex.create({
3737
row: (props: { backgroundColor: string }) => ({
3838
paddingBlock: 8,
3939
paddingInline: 16,
40+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
4041
backgroundColor: props.backgroundColor,
4142
}),
4243
});

test-cases/conditional-runtimeCallThemeBool.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const styles = stylex.create({
3434
row: (props: { backgroundColor: string }) => ({
3535
paddingBlock: 8,
3636
paddingInline: 16,
37+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
3738
backgroundColor: props.backgroundColor,
3839
}),
3940
});

test-cases/css-important.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const styles = stylex.create({
2424
backgroundColor: "#bf4f74 !important",
2525
color: "white !important",
2626
borderWidth: "0 !important",
27+
// eslint-disable-next-line stylex/valid-styles -- !important suffix not parsed by rule
2728
borderStyle: "none !important",
2829
borderColor: "initial !important",
2930
paddingBlock: 8,

test-cases/helper-callPropArg.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const styles = stylex.create({
3030
width: 50,
3131
},
3232
boxBoxShadow: (boxShadow: string) => ({
33+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
3334
boxShadow: shadow(boxShadow),
3435
}),
3536
});

test-cases/helper-memberCalleeMultiArg.output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const styles = stylex.create({
4949
toggle: (props: { backgroundColor: string }) => ({
5050
paddingBlock: 8,
5151
paddingInline: 16,
52+
// eslint-disable-next-line stylex/valid-styles -- dynamic style fn param
5253
backgroundColor: props.backgroundColor,
5354
}),
5455
boxBackgroundColor: (backgroundColor: string) => ({

0 commit comments

Comments
 (0)