Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false negatives when using parsers other than vue-eslint-parser in no-missing-keys #312

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import {
defineTemplateBodyVisitor,
getLocaleMessages,
getStaticLiteralValue,
isStaticLiteral
isStaticLiteral,
compositingVisitors
} from '../utils/index'
import type { AST as VAST } from 'vue-eslint-parser'
import type { RuleContext, RuleListener } from '../types'
import { createRule } from '../utils/rule'

function create(context: RuleContext): RuleListener {
return defineTemplateBodyVisitor(
context,
{
return compositingVisitors(
defineTemplateBodyVisitor(context, {
"VAttribute[directive=true][key.name='t']"(node: VAST.VDirective) {
checkDirective(context, node)
},
Expand All @@ -33,7 +33,7 @@ function create(context: RuleContext): RuleListener {
CallExpression(node: VAST.ESLintCallExpression) {
checkCallExpression(context, node)
}
},
}),
{
CallExpression(node: VAST.ESLintCallExpression) {
checkCallExpression(context, node)
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export function skipTSAsExpression<T extends VAST.Node>(node: T): T {
return node
}

function compositingVisitors(
export function compositingVisitors(
visitor: RuleListener,
...visitors: RuleListener[]
) {
Expand Down
9 changes: 8 additions & 1 deletion tests/lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ tester.run('no-missing-keys', rule as never, {
]
),

invalid: buildTestsForLocales(
invalid: buildTestsForLocales<RuleTester.InvalidTestCase>(
[
{
// basic
Expand Down Expand Up @@ -275,6 +275,13 @@ tester.run('no-missing-keys', rule as never, {
errors: [
`'messages.missing' does not exist in localization message resources`
]
},
{
parser: require.resolve('espree'),
code: `$t('messages.missing')`,
errors: [
`'messages.missing' does not exist in localization message resources`
]
}
],
[
Expand Down