-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a custom lint rule to ensure we use v-clean-tooltip instead of…
… v-tooltip directives.
- Loading branch information
1 parent
50f7916
commit 1542da0
Showing
4 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.' | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters