@gitlab/eslint-plugin
Version:
GitLab package for our custom eslint rules
78 lines (74 loc) • 2.13 kB
JavaScript
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const { DOCS_BASE_URL } = require('../constants');
const { defineTemplateBodyVisitor } = require('../utils/index');
const {
literalValidator,
templateLiteralValidator,
memberExpressionValidator,
} = require('../utils/hardcoded-urls');
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
type: 'error',
docs: {
description: 'Disallow hardcoded URLs in Vue templates',
category: 'maintainability',
url: DOCS_BASE_URL + '/vue-no-hardcoded-urls.md',
},
schema: [
{
type: 'object',
properties: {
allowedVueComponents: {
type: 'array',
items: { type: 'string' },
default: [],
},
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 defineTemplateBodyVisitor(context, {
VLiteral(node) {
literalValidator(context, node);
},
TemplateLiteral(node) {
templateLiteralValidator(context, node);
},
MemberExpression(node) {
memberExpressionValidator(context, node);
},
});
},
};