From 16f044cb6be037650c62e66979f64a856b1a76c3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 9 Oct 2021 13:42:27 +0200 Subject: [PATCH] cli: update backend eslint config to allow __dirname in tests Signed-off-by: Patrik Oldsberg --- .changeset/smart-seahorses-ring.md | 5 +++++ packages/cli/config/eslint.backend.js | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .changeset/smart-seahorses-ring.md diff --git a/.changeset/smart-seahorses-ring.md b/.changeset/smart-seahorses-ring.md new file mode 100644 index 0000000000..a5ae156afd --- /dev/null +++ b/.changeset/smart-seahorses-ring.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Update default backend ESLint configuration to allow usage of `__dirname` in tests. diff --git a/packages/cli/config/eslint.backend.js b/packages/cli/config/eslint.backend.js index 99767f5d79..a97f26f8da 100644 --- a/packages/cli/config/eslint.backend.js +++ b/packages/cli/config/eslint.backend.js @@ -14,6 +14,15 @@ * limitations under the License. */ +const globalRestrictedSyntax = [ + { + message: + 'Default import from winston is not allowed, import `* as winston` instead.', + selector: + 'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier', + }, +]; + module.exports = { extends: [ '@spotify/eslint-config-base', @@ -69,17 +78,12 @@ module.exports = { // Avoid default import from winston as it breaks at runtime 'no-restricted-syntax': [ 'error', - { - message: - 'Default import from winston is not allowed, import `* as winston` instead.', - selector: - 'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier', - }, { message: "`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-common` instead.", selector: 'Identifier[name="__dirname"]', }, + ...globalRestrictedSyntax, ], }, overrides: [ @@ -103,6 +107,7 @@ module.exports = { bundledDependencies: true, }, ], + 'no-restricted-syntax': ['error', ...globalRestrictedSyntax], }, }, ],