mirror of https://github.com/rancher/dashboard.git
Merge pull request #12633 from codyrancher/linter
Adding a custom lint rule to ensure we use v-clean-tooltip instead of v-tooltip directives.
This commit is contained in:
commit
d413605ca3
|
|
@ -190,7 +190,10 @@ module.exports = {
|
||||||
'vue/one-component-per-file': 'off',
|
'vue/one-component-per-file': 'off',
|
||||||
'vue/no-deprecated-slot-attribute': 'off',
|
'vue/no-deprecated-slot-attribute': 'off',
|
||||||
'vue/require-explicit-emits': 'error',
|
'vue/require-explicit-emits': 'error',
|
||||||
'vue/v-on-event-hyphenation': 'off'
|
'vue/v-on-event-hyphenation': 'off',
|
||||||
|
|
||||||
|
// Locally defined rules, you can find these defined in the `eslint-local-rules` directory.
|
||||||
|
'v-clean-tooltip': 'error',
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Currently loading these rules with the --rulesdir argument. In the future we could make use of `eslint-plugin-local-rules`.
|
||||||
|
const vueUtils = require('eslint-plugin-vue/lib/utils');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
meta: {
|
||||||
|
type: 'problem',
|
||||||
|
docs: { description: 'We want to use `v-clean-tooltip` instead of `v-tooltip` in most all areas to avoid XSS exploits.' },
|
||||||
|
schema: [],
|
||||||
|
},
|
||||||
|
create(context) {
|
||||||
|
return vueUtils.defineTemplateBodyVisitor(context, {
|
||||||
|
VAttribute(node) {
|
||||||
|
// v-tooltip is a VDirectiveKey
|
||||||
|
if (node?.key?.type !== 'VDirectiveKey') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// v-tooltip is also a VIdentifier
|
||||||
|
if (node.key.name.type !== 'VIdentifier') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.key.name.name === 'tooltip') {
|
||||||
|
context.report({
|
||||||
|
node: node.key,
|
||||||
|
loc: node.loc,
|
||||||
|
message: 'We want to use `v-clean-tooltip` instead of `v-tooltip` in most all areas to avoid XSS exploits.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"serve-pkgs": "./shell/scripts/serve-pkgs",
|
"serve-pkgs": "./shell/scripts/serve-pkgs",
|
||||||
"publish-shell-reset-reg": "cd shell && npm publish",
|
"publish-shell-reset-reg": "cd shell && npm publish",
|
||||||
"clean": "./shell/scripts/clean",
|
"clean": "./shell/scripts/clean",
|
||||||
"lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .js,.ts,.vue .",
|
"lint": "./node_modules/.bin/eslint --rulesdir ./eslint-local-rules --max-warnings 0 --ext .js,.ts,.vue .",
|
||||||
"lint:lib": "cd pkg/rancher-components && yarn lint",
|
"lint:lib": "cd pkg/rancher-components && yarn lint",
|
||||||
"lint-l10n": "./node_modules/.bin/yamllint ./shell/assets/translations",
|
"lint-l10n": "./node_modules/.bin/yamllint ./shell/assets/translations",
|
||||||
"test": "NODE_OPTIONS=--max_old_space_size=8192 jest --watch",
|
"test": "NODE_OPTIONS=--max_old_space_size=8192 jest --watch",
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
],
|
],
|
||||||
"types": "./types/index.d.ts",
|
"types": "./types/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:lib": "vue-cli-service build --target lib --name @rancher/components src/main.ts",
|
"build:lib": "vue-cli-service build --skip-plugins eslint --target lib --name @rancher/components src/main.ts",
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint --rulesdir ../../eslint-local-rules"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue