diff --git a/.changeset/famous-bobcats-remain.md b/.changeset/famous-bobcats-remain.md new file mode 100644 index 0000000000..6943eb7e56 --- /dev/null +++ b/.changeset/famous-bobcats-remain.md @@ -0,0 +1,5 @@ +--- +'@backstage/eslint-plugin': patch +--- + +Internal refactor to deal with `estree` upgrade diff --git a/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js b/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js index 78fd3d63e9..6e0ba9ee87 100644 --- a/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js +++ b/packages/eslint-plugin/rules/no-top-level-material-ui-4-imports.js @@ -80,11 +80,14 @@ const KNOWN_STYLES = [ /** * filter function to keep only ImportSpecifier nodes - * @param {import('estree').ImportSpecifier | import('estree').ImportDefaultSpecifier| import('estree').ImportNamespaceSpecifier} specifier + * @param {import('estree').ImportSpecifier | import('estree').ImportDefaultSpecifier | import('estree').ImportNamespaceSpecifier} specifier * @returns {specifier is import('estree').ImportSpecifier} */ function importSpecifiersFilter(specifier) { - return specifier.type === 'ImportSpecifier'; + return ( + specifier.type === 'ImportSpecifier' && + specifier.imported.type !== 'Literal' + ); } /** @@ -146,12 +149,16 @@ module.exports = { const specifiers = node.specifiers.filter(importSpecifiersFilter); - const specifiersMap = specifiers.map( + const specifiersMap = specifiers.flatMap( /** * transform ImportSpecifier to FixerValues to have a simpler object to work with - * @returns {FixerValues} + * @returns {FixerValues[]} */ s => { + if (s.imported.type === 'Literal') { + return []; + } + const value = s.imported.name; const alias = s.local.name === value ? undefined : s.local.name; @@ -165,19 +172,24 @@ module.exports = { const emitComponent = !emitProp; const emitComponentAndProp = emitProp && - specifiers.find(s => s.imported.name === propsMatch[1])?.local - .name; + specifiers.find( + s => + s.imported.type !== 'Literal' && + s.imported.name === propsMatch[1], + )?.local.name; - return { - emitComponent: emitComponent || Boolean(emitComponentAndProp), - emitProp, - value, - componentValue: propsMatch ? propsMatch[1] : undefined, - componentAlias: emitComponentAndProp - ? emitComponentAndProp - : undefined, - alias, - }; + return [ + { + emitComponent: emitComponent || Boolean(emitComponentAndProp), + emitProp, + value, + componentValue: propsMatch ? propsMatch[1] : undefined, + componentAlias: emitComponentAndProp + ? emitComponentAndProp + : undefined, + alias, + }, + ]; }, ); diff --git a/yarn.lock b/yarn.lock index c8964dd4b6..ad20fae595 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14544,114 +14544,114 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.22.4" +"@rollup/rollup-android-arm-eabi@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.22.5" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-android-arm64@npm:4.22.4" +"@rollup/rollup-android-arm64@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-android-arm64@npm:4.22.5" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-darwin-arm64@npm:4.22.4" +"@rollup/rollup-darwin-arm64@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-darwin-arm64@npm:4.22.5" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-darwin-x64@npm:4.22.4" +"@rollup/rollup-darwin-x64@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-darwin-x64@npm:4.22.5" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.22.4" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.22.5" conditions: os=linux & cpu=arm & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm-musleabihf@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.22.4" +"@rollup/rollup-linux-arm-musleabihf@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.22.5" conditions: os=linux & cpu=arm & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.22.4" +"@rollup/rollup-linux-arm64-gnu@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.22.5" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.22.4" +"@rollup/rollup-linux-arm64-musl@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.22.5" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.4" +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.5" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.22.4" +"@rollup/rollup-linux-riscv64-gnu@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.22.5" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-s390x-gnu@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.22.4" +"@rollup/rollup-linux-s390x-gnu@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.22.5" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.22.4" +"@rollup/rollup-linux-x64-gnu@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.22.5" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.22.4" +"@rollup/rollup-linux-x64-musl@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.22.5" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.22.4" +"@rollup/rollup-win32-arm64-msvc@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.22.5" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.22.4" +"@rollup/rollup-win32-ia32-msvc@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.22.5" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.22.4": - version: 4.22.4 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.22.4" +"@rollup/rollup-win32-x64-msvc@npm:4.22.5": + version: 4.22.5 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.22.5" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -17376,10 +17376,10 @@ __metadata: languageName: node linkType: hard -"@types/estree@npm:*, @types/estree@npm:1.0.5, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5": - version: 1.0.5 - resolution: "@types/estree@npm:1.0.5" - checksum: dd8b5bed28e6213b7acd0fb665a84e693554d850b0df423ac8076cc3ad5823a6bc26b0251d080bdc545af83179ede51dd3f6fa78cad2c46ed1f29624ddf3e41a +"@types/estree@npm:*, @types/estree@npm:1.0.6, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5": + version: 1.0.6 + resolution: "@types/estree@npm:1.0.6" + checksum: 8825d6e729e16445d9a1dd2fb1db2edc5ed400799064cd4d028150701031af012ba30d6d03fe9df40f4d7a437d0de6d2b256020152b7b09bde9f2e420afdffd9 languageName: node linkType: hard @@ -39568,26 +39568,26 @@ __metadata: linkType: hard "rollup@npm:^4.0.0, rollup@npm:^4.20.0": - version: 4.22.4 - resolution: "rollup@npm:4.22.4" + version: 4.22.5 + resolution: "rollup@npm:4.22.5" dependencies: - "@rollup/rollup-android-arm-eabi": 4.22.4 - "@rollup/rollup-android-arm64": 4.22.4 - "@rollup/rollup-darwin-arm64": 4.22.4 - "@rollup/rollup-darwin-x64": 4.22.4 - "@rollup/rollup-linux-arm-gnueabihf": 4.22.4 - "@rollup/rollup-linux-arm-musleabihf": 4.22.4 - "@rollup/rollup-linux-arm64-gnu": 4.22.4 - "@rollup/rollup-linux-arm64-musl": 4.22.4 - "@rollup/rollup-linux-powerpc64le-gnu": 4.22.4 - "@rollup/rollup-linux-riscv64-gnu": 4.22.4 - "@rollup/rollup-linux-s390x-gnu": 4.22.4 - "@rollup/rollup-linux-x64-gnu": 4.22.4 - "@rollup/rollup-linux-x64-musl": 4.22.4 - "@rollup/rollup-win32-arm64-msvc": 4.22.4 - "@rollup/rollup-win32-ia32-msvc": 4.22.4 - "@rollup/rollup-win32-x64-msvc": 4.22.4 - "@types/estree": 1.0.5 + "@rollup/rollup-android-arm-eabi": 4.22.5 + "@rollup/rollup-android-arm64": 4.22.5 + "@rollup/rollup-darwin-arm64": 4.22.5 + "@rollup/rollup-darwin-x64": 4.22.5 + "@rollup/rollup-linux-arm-gnueabihf": 4.22.5 + "@rollup/rollup-linux-arm-musleabihf": 4.22.5 + "@rollup/rollup-linux-arm64-gnu": 4.22.5 + "@rollup/rollup-linux-arm64-musl": 4.22.5 + "@rollup/rollup-linux-powerpc64le-gnu": 4.22.5 + "@rollup/rollup-linux-riscv64-gnu": 4.22.5 + "@rollup/rollup-linux-s390x-gnu": 4.22.5 + "@rollup/rollup-linux-x64-gnu": 4.22.5 + "@rollup/rollup-linux-x64-musl": 4.22.5 + "@rollup/rollup-win32-arm64-msvc": 4.22.5 + "@rollup/rollup-win32-ia32-msvc": 4.22.5 + "@rollup/rollup-win32-x64-msvc": 4.22.5 + "@types/estree": 1.0.6 fsevents: ~2.3.2 dependenciesMeta: "@rollup/rollup-android-arm-eabi": @@ -39626,7 +39626,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: b093b518deb1fd0c0455eef746abe9efa3a2cd7e2b65a4ace9e8fa5d60b3d6da2406816de2c6c1d553609f22cf730f1c5839a05a1ff60003c504486172238d1a + checksum: 894b3d428b5a7f1db2245f50622ce65a3ad8f754265dd1da7dce133e39b315516dbcbac51e4fe100b44d59b168bac3f36ebaeb836fc9f7057d4972f44497d046 languageName: node linkType: hard