-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make to use
project: undefined
when parsing template script-let.
- Loading branch information
Showing
4 changed files
with
136 additions
and
8 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
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,129 @@ | ||
"use strict" | ||
|
||
const assert = require("assert") | ||
const { parseForESLint } = require("../src") | ||
const espree = require("espree") | ||
|
||
describe("use `project: undefined` when parsing template script-let", () => { | ||
it("should be the project option is defined only once in Simple SFC.", () => { | ||
let projectCount = 0 | ||
parseForESLint( | ||
`<template> | ||
<div v-bind:class="{}"> | ||
<template v-for="item in items"> | ||
{{ 'str' }} | ||
<button v-on:click="handler()"></button> | ||
</template> | ||
<MyComponent> | ||
<template v-slot="{a}"> | ||
<div v-if="a">A</div> | ||
</template> | ||
</MyComponent> | ||
</div> | ||
</template> | ||
<script> | ||
export default {} | ||
</script> | ||
`, | ||
{ | ||
project: true, | ||
sourceType: "module", | ||
ecmaVersion: 2018, | ||
parser: { | ||
parseForESLint(code, options) { | ||
if (options.project) { | ||
projectCount++ | ||
} | ||
|
||
return { | ||
ast: espree.parse(code, options), | ||
} | ||
}, | ||
}, | ||
}, | ||
) | ||
assert.strictEqual(projectCount, 1) | ||
}) | ||
it("should be the project option is defined only once in <script setup>.", () => { | ||
let projectCount = 0 | ||
parseForESLint( | ||
`<script setup> | ||
let items = ["foo"] | ||
</script> | ||
<template> | ||
<div v-bind:class="{}"> | ||
<template v-for="item in items"> | ||
{{ 'str' }} | ||
<button v-on:click="handler()"></button> | ||
</template> | ||
<MyComponent> | ||
<template v-slot="{a}"> | ||
<div v-if="a">A</div> | ||
</template> | ||
</MyComponent> | ||
</div> | ||
</template> | ||
`, | ||
{ | ||
project: true, | ||
sourceType: "module", | ||
ecmaVersion: 2018, | ||
parser: { | ||
parseForESLint(code, options) { | ||
if (options.project) { | ||
projectCount++ | ||
} | ||
|
||
return { | ||
ast: espree.parse(code, options), | ||
} | ||
}, | ||
}, | ||
}, | ||
) | ||
assert.strictEqual(projectCount, 1) | ||
}) | ||
|
||
it("should be the project option is defined only once in <script setup> with <script>.", () => { | ||
let projectCount = 0 | ||
parseForESLint( | ||
`<script> | ||
import { ref } from 'vue' | ||
</script> | ||
<script setup> | ||
let items = ref(["foo"]) | ||
</script> | ||
<template> | ||
<div v-bind:class="{}"> | ||
<template v-for="item in items"> | ||
{{ 'str' }} | ||
<button v-on:click="handler()"></button> | ||
</template> | ||
<MyComponent> | ||
<template v-slot="{a}"> | ||
<div v-if="a">A</div> | ||
</template> | ||
</MyComponent> | ||
</div> | ||
</template> | ||
`, | ||
{ | ||
project: true, | ||
sourceType: "module", | ||
ecmaVersion: 2018, | ||
parser: { | ||
parseForESLint(code, options) { | ||
if (options.project) { | ||
projectCount++ | ||
} | ||
|
||
return { | ||
ast: espree.parse(code, options), | ||
} | ||
}, | ||
}, | ||
}, | ||
) | ||
assert.strictEqual(projectCount, 1) | ||
}) | ||
}) |