Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(eslint-plugin): match no-react-introspection allowFiles on Windows (#5639)

Ojas Mutreja97a55c8a360e
diff --git a/internal/eslint-plugin-astryx/no-react-introspection.js b/internal/eslint-plugin-astryx/no-react-introspection.js
index ae9a5a70d7..ffe0a5cee7 100644
--- a/internal/eslint-plugin-astryx/no-react-introspection.js
+++ b/internal/eslint-plugin-astryx/no-react-introspection.js
@@ -74,8 +74,13 @@ const noReactIntrospectionRule = {
const options = context.options[0] || {};
const allowFiles = options.allowFiles || [];
- // Check if this file is explicitly allowed
- const filename = context.filename ?? context.getFilename();
+ // Check if this file is explicitly allowed. Patterns are written with
+ // forward slashes; normalize before matching so this also works on
+ // Windows, where context.filename comes back with backslashes.
+ const filename = (context.filename ?? context.getFilename()).replace(
+ /\\/g,
+ '/',
+ );
if (allowFiles.some(pattern => filename.includes(pattern))) {
return {};
}
diff --git a/internal/eslint-plugin-astryx/no-react-introspection.test.mjs b/internal/eslint-plugin-astryx/no-react-introspection.test.mjs
index 360d98f6f0..c9b2b1ab12 100644
--- a/internal/eslint-plugin-astryx/no-react-introspection.test.mjs
+++ b/internal/eslint-plugin-astryx/no-react-introspection.test.mjs
@@ -30,6 +30,13 @@ tester.run('no-react-introspection', noReactIntrospectionRule, {
options: [{allowFiles: ['test-utils']}],
filename: '/packages/test-utils/src/helpers.tsx',
},
+ // allowFiles escape hatch on Windows, where ESLint reports filename with
+ // backslash separators against a forward-slash pattern.
+ {
+ code: `import { Children } from 'react'; Children.map(children, c => c);`,
+ options: [{allowFiles: ['test-utils']}],
+ filename: 'D:\\repo\\packages\\test-utils\\src\\helpers.tsx',
+ },
],
invalid: [
// Children.toArray