-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add extra config for vue+typescript projects
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
5 changed files
with
71 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
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,19 @@ | ||
import { ESLint } from "eslint" | ||
import type { Linter } from "eslint" | ||
import * as path from 'path' | ||
import * as eslintConfig from '../typescript.js' | ||
|
||
|
||
const eslint = new ESLint({ | ||
baseConfig: eslintConfig as unknown as Linter.Config<Linter.RulesRecord> | ||
}) | ||
|
||
const lintFile = async (file) => { | ||
const real = path.resolve(path.join(__dirname, file)) | ||
return await eslint.lintFiles(real) | ||
} | ||
|
||
test('works with Typescript + Vue', async () => { | ||
const results = await lintFile('fixtures/typescript-test.vue') | ||
expect(results).toHaveIssueCount(0) | ||
}) |
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,12 @@ | ||
<template> | ||
<code>String: "{{ props.someString }}" | ||
Int: {{ props.someInt }} | ||
</code> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const props = defineProps<{ | ||
someString: string, | ||
someInt: number, | ||
}>() | ||
</script> |
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,25 @@ | ||
const base = require('./parts/base.js') | ||
const typescriptOverrides = require('./parts/typescript.js') | ||
const vueOverrides = require('./parts/vue.js') | ||
|
||
/** | ||
* Config for projects written in Typescript + vue including vue files written in Typescript (`<script lang='ts'>`) | ||
*/ | ||
module.exports = { | ||
...base, | ||
overrides: [ | ||
// Add Typescript rules also for vue files | ||
{ | ||
...typescriptOverrides, | ||
files: ['**/*.ts', '**/*.tsx', '**/*.vue'], | ||
}, | ||
// Use different parser for vue files script section | ||
{ | ||
...vueOverrides, | ||
parserOptions: { | ||
parser: '@typescript-eslint/parser', | ||
sourceType: 'module', | ||
}, | ||
}, | ||
] | ||
} |