UNPKG

@gitlab/eslint-plugin

Version:

GitLab package for our custom eslint rules

72 lines (68 loc) 1.86 kB
// ------------------------------------------------------------------------------ // Requirements // ------------------------------------------------------------------------------ const { DOCS_BASE_URL } = require('../constants'); const { literalValidator, templateLiteralValidator, memberExpressionValidator, } = require('../utils/hardcoded-urls'); // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ module.exports = { meta: { type: 'error', docs: { description: 'Disallow hardcoded URLs', category: 'maintainability', url: DOCS_BASE_URL + '/no-hardcoded-urls.md', }, schema: [ { type: 'object', properties: { allowedKeys: { type: 'array', items: { type: 'string' }, default: [], }, allowedFunctions: { type: 'array', items: { type: 'string' }, default: [], }, allowedInterpolationVariables: { type: 'array', items: { type: 'string' }, default: [], }, allowedPatterns: { type: 'array', items: { type: 'string' }, default: [], }, disallowedObjectProperties: { type: 'array', items: { type: 'string' }, default: [], }, }, additionalProperties: false, }, ], }, create(context) { return { Literal(node) { literalValidator(context, node); }, TemplateLiteral(node) { templateLiteralValidator(context, node); }, MemberExpression(node) { memberExpressionValidator(context, node); }, }; }, };