-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
|
||
const utils = require('../../utils') | ||
|
||
module.exports = { | ||
supported: '>=3.0.0', | ||
/** @param {RuleContext} context @returns {TemplateListener} */ | ||
createScriptVisitor(context) { | ||
const scriptSetup = utils.getScriptSetupElement(context) | ||
if (!scriptSetup) { | ||
return {} | ||
} | ||
const reportNode = | ||
utils.getAttribute(scriptSetup, 'setup') || scriptSetup.startTag | ||
return { | ||
Program() { | ||
context.report({ | ||
node: reportNode, | ||
messageId: 'forbiddenScriptSetup' | ||
}) | ||
} | ||
} | ||
} | ||
} |
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,48 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
|
||
const RuleTester = require('eslint').RuleTester | ||
const rule = require('../../../../lib/rules/no-unsupported-features') | ||
const utils = require('./utils') | ||
|
||
const buildOptions = utils.optionsBuilder('script-setup', '^3.0.0') | ||
const tester = new RuleTester({ | ||
parser: require.resolve('vue-eslint-parser'), | ||
parserOptions: { | ||
ecmaVersion: 2019 | ||
} | ||
}) | ||
|
||
tester.run('no-unsupported-features/script-setup', rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
<script setup> | ||
</script>`, | ||
options: buildOptions() | ||
}, | ||
{ | ||
code: ` | ||
<script> | ||
</script>`, | ||
options: buildOptions({ version: '^2.6.0' }) | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
<script setup> | ||
</script>`, | ||
options: buildOptions({ version: '^2.6.0' }), | ||
errors: [ | ||
{ | ||
message: '`<script setup>` are not supported until Vue.js "3.0.0".', | ||
line: 2 | ||
} | ||
] | ||
} | ||
] | ||
}) |