Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Disallow all link components except `<VLink>` with eslint rule (#916)

Zack Krida6b838c684490
diff --git a/.eslintrc.js b/.eslintrc.js
index 04b047e88..22b877e5f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -50,6 +50,26 @@ module.exports = {
'warn',
{ required: { some: ['nesting', 'id'] } },
],
+ /**
+ * Custom rule to disallow raw `<a></a>` tag usage.
+ * Learn more about vue-eslint-parser's AST syntax:
+ * https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md
+ */
+ 'vue/no-restricted-syntax': [
+ 'error',
+ {
+ selector: 'VElement[name="a"]',
+ message: 'Use the <VLink> component instead of a raw <a> tag.',
+ },
+ {
+ selector: 'VElement[name="nuxtlink"]',
+ message: 'Use the <VLink> component instead of <NuxtLink>.',
+ },
+ {
+ selector: 'VElement[name="routerlink"]',
+ message: 'Use the <VLink> component instead of <RouterLink>.',
+ },
+ ],
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
},
settings: {