-
-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/force-types-on-object-props
- Loading branch information
Showing
65 changed files
with
5,608 additions
and
152 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 @@ | ||
module.exports = {} |
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
module.exports = { | ||
createRequire: () => () => null | ||
createRequire: () => (module) => { | ||
if (module === 'espree') { | ||
return require('espree') | ||
} | ||
if (module === 'eslint-scope') { | ||
return require('eslint-scope') | ||
} | ||
throw new Error(`Not implemented: ${module}`) | ||
} | ||
} |
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,93 @@ | ||
--- | ||
pageClass: rule-details | ||
sidebarDepth: 0 | ||
title: vue/define-emits-declaration | ||
description: enforce declaration style of `defineEmits` | ||
since: v9.5.0 | ||
--- | ||
# vue/define-emits-declaration | ||
|
||
> enforce declaration style of `defineEmits` | ||
## :book: Rule Details | ||
|
||
This rule enforces `defineEmits` typing style which you should use `type-based` or `runtime` declaration. | ||
|
||
This rule only works in setup script and `lang="ts"`. | ||
|
||
<eslint-code-block :rules="{'vue/define-emits-declaration': ['error']}"> | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
/* ✓ GOOD */ | ||
const emit = defineEmits<{ | ||
(e: 'change', id: number): void | ||
(e: 'update', value: string): void | ||
}>() | ||
/* ✗ BAD */ | ||
const emit = defineEmits({ | ||
change: (id) => typeof id == 'number', | ||
update: (value) => typeof value == 'string' | ||
}) | ||
/* ✗ BAD */ | ||
const emit = defineEmits(['change', 'update']) | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :wrench: Options | ||
|
||
```json | ||
"vue/define-emits-declaration": ["error", "type-based" | "runtime"] | ||
``` | ||
|
||
- `type-based` (default) enforces type-based declaration | ||
- `runtime` enforces runtime declaration | ||
|
||
### `runtime` | ||
|
||
<eslint-code-block :rules="{'vue/define-emits-declaration': ['error', 'runtime']}"> | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
/* ✗ BAD */ | ||
const emit = defineEmits<{ | ||
(e: 'change', id: number): void | ||
(e: 'update', value: string): void | ||
}>() | ||
/* ✓ GOOD */ | ||
const emit = defineEmits({ | ||
change: (id) => typeof id == 'number', | ||
update: (value) => typeof value == 'string' | ||
}) | ||
/* ✓ GOOD */ | ||
const emit = defineEmits(['change', 'update']) | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :couple: Related Rules | ||
|
||
- [vue/define-props-declaration](./define-props-declaration.md) | ||
- [vue/valid-define-emits](./valid-define-emits.md) | ||
|
||
## :books: Further Reading | ||
|
||
- [`defineEmits`](https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits) | ||
- [Typescript-only-features of `defineEmits`](https://vuejs.org/api/sfc-script-setup.html#typescript-only-features) | ||
- [Guide - Typing-component-emits](https://vuejs.org/guide/typescript/composition-api.html#typing-component-emits) | ||
|
||
## :rocket: Version | ||
|
||
This rule was introduced in eslint-plugin-vue v9.5.0 | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/define-emits-declaration.js) | ||
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/define-emits-declaration.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
pageClass: rule-details | ||
sidebarDepth: 0 | ||
title: vue/define-props-declaration | ||
description: enforce declaration style of `defineProps` | ||
since: v9.5.0 | ||
--- | ||
# vue/define-props-declaration | ||
|
||
> enforce declaration style of `defineProps` | ||
## :book: Rule Details | ||
|
||
This rule enforces `defineProps` typing style which you should use `type-based` or `runtime` declaration. | ||
|
||
This rule only works in setup script and `lang="ts"`. | ||
|
||
<eslint-code-block :rules="{'vue/define-props-declaration': ['error']}"> | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
/* ✓ GOOD */ | ||
const props = defineProps<{ | ||
kind: string, | ||
options: { title: string } | ||
}>() | ||
/* ✗ BAD */ | ||
const props = defineProps({ | ||
kind: { type: String }, | ||
options: { type: Object as PropType<{ title: string }> } | ||
}) | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :wrench: Options | ||
|
||
```json | ||
"vue/define-props-declaration": ["error", "type-based" | "runtime"] | ||
``` | ||
|
||
- `type-based` (default) enforces type-based declaration | ||
- `runtime` enforces runtime declaration | ||
|
||
### `"runtime"` | ||
|
||
<eslint-code-block :rules="{'vue/define-emits-declaration': ['error', 'runtime']}"> | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
/* ✓ GOOD */ | ||
const props = defineProps({ | ||
kind: { type: String }, | ||
options: { type: Object as PropType<{ title: string }> } | ||
}) | ||
/* ✗ BAD */ | ||
const props = defineProps<{ | ||
kind: string, | ||
options: { title: string } | ||
}>() | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :couple: Related Rules | ||
|
||
- [vue/define-emits-declaration](./define-emits-declaration.md) | ||
- [vue/valid-define-props](./valid-define-props.md) | ||
|
||
## :books: Further Reading | ||
|
||
- [`defineProps`](https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits) | ||
- [Typescript-only-features of `defineProps`](https://vuejs.org/api/sfc-script-setup.html#typescript-only-features) | ||
- [Guide - Typing-component-props](https://vuejs.org/guide/typescript/composition-api.html#typing-component-props) | ||
|
||
## :rocket: Version | ||
|
||
This rule was introduced in eslint-plugin-vue v9.5.0 | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/define-props-declaration.js) | ||
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/define-props-declaration.js) |
Oops, something went wrong.