cli: update backend eslint config to allow __dirname in tests

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-10-09 13:42:27 +02:00
parent 9faf634497
commit 16f044cb6b
2 changed files with 16 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Update default backend ESLint configuration to allow usage of `__dirname` in tests.
+11 -6
View File
@@ -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],
},
},
],