Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c931ae6

Browse files
Fix crash in component-api-style rule (#1721)
1 parent 20eaee7 commit c931ae6

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

‎lib/rules/component-api-style.js‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,18 @@ module.exports = {
274274
if (!name) {
275275
continue
276276
}
277-
const propAllowed = apis.some(
278-
(api) => api.allow && api.options.has(name)
279-
)
280-
if (!propAllowed) {
277+
const disallowApi =
278+
!apis.some((api) => api.allow && api.options.has(name)) &&
279+
apis.find((api) => !api.allow && api.options.has(name))
280+
281+
if (disallowApi) {
281282
context.report({
282283
node: prop.key,
283284
messageId: isPreferScriptSetup(allows)
284285
? 'disallowComponentOptionPreferScriptSetup'
285286
: 'disallowComponentOption',
286287
data: {
287-
disallowedApi: apis.filter(
288-
(api) => !api.allow && api.options.has(name)
289-
)[0].apiName,
288+
disallowedApi: disallowApi.apiName,
290289
optionPhrase: buildOptionPhrase(name),
291290
allowedApis: buildAllowedPhrase(allows)
292291
}

‎tests/lib/rules/component-api-style.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,35 @@ tester.run('component-api-style', rule, {
181181
}
182182
</script>
183183
`
184+
},
185+
{
186+
// https://github.com/vuejs/eslint-plugin-vue/issues/1720
187+
filename: 'test.vue',
188+
options: [['composition']],
189+
code: `
190+
<template>
191+
<div id="app">
192+
<header>
193+
<Navigation />
194+
</header>
195+
<main class="container-fluid mb-4" role="main">
196+
<RouterView />
197+
</main>
198+
</div>
199+
</template>
200+
201+
<script lang="ts">
202+
import { defineComponent } from '@vue/composition-api'
203+
204+
import Navigation from '@/components/app/nav/Navigation.vue'
205+
206+
export default defineComponent({
207+
name: 'App',
208+
components: {
209+
Navigation,
210+
},
211+
})
212+
</script>`
184213
}
185214
],
186215
invalid: [

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /