fix: review findings
removed default exclude targets so that tests are also in the scope. added new includedFiles option that defaults to all in src/ directories added more ignored packages to local config to make this pass, needs fixes later on Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
+7
-3
@@ -24,13 +24,17 @@ module.exports = {
|
||||
'error',
|
||||
{
|
||||
// TODO: Fix these either by right role or by moving things to new packages
|
||||
// TODO: Additionally remove the '**/*.{test,spec}.[jt]s?(x)' from `excludedFiles` in `no-mixed-plugin-imports`
|
||||
// and fix the errors
|
||||
excludedTargetPackages: [
|
||||
'@backstage/plugin-catalog',
|
||||
'@backstage/plugin-techdocs',
|
||||
'@backstage/plugin-app',
|
||||
'@backstage/plugin-catalog-backend'
|
||||
'@backstage/plugin-catalog-backend',
|
||||
'@backstage/test-utils',
|
||||
'@backstage/plugin-auth-backend',
|
||||
'@backstage/plugin-permission-backend',
|
||||
'@backstage/plugin-kubernetes-backend',
|
||||
'@backstage/config-loader',
|
||||
'@backstage/plugin-app-backend'
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
@@ -68,6 +68,7 @@ module.exports = {
|
||||
'Use web library {{targetPackage}}-react or common library instead.',
|
||||
useNodePlugin:
|
||||
'Use node library {{targetPackage}}-node or common library instead.',
|
||||
useCommonPlugin: 'Use common library {{targetPackage}}-common instead.',
|
||||
removeImport:
|
||||
'Remove this import to avoid mixed plugin imports. Fix the code by refactoring it to use the correct plugin type.',
|
||||
},
|
||||
@@ -90,6 +91,11 @@ module.exports = {
|
||||
items: { type: 'string' },
|
||||
uniqueItems: true,
|
||||
},
|
||||
includedFiles: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
@@ -115,12 +121,14 @@ module.exports = {
|
||||
/** @type {string[]} */
|
||||
const ignoreTargetPackages = options.excludedTargetPackages || [];
|
||||
/** @type {string[]} */
|
||||
const ignorePatterns = options.excludedFiles || [
|
||||
'**/*.{test,spec}.[jt]s?(x)',
|
||||
'**/dev/index.[jt]s?(x)',
|
||||
];
|
||||
const excludePatterns = options.excludedFiles || [];
|
||||
/** @type {string[]} */
|
||||
const includePatterns = options.includedFiles || ['**/src/**'];
|
||||
|
||||
if (ignorePatterns.some(pattern => matchesPattern(pattern, filePath))) {
|
||||
if (
|
||||
!includePatterns.some(pattern => matchesPattern(pattern, filePath)) ||
|
||||
excludePatterns.some(pattern => matchesPattern(pattern, filePath))
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -170,6 +178,19 @@ module.exports = {
|
||||
return fixer.replaceText(imp.node, newImport);
|
||||
},
|
||||
});
|
||||
suggest.push({
|
||||
messageId: 'useCommonPlugin',
|
||||
data: {
|
||||
targetPackage: targetName,
|
||||
},
|
||||
/** @param {import('eslint').Rule.RuleFixer} fixer */
|
||||
fix(fixer) {
|
||||
const source = context.sourceCode;
|
||||
const nodeSource = source.getText(imp.node);
|
||||
const newImport = nodeSource.replace(/'$/, "-common'");
|
||||
return fixer.replaceText(imp.node, newImport);
|
||||
},
|
||||
});
|
||||
} else if (
|
||||
(sourceRole === 'backend-plugin' ||
|
||||
sourceRole === 'backend-plugin-module') &&
|
||||
@@ -188,6 +209,19 @@ module.exports = {
|
||||
return fixer.replaceText(imp.node, newImport);
|
||||
},
|
||||
});
|
||||
suggest.push({
|
||||
messageId: 'useCommonPlugin',
|
||||
data: {
|
||||
targetPackage: targetName,
|
||||
},
|
||||
/** @param {import('eslint').Rule.RuleFixer} fixer */
|
||||
fix(fixer) {
|
||||
const source = context.sourceCode;
|
||||
const nodeSource = source.getText(imp.node);
|
||||
const newImport = nodeSource.replace(/-backend'$/, '-common');
|
||||
return fixer.replaceText(imp.node, newImport);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
suggest.push({
|
||||
messageId: 'removeImport',
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
"dependencies": {
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-node": "workspace:^",
|
||||
"@backstage/plugin-events-node": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -5995,7 +5995,6 @@ __metadata:
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend": "workspace:^"
|
||||
"@backstage/plugin-catalog-node": "workspace:^"
|
||||
"@backstage/plugin-events-backend-test-utils": "workspace:^"
|
||||
"@backstage/plugin-events-node": "workspace:^"
|
||||
languageName: unknown
|
||||
|
||||
Reference in New Issue
Block a user