eslint-plugin-conarti-fsd
Version:
Feature-sliced design methodology plugin
52 lines (48 loc) • 1.14 kB
JavaScript
/**
* @fileoverview Checks layer imports
* @author conarti
*/
;
const { ERROR_MESSAGE_ID } = require('./config');
const { validateAndReport } = require('./model');
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Checks layer imports',
recommended: false,
url: null,
},
fixable: null,
messages: {
[ERROR_MESSAGE_ID.CAN_NOT_IMPORT]: 'You cannot import layer "{{ importLayer }}" into "{{ currentFileLayer }}" (shared -> entities -> features -> widgets -> pages -> processes -> app)',
},
schema: [
{
type: 'object',
properties: {
allowTypeImports: {
type: 'boolean',
},
ignorePatterns: {
type: 'array',
items: {
type: 'string',
},
},
},
},
],
},
create(context) {
return {
ImportDeclaration(node) {
validateAndReport(node, context);
},
ImportExpression(node) {
validateAndReport(node, context);
},
};
},
};