UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

67 lines (66 loc) 2.42 kB
import Rule from './rule.js'; import { INFO, WARNING, ERROR } from './rule-levels.js'; export const rulesNames = { ENT_SHORTER_DECL: 'ENT_SHORTER_DECL', ENT_OPTIONAL_TABLE_NAME: 'ENT_OPTIONAL_TABLE_NAME', ENT_DUPLICATED: 'ENT_DUPLICATED', FLD_OPTIONAL_COMMAS: 'FLD_OPTIONAL_COMMAS', REL_INDIVIDUAL_DECL: 'REL_INDIVIDUAL_DECL', AIGC_INDIVIDUAL_DECL: 'AIGC_INDIVIDUAL_DECL', FLD_DUPLICATED: 'FLD_DUPLICATED', ENUM_DUPLICATED: 'ENUM_DUPLICATED', ENUM_UNUSED: 'ENUM_UNUSED', }; export const rules = { ENT_SHORTER_DECL: new Rule({ name: 'ShorterEntityDeclaration', level: INFO, comment: 'When an entity does not have any field, it is possible to omit the curly braces.', }), ENT_OPTIONAL_TABLE_NAME: new Rule({ name: 'OptionalEntityTableName', level: WARNING, comment: 'Setting custom table names is possible, but not recommended.', }), ENT_DUPLICATED: new Rule({ name: 'DuplicatedEntityDeclaration', level: ERROR, comment: 'An entity should not be declared more than once.', }), FLD_DUPLICATED: new Rule({ name: 'DuplicatedFieldDeclaration', level: ERROR, comment: 'A field should not be declared more than once in an entity.', }), FLD_OPTIONAL_COMMAS: new Rule({ name: 'OptionalFieldCommas', level: INFO, comment: 'While commas are supported, they are not mandatory if only one field is declared per line.', }), REL_INDIVIDUAL_DECL: new Rule({ name: 'IndividualRelationshipDeclaration', level: WARNING, comment: 'It is preferable to group relationships by type instead of declaring them one by one.', }), AIGC_INDIVIDUAL_DECL: new Rule({ name: 'IndividualAigcDeclaration', level: WARNING, comment: 'It is preferable to group aigcs by type instead of declaring them one by one.', }), ENUM_DUPLICATED: new Rule({ name: 'DuplicatedEnumDeclaration', level: ERROR, comment: 'An enum should not be declared more than once.', }), ENUM_UNUSED: new Rule({ name: 'UnusedEnum', level: INFO, comment: 'An unused enum should be removed.', }), }; export function getRule(ruleName) { if (!ruleName) { throw new Error('A rule name has to be passed to get a rule.'); } return rules[ruleName]; }