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 edf43ff

Browse files
ota-meshikazupon
authored andcommitted
Drop autofix of prop-name-casing. (#940)
* Drop autofix of prop-name-casing. * Fixed eslint error
1 parent 3836af4 commit edf43ff

File tree

4 files changed

+5
-84
lines changed

4 files changed

+5
-84
lines changed

‎docs/rules/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
9898
| [vue/no-multi-spaces](./no-multi-spaces.md) | disallow multiple spaces | :wrench: |
9999
| [vue/no-spaces-around-equal-signs-in-attribute](./no-spaces-around-equal-signs-in-attribute.md) | disallow spaces around equal signs in attribute | :wrench: |
100100
| [vue/no-template-shadow](./no-template-shadow.md) | disallow variable declarations from shadowing variables declared in the outer scope | |
101-
| [vue/prop-name-casing](./prop-name-casing.md) | enforce specific casing for the Prop name in Vue components | :wrench: |
101+
| [vue/prop-name-casing](./prop-name-casing.md) | enforce specific casing for the Prop name in Vue components | |
102102
| [vue/require-default-prop](./require-default-prop.md) | require default value for props | |
103103
| [vue/require-prop-types](./require-prop-types.md) | require type definitions in props | |
104104
| [vue/singleline-html-element-content-newline](./singleline-html-element-content-newline.md) | require a line break before and after the contents of a singleline element | :wrench: |

‎docs/rules/prop-name-casing.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ description: enforce specific casing for the Prop name in Vue components
88
> enforce specific casing for the Prop name in Vue components
99
1010
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
11-
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1211

1312
## :book: Rule Details
1413

1514
This rule enforce proper casing of props in vue components(camelCase).
1615

17-
<eslint-code-block fix:rules="{'vue/prop-name-casing': ['error']}">
16+
<eslint-code-block :rules="{'vue/prop-name-casing': ['error']}">
1817

1918
```vue
2019
<script>
@@ -46,7 +45,7 @@ export default {
4645

4746
### `"snake_case"`
4847

49-
<eslint-code-block fix:rules="{'vue/prop-name-casing': ['error', 'snake_case']}">
48+
<eslint-code-block :rules="{'vue/prop-name-casing': ['error', 'snake_case']}">
5049

5150
```vue
5251
<script>

‎lib/rules/prop-name-casing.js‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ const utils = require('../utils')
88
const casing = require('../utils/casing')
99
const allowedCaseOptions = ['camelCase', 'snake_case']
1010

11-
function canFixPropertyName (node, key, originalName) {
12-
// Can not fix of computed property names & shorthand
13-
if (node.computed || node.shorthand) {
14-
return false
15-
}
16-
17-
// Can not fix of unknown types
18-
if (key.type !== 'Literal' && key.type !== 'Identifier') {
19-
return false
20-
}
21-
// Can fix of ASCII printable characters
22-
return originalName.match(/[-~]+/)
23-
}
24-
2511
// ------------------------------------------------------------------------------
2612
// Rule Definition
2713
// ------------------------------------------------------------------------------
@@ -53,12 +39,7 @@ function create (context) {
5339
data: {
5440
name: propName,
5541
caseType: caseType
56-
},
57-
fix: canFixPropertyName(item.node, item.key, propName) ? fixer => {
58-
return item.key.type === 'Literal'
59-
? fixer.replaceText(item.key, item.key.raw.replace(item.key.value, convertedName))
60-
: fixer.replaceText(item.key, convertedName)
61-
} : undefined
42+
}
6243
})
6344
}
6445
}
@@ -77,7 +58,7 @@ module.exports = {
7758
category: 'strongly-recommended',
7859
url: 'https://eslint.vuejs.org/rules/prop-name-casing.html'
7960
},
80-
fixable: 'code', // null or "code" or "whitespace"
61+
fixable: null, // null or "code" or "whitespace"
8162
schema: [
8263
{
8364
enum: allowedCaseOptions

‎tests/lib/rules/prop-name-casing.js‎

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,6 @@ ruleTester.run('prop-name-casing', rule, {
300300
}
301301
}
302302
`,
303-
output: `
304-
export default {
305-
props: {
306-
greetingText: String
307-
}
308-
}
309-
`,
310303
parserOptions,
311304
errors: [{
312305
message: 'Prop "greeting_text" is not in camelCase.',
@@ -324,13 +317,6 @@ ruleTester.run('prop-name-casing', rule, {
324317
}
325318
`,
326319
options: ['camelCase'],
327-
output: `
328-
export default {
329-
props: {
330-
greetingText: String
331-
}
332-
}
333-
`,
334320
parserOptions,
335321
errors: [{
336322
message: 'Prop "greeting_text" is not in camelCase.',
@@ -346,11 +332,6 @@ ruleTester.run('prop-name-casing', rule, {
346332
}
347333
`,
348334
options: ['camelCase'],
349-
output: `
350-
export default {
351-
props: ['greetingText']
352-
}
353-
`,
354335
parserOptions,
355336
errors: [{
356337
message: 'Prop "greeting_text" is not in camelCase.',
@@ -368,13 +349,6 @@ ruleTester.run('prop-name-casing', rule, {
368349
}
369350
`,
370351
options: ['snake_case'],
371-
output: `
372-
export default {
373-
props: {
374-
greeting_text: String
375-
}
376-
}
377-
`,
378352
parserOptions,
379353
errors: [{
380354
message: 'Prop "greetingText" is not in snake_case.',
@@ -392,13 +366,6 @@ ruleTester.run('prop-name-casing', rule, {
392366
}
393367
`,
394368
options: ['camelCase'],
395-
output: `
396-
export default {
397-
props: {
398-
'greetingText': String
399-
}
400-
}
401-
`,
402369
parserOptions,
403370
errors: [{
404371
message: 'Prop "greeting-text" is not in camelCase.',
@@ -416,13 +383,6 @@ ruleTester.run('prop-name-casing', rule, {
416383
}
417384
`,
418385
options: ['snake_case'],
419-
output: `
420-
export default {
421-
props: {
422-
'greeting_text': String
423-
}
424-
}
425-
`,
426386
parserOptions,
427387
errors: [{
428388
message: 'Prop "greeting-text" is not in snake_case.',
@@ -439,13 +399,6 @@ ruleTester.run('prop-name-casing', rule, {
439399
}
440400
}
441401
`,
442-
output: `
443-
export default {
444-
props: {
445-
'greetingText': String
446-
}
447-
}
448-
`,
449402
parserOptions,
450403
errors: [{
451404
message: 'Prop "greeting_text" is not in camelCase.',
@@ -463,7 +416,6 @@ ruleTester.run('prop-name-casing', rule, {
463416
}
464417
}
465418
`,
466-
output: null,
467419
parserOptions,
468420
errors: [{
469421
message: 'Prop "greeting-text" is not in camelCase.',
@@ -481,7 +433,6 @@ ruleTester.run('prop-name-casing', rule, {
481433
}
482434
}
483435
`,
484-
output: null,
485436
parserOptions,
486437
errors: [{
487438
message: 'Prop "greeting_text" is not in camelCase.',
@@ -499,7 +450,6 @@ ruleTester.run('prop-name-casing', rule, {
499450
}
500451
}
501452
`,
502-
output: null,
503453
parserOptions,
504454
errors: [{
505455
message: 'Prop "\u{1F37B}" is not in camelCase.',
@@ -517,7 +467,6 @@ ruleTester.run('prop-name-casing', rule, {
517467
}
518468
}
519469
`,
520-
output: null,
521470
parserOptions,
522471
errors: [{
523472
message: 'Prop "漢字" is not in camelCase.',
@@ -534,13 +483,6 @@ ruleTester.run('prop-name-casing', rule, {
534483
}
535484
}
536485
`,
537-
output: `
538-
export default {
539-
props: {
540-
'abc123Def': String
541-
}
542-
}
543-
`,
544486
parserOptions,
545487
errors: [{
546488
message: 'Prop "abc-123-def" is not in camelCase.',
@@ -558,7 +500,6 @@ ruleTester.run('prop-name-casing', rule, {
558500
}
559501
}
560502
`,
561-
output: null,
562503
parserOptions,
563504
errors: [{
564505
message: 'Prop "greeting-text" is not in camelCase.',

0 commit comments

Comments
(0)

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