Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️New: Add
vue/camelcase
rule (#772)
- Loading branch information
1 parent
94e4f0b
commit fa26414
Showing
5 changed files
with
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
pageClass: rule-details | ||
sidebarDepth: 0 | ||
title: vue/camelcase | ||
description: enforce camelcase naming convention | ||
--- | ||
# vue/camelcase | ||
> enforce camelcase naming convention | ||
This rule is the same rule as core [camelcase] rule but it applies to the expressions in `<template>`. | ||
|
||
## :books: Further reading | ||
|
||
- [camelcase] | ||
|
||
[camelcase]: https://eslint.org/docs/rules/camelcase | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/camelcase.js) | ||
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/camelcase.js) |
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,9 @@ | ||
/** | ||
* @author Yosuke Ota | ||
*/ | ||
'use strict' | ||
|
||
const { wrapCoreRule } = require('../utils') | ||
|
||
// eslint-disable-next-line | ||
module.exports = wrapCoreRule(require('eslint/lib/rules/camelcase')) |
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,57 @@ | ||
/** | ||
* @author Yosuke Ota | ||
*/ | ||
'use strict' | ||
|
||
const RuleTester = require('eslint').RuleTester | ||
const rule = require('../../../lib/rules/camelcase') | ||
|
||
const tester = new RuleTester({ | ||
parser: 'vue-eslint-parser', | ||
parserOptions: { ecmaVersion: 2015 } | ||
}) | ||
|
||
tester.run('camelcase', rule, { | ||
valid: [ | ||
`<template> | ||
<div :attr="{ myPref: 1 }" /> | ||
</template>`, | ||
{ | ||
code: ` | ||
<template> | ||
<div @click="($event) => { | ||
const { my_pref } = $event | ||
}" /> | ||
</template>`, | ||
options: [{ ignoreDestructuring: true }] | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
<template> | ||
<div :attr="{ my_pref: 1 }" /> | ||
</template>`, | ||
errors: [ | ||
{ | ||
message: 'Identifier \'my_pref\' is not in camel case.', | ||
line: 3 | ||
} | ||
] | ||
}, | ||
{ | ||
code: ` | ||
<template> | ||
<div @click="($event) => { | ||
const { my_pref } = $event | ||
}" /> | ||
</template>`, | ||
errors: [ | ||
{ | ||
message: 'Identifier \'my_pref\' is not in camel case.', | ||
line: 4 | ||
} | ||
] | ||
} | ||
] | ||
}) |