eslint-plugin-fsd-arch-validator
Version:
Validate whether module imports within your project meet the requirements of FSD architecture
95 lines (92 loc) • 3.44 kB
JavaScript
const rule = require("../../../lib/rules/layer-imports"),
RuleTester = require("eslint").RuleTester;
const aliasOptions = [
{
alias: '@'
}
]
const ruleTester = new RuleTester({
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
});
ruleTester.run("layer-imports", rule, {
valid: [
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\features\\Article',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/shared/Button.tsx'",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\features\\Article',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\app\\providers',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/widgets/Articl'",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\widgets\\pages',
code: "import { useLocation } from 'react-router-dom'",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\app\\providers',
code: "import { addCommentFormActions, addCommentFormReducer } from 'redux'",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\index.tsx',
code: "import { StoreProvider } from '@/app/providers/StoreProvider';",
errors: [],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\Article.tsx',
code: "import { StateSchema } from '@/app/providers/StoreProvider'",
errors: [],
options: [
{
alias: '@',
ignoreImportPatterns: ['**/StoreProvider']
}
],
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\Article.tsx',
code: "import { StateSchema } from '@/app/providers/StoreProvider'",
errors: [],
options: [
{
alias: '@',
ignoreImportPatterns: ['**/StoreProvider']
}
],
},
],
invalid: [
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\providers',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/features/Articl'",
errors: [{ message: "Layer may only import from underlying ones (shared, entities)."}],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\features\\providers',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/widgets/Articl'",
errors: [{ message: "Layer may only import from underlying ones (shared, entities)."}],
options: aliasOptions,
},
{
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\providers',
code: "import { addCommentFormActions, addCommentFormReducer } from '@/widgets/Articl'",
errors: [{ message: "Layer may only import from underlying ones (shared, entities)."}],
options: aliasOptions,
},
],
});