Skip to content

Commit

Permalink
test: update examples to pass linting without errors
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Sep 23, 2024
1 parent 31d1ca4 commit 96fadac
Show file tree
Hide file tree
Showing 34 changed files with 313 additions and 222 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @vue/eslint-config-typescript

> eslint-config-typescript for Vue
ESLint configuration for Vue 3 + TypeScript projects.

See [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/rules/) for available rules.

Expand All @@ -13,7 +13,7 @@ other parts of `create-vue` setups, such as `eslint-plugin-vue` being
extended in the same resulting config.

> [!NOTE]
> The current version doesn't support the legacy `.eslintrc*` configuraion format. For that you need to use version 9 or earlier. See the [corresponding README](https://www.npmjs.com/package/@vue/eslint-config-typescript/v/legacy-eslintrc) for more usage instructions.
> The current version doesn't support the legacy `.eslintrc*` configuraion format. For that you need to use version 13 or earlier. See the [corresponding README](https://www.npmjs.com/package/@vue/eslint-config-typescript/v/legacy-eslintrc) for more usage instructions.
## Installation

Expand Down
6 changes: 6 additions & 0 deletions examples/allow-js/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import pluginVue from "eslint-plugin-vue";
import vueTsEslintConfig from "@vue/eslint-config-typescript";

export default [
{
name: 'app/files-to-lint',
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs["flat/essential"],
...vueTsEslintConfig({
supportedScriptLangs: {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/setup-files',
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},
Expand Down
23 changes: 23 additions & 0 deletions examples/with-cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pluginVue from 'eslint-plugin-vue'
import pluginCypress from 'eslint-plugin-cypress/flat'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig(),

{
files: [
'**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}',
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
'cypress/support/**/*.{js,ts,jsx,tsx}'
],
...pluginCypress.configs.recommended,
}
]
14 changes: 0 additions & 14 deletions examples/with-jsx-in-vue/.eslintrc.cjs

This file was deleted.

20 changes: 20 additions & 0 deletions examples/with-jsx-in-vue/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig({
supportedScriptLangs: {
ts: true,
tsx: true,
js: true,
jsx: true
}
}),
]
39 changes: 24 additions & 15 deletions examples/with-jsx-in-vue/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
<script setup lang="ts">
defineProps<{
msg: string
}>()
</script>
<script lang="jsx">
import { defineComponent } from 'vue'
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
You’ve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
</h3>
</div>
</template>
export default defineComponent({
props: { msg: String },
setup(props) {
return () => (
<div class="greetings">
<h1 class="green">{props.msg}</h1>
<h3>
You’ve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">
Vite
</a>{' '}
+
<a href="https://vuejs.org/" target="_blank" rel="noopener">
Vue 3
</a>
.
</h3>
</div>
)
},
})
</script>

<style scoped>
h1 {
Expand Down
4 changes: 3 additions & 1 deletion examples/with-jsx-in-vue/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},

"allowJs": true
}
}
14 changes: 0 additions & 14 deletions examples/with-jsx/.eslintrc.cjs

This file was deleted.

13 changes: 13 additions & 0 deletions examples/with-jsx/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig(),
]
3 changes: 3 additions & 0 deletions examples/with-jsx/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import HelloWorld from './components/HelloWorld.vue'
import TheWelcome from './components/TheWelcome.vue'
import FooComp from './FooComp'
</script>

<template>
Expand All @@ -10,6 +11,8 @@ import TheWelcome from './components/TheWelcome.vue'
<div class="wrapper">
<HelloWorld msg="You did it!" />
</div>

<FooComp />
</header>

<main>
Expand Down
7 changes: 7 additions & 0 deletions examples/with-jsx/src/FooComp.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineComponent } from "vue"

export default defineComponent({
setup() {
return () => <div>Foo</div>
},
})
3 changes: 2 additions & 1 deletion examples/with-jsx/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"allowJs": true
}
}
14 changes: 0 additions & 14 deletions examples/with-nightwatch/.eslintrc.cjs

This file was deleted.

22 changes: 22 additions & 0 deletions examples/with-nightwatch/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig(),

{
files: ['tests/e2e/**/*.{js,ts}', '**/__tests__/**/*.{js,ts}'],
rules: {
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
// You can use https://github.com/ihordiachenko/eslint-plugin-chai-friendly for more accurate linting
},
},
]
1 change: 1 addition & 0 deletions examples/with-nightwatch/nightwatch/nightwatch.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unused-vars */
import { NightwatchCustomAssertions, NightwatchCustomCommands } from 'nightwatch'

declare module 'nightwatch' {
Expand Down
1 change: 1 addition & 0 deletions examples/with-nightwatch/tests/e2e/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ describe('My First Test', function () {

after((browser) => browser.end())
})

24 changes: 0 additions & 24 deletions examples/with-playwright/.eslintrc.cjs

This file was deleted.

19 changes: 19 additions & 0 deletions examples/with-playwright/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pluginVue from 'eslint-plugin-vue'
import pluginPlaywright from 'eslint-plugin-playwright'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig(),

{
...pluginPlaywright.configs['flat/recommended'],
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
},
]
15 changes: 0 additions & 15 deletions examples/with-prettier/.eslintrc.cjs

This file was deleted.

16 changes: 16 additions & 0 deletions examples/with-prettier/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig(),

skipFormatting
]
2 changes: 1 addition & 1 deletion examples/with-prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@tsconfig/node20": "^20.1.4",
"@types/node": "^20.16.5",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-prettier": "^10.0.0-rc.2",
"@vue/eslint-config-typescript": "workspace:*",
"@vue/tsconfig": "^0.5.1",
"eslint": "^9.10.0",
Expand Down
14 changes: 0 additions & 14 deletions examples/with-tsx-in-vue/.eslintrc.cjs

This file was deleted.

18 changes: 18 additions & 0 deletions examples/with-tsx-in-vue/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'

export default [
{
name: 'app/files-to-lint',
files: ['**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
ignores: ['**/dist/**'],
},

...pluginVue.configs['flat/essential'],
...vueTsEslintConfig({
supportedScriptLangs: {
ts: true,
tsx: true
}
}),
]
Loading

0 comments on commit 96fadac

Please sign in to comment.