chore: new payload/no-relative-monorepo-imports eslint rule
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Disallow imports from relative monorepo packages/*/src',
|
||||
category: 'Best Practices',
|
||||
recommended: true,
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
create: function (context) {
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
const importPath = node.source.value
|
||||
|
||||
// Match imports starting with any number of "../" followed by "packages/"
|
||||
const regex = /^(\.\.\/)*packages\/[^/]+\/src/
|
||||
|
||||
if (regex.test(importPath)) {
|
||||
context.report({
|
||||
node: node.source,
|
||||
message: 'Import from relative "packages/*/src" is not allowed',
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -2,5 +2,6 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
'no-non-retryable-assertions': require('./customRules/no-non-retryable-assertions'),
|
||||
'no-relative-monorepo-imports': require('./customRules/no-relative-monorepo-imports'),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user