packages,plugins: migrate to new lint config
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
const parent = require('@backstage/cli/config/eslint.backend');
|
||||
|
||||
module.exports = {
|
||||
extends: [require.resolve('@backstage/cli/config/eslint.backend')],
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname, {
|
||||
ignorePatterns: ['sample-templates/'],
|
||||
rules: {
|
||||
'no-console': 0, // Permitted in console programs
|
||||
'new-cap': ['error', { capIsNew: false }], // Because Express constructs things e.g. like 'const r = express.Router()'
|
||||
// Usage of path.resolve is extra sensitive in the scaffolder, so forbid it in non-test code
|
||||
'no-console': 0,
|
||||
'new-cap': [
|
||||
'error',
|
||||
{
|
||||
capIsNew: false,
|
||||
},
|
||||
],
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
...parent.rules['no-restricted-imports'][1],
|
||||
paths: [
|
||||
{
|
||||
name: 'path',
|
||||
@@ -19,23 +19,41 @@ module.exports = {
|
||||
'Do not use path.resolve, use `resolveSafeChildPath` from `@backstage/backend-common` instead as it prevents security issues',
|
||||
},
|
||||
],
|
||||
patterns: ['**/../../**/*/src/**', '**/../../**/*/src'],
|
||||
},
|
||||
],
|
||||
'no-restricted-syntax': parent.rules['no-restricted-syntax'].concat([
|
||||
'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"]',
|
||||
},
|
||||
{
|
||||
message:
|
||||
'Do not use path.resolve, use `resolveSafeChildPath` from `@backstage/backend-common` instead as it prevents security issues',
|
||||
selector:
|
||||
'MemberExpression[object.name="path"][property.name="resolve"]',
|
||||
},
|
||||
]),
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.test.*', 'src/setupTests.*', 'dev/**'],
|
||||
rules: {
|
||||
'no-restricted-imports': parent.rules['no-restricted-imports'],
|
||||
'no-restricted-imports': [
|
||||
2,
|
||||
{
|
||||
patterns: ['**/../../**/*/src/**', '**/../../**/*/src'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user