Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rules/no-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const utils = require('../utils')

// eslint-disable-next-line no-invalid-meta, no-invalid-meta-docs-categories
module.exports = utils.wrapCoreRule('no-console', {
skipCoreHandlers: true,
create(context) {
const options = context.options[0] || {}
const allowed = options.allow || []
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ module.exports = {
* @param {boolean} [options.skipDynamicArguments] If `true`, skip validation within dynamic arguments.
* @param {boolean} [options.skipDynamicArgumentsReport] If `true`, skip report within dynamic arguments.
* @param {boolean} [options.applyDocument] If `true`, apply check to document fragment.
* @param {boolean} [options.skipCoreHandlers] If `true`, skip core handlers.
* @param {WrapCoreRulePreprocess} [options.preprocess] Preprocess to calling create of core rule.
* @param {WrapCoreRuleCreate} [options.create] If define, extend core rule.
* @returns {RuleModule} The wrapped rule implementation.
Expand Down Expand Up @@ -418,6 +419,7 @@ module.exports = {
categories,
skipDynamicArguments,
skipDynamicArgumentsReport,
skipCoreHandlers,
applyDocument,
preprocess,
create
Expand Down Expand Up @@ -457,7 +459,9 @@ module.exports = {
}

const coreHandlers = coreRule.create(context)
compositingVisitors(handlers, coreHandlers)
if (!skipCoreHandlers) {
compositingVisitors(handlers, coreHandlers)
}

// Move `Program` handlers to `VElement[parent.type!='VElement']`
if (handlers.Program) {
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/no-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ tester.run('no-console', rule, {
</template>
`,
options: [{ allow: ['log', 'warn', 'info'] }]
},
{
filename: 'test.vue',
code: `
<template>
<button :foo="console.error">button</button>
</template>
<script setup>
console.log('test')
</script>
`,
options: [{ allow: ['error'] }]
}
],
invalid: [
Expand Down