Skip to content

Commit

Permalink
Merge branch 'master' into 47-props-per-line
Browse files Browse the repository at this point in the history
* master:
  Add rule `vue/require-valid-default-prop`. (vuejs#119)
  3.10.0
  Update readme to 3.10.0
  Chore: remove package-lock.json (vuejs#128)
  Fix: parserService must exist always (fixes vuejs#125) (vuejs#127)
  Add rule `require-render-return`. (vuejs#114)
  3.9.0
  Update package-lock
  Update: options for `no-duplicate-attributes` (fixes vuejs#112)(vuejs#113)
  New: add rule `attribute-hyphenation`. (fixes vuejs#92)(vuejs#95)
  Add namespace check of svg & mathML instead of tag names (vuejs#120)
  ⚠️ Add support for deprecated state in update-rules ⚠️ (vuejs#121)
  Add rules: `no-dupe-keys` and `no-reserved-keys`. (vuejs#88)
  Chore: Improve tests for name-property-casing & improve documentation (vuejs#115)
  New: add `require-prop-types` rule (fixes vuejs#19)(vuejs#85)
  Update: upgrade vue-eslint-parser (fixes vuejs#36, fixes vuejs#56, fixes vuejs#96) (vuejs#116)
  • Loading branch information
Filipa Lacerda committed Aug 5, 2017
2 parents 982d9f2 + a3d64c7 commit 2f0492d
Show file tree
Hide file tree
Showing 66 changed files with 3,115 additions and 2,375 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
lib/recommended-rules.js
coverage
.nyc_output
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,38 @@ No rules are enabled by `plugin:vue/base` config. The `plugin:vue/recommended` c

The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.

Deprecated rules witch should be used with caution and only enabled when you know what you are doing have a warning :warning: icon.

<!--RULES_TABLE_START-->

### Stylistic Issues

| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | Define a style for the props casing in templates. |
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |


### Best Practices

| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
| :wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
| :wrench::warning: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. - (deprecated) |
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | Check if there are no asynchronous actions inside computed properties. |
| :white_check_mark: | [no-confusing-v-for-v-if](./docs/rules/no-confusing-v-for-v-if.md) | disallow confusing `v-for` and `v-if` on the same element. |
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate attributes. |
| | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | Don't introduce side effects in computed properties |
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
| | [order-in-components](./docs/rules/order-in-components.md) | Keep order of properties in components |
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
| | [require-prop-types](./docs/rules/require-prop-types.md) | Prop definitions should be detailed |
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |


### Stylistic Issues

| | Rule ID | Description |
|:---|:--------|:------------|
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |


### Variables

| | Rule ID | Description |
Expand All @@ -97,6 +101,7 @@ The `--fix` option on the command line automatically fixes problems reported by

| | Rule ID | Description |
|:---|:--------|:------------|
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | Prevents duplication of field names. |
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid `v-bind` directives. |
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid `v-cloak` directives. |
Expand All @@ -112,8 +117,10 @@ The `--fix` option on the command line automatically fixes problems reported by
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid `v-show` directives. |
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid `v-text` directives. |
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
| | [no-reservered-keys](./docs/rules/no-reservered-keys.md) | Prevent overwrite reserved keys. |
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
| | [require-render-return](./docs/rules/require-render-return.md) | Enforces render function to always return value. |
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | Enforces that a return statement is present in computed property. |

<!--RULES_TABLE_END-->
Expand Down
53 changes: 53 additions & 0 deletions docs/rules/attribute-hyphenation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Define if attributes on cusom components can be hyphened. (attribute-hyphenation)

## :wrench: Options

Default casing is set to `always`

```
'vue/attribute-hyphenation': [2, 'always'|'never']
```

### `"always"` - Use hyphenated name. (It errors on upper case letters.)

:+1: Examples of **correct** code`:

```html
<template>
<foo my-prop="prop">
<a onClick="return false"></a>
</foo>
</template>
```

:-1: Examples of **incorrect** code`:

```html
<template>
<foo myProp="prop">
<a onClick="return false"></a>
</foo>
</template>
```

### `"never"` - Don't use hyphenated name. (It errors on hyphens except `data-` and `aria-`.)

:+1: Examples of **correct** code`:

```html
<template>
<foo myProp="prop">
<a onClick="return false"></a>
</foo>
</template>
```

:-1: Examples of **incorrect** code`:

```html
<template>
<foo my-prop="prop">
<a onClick="return false"></a>
</foo>
</template>
```
78 changes: 78 additions & 0 deletions docs/rules/no-dupe-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Prevents duplication of field names (no-dupe-keys)

This rule prevents to use duplicated names.

## :book: Rule Details

This rule is aimed at preventing duplicated property names.

:-1: Examples of **incorrect** code for this rule:

```js
export default {
props: {
foo: String
},
computed: {
foo: {
get () {
}
}
},
data: {
foo: null
},
methods: {
foo () {
}
}
}
```

:+1: Examples of **correct** code for this rule:

```js
export default {
props: ['foo'],
computed: {
bar () {
}
},
data () {
return {
dat: null
}
},
methods: {
test () {
}
}
}
```

## :wrench: Options

This rule has an object option:

`"groups"`: [] (default) array of additional groups to search for duplicates.

### Example:

```
vue/no-dupe-keys: [2, {
groups: ['asyncComputed']
}]
```

:-1: Examples of **incorrect** code for this configuration

```js
export default {
computed: {
foo () {}
},
asyncComputed: {
foo () {}
}
}
```
13 changes: 12 additions & 1 deletion docs/rules/no-duplicate-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ This rule reports duplicate attributes.

## :wrench: Options

Nothing.
`allowCoexistClass` - Enables [`v-bind:class`] directive can coexist with the plain `class` attribute.
`allowCoexistStyle` - Enables [`v-bind:style`] directive can coexist with the plain `style` attribute.

```
'vue/name-property-casing': [2, {
allowCoexistClass: Boolean // default: true
allowCoexistStyle: Boolean, // default: true
}]
```

## TODO: `<div foo foo></div>`

`parse5` remove duplicate attributes on the tokenization phase.
Needs investigation to check.

[`v-bind:class`]: https://vuejs.org/v2/guide/class-and-style.html
[`v-bind:style`]: https://vuejs.org/v2/guide/class-and-style.html
64 changes: 62 additions & 2 deletions docs/rules/no-parsing-error.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Disallow parsing errors in `<template>` (no-parsing-error)

This rule reports syntax errors in directives/mustaches of `<template>`.
This rule reports syntax errors in `<template>`. For example:

- Syntax errors of scripts in directives.
- Syntax errors of scripts in mustaches.
- Syntax errors of HTML.
- Invalid end tags.
- Attributes in end tags.
- ...
- See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors

## :book: Rule Details

Expand All @@ -25,4 +33,56 @@ Then reports syntax errors if exist.

## :wrench: Options

Nothing.
```json
{
"vue/no-parsing-error": ["error", {
"abrupt-closing-of-empty-comment": false,
"absence-of-digits-in-numeric-character-reference": false,
"cdata-in-html-content": false,
"character-reference-outside-unicode-range": false,
"control-character-in-input-stream": false,
"control-character-reference": false,
"eof-before-tag-name": false,
"eof-in-cdata": false,
"eof-in-comment": false,
"eof-in-tag": false,
"incorrectly-closed-comment": false,
"incorrectly-opened-comment": false,
"invalid-first-character-of-tag-name": false,
"missing-attribute-value": false,
"missing-end-tag-name": false,
"missing-semicolon-after-character-reference": false,
"missing-whitespace-between-attributes": false,
"nested-comment": false,
"noncharacter-character-reference": false,
"noncharacter-in-input-stream": false,
"null-character-reference": false,
"surrogate-character-reference": false,
"surrogate-in-input-stream": false,
"unexpected-character-in-attribute-name": false,
"unexpected-character-in-unquoted-attribute-value": false,
"unexpected-equals-sign-before-attribute-name": false,
"unexpected-null-character": false,
"unexpected-question-mark-instead-of-tag-name": false,
"unexpected-solidus-in-tag": false,
"unknown-named-character-reference": false,
"end-tag-with-attributes": false,
"duplicate-attribute": false,
"end-tag-with-trailing-solidus": false,
"non-void-html-element-start-tag-with-trailing-solidus": false,
"x-invalid-end-tag": false,
"x-invalid-namespace": false
}]
}
```

You can enable HTML syntax errors by opt-in.

For example, if `"x-invalid-end-tag": true` is given then this rule will catch the end tags of elements which have not opened.
The error codes are defined in [WHATWG spec](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors), but this rule does not support all of those (E.g., it does not catch errors about DOCTYPE).
Also, The codes which have `x-` prefix are original in this rule because errors in tree construction phase have not codified yet.

- `x-invalid-end-tag` enables the errors about the end tags of elements which have not opened.
- `x-invalid-namespace` enables the errors about invalid `xmlns` attributes. See also [step 10. of "create an element for a token"](https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token).

> TODO(mysticatea): I will revisit errors in tree construction phase after those are codified.
54 changes: 54 additions & 0 deletions docs/rules/no-reservered-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Prevent overwrite reserved keys (no-reservered-keys)

This rule prevents to use reserved names from to avoid conflicts and unexpected behavior.

## Rule Details

:-1: Examples of **incorrect** code for this rule:

```js
export default {
props: {
$el: String
},
computed: {
$on: {
get () {
}
}
},
data: {
_foo: null
},
methods: {
$nextTick () {
}
}
}
```

## :wrench: Options

This rule has an object option:

`"reserved"`: [] (default) array of dissalowed names inside `groups`.

`"groups"`: [] (default) array of additional groups to search for duplicates.

### Example:

```
vue/no-dupe-keys: [2, {
reserved: ['foo']
}]
```

:-1: Examples of **incorrect** code for this configuration

```js
export default {
computed: {
foo () {}
}
}
```
Loading

0 comments on commit 2f0492d

Please sign in to comment.