Skip to content

Commit

Permalink
fix: resolve resolvers and parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed May 22, 2024
1 parent b3745ee commit a6aecfe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions configs/import.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createRequire } from 'node:module'
import { fixupPluginRules } from '@eslint/compat'
import importPlugin from 'eslint-plugin-import'
import { defineConfig } from '../config.js'

export default defineConfig(options => {
const { resolve } = createRequire(import.meta.url)
return [
{
plugins: {
Expand All @@ -12,7 +14,7 @@ export default defineConfig(options => {
'import/internal-regex': '^@/',
'import/resolver': {
// Must go before any other resolvers for typescript files
typescript: {
[resolve('eslint-import-resolver-typescript')]: {
extensions: [
'.ts',
'.tsx',
Expand All @@ -23,7 +25,7 @@ export default defineConfig(options => {
'.vue',
],
},
alias: {
[resolve('eslint-import-resolver-alias')]: {
map: [
['@', './src'],
],
Expand All @@ -40,8 +42,8 @@ export default defineConfig(options => {
},
},
'import/parsers': {
'@typescript-eslint/parser': ['.cts', '.mts', '.ts', '.tsx'],
'vue-eslint-parser': ['.vue'],
[resolve('@typescript-eslint/parser')]: ['.cts', '.mts', '.ts', '.tsx'],
[resolve('vue-eslint-parser')]: ['.vue'],
},
},
rules: {
Expand Down
18 changes: 10 additions & 8 deletions configs/vue.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createRequire } from 'node:module'
import vuePlugin from 'eslint-plugin-vue'
import vueScopedCssPlugin from 'eslint-plugin-vue-scoped-css'
import { defineConfig } from '../config.js'
Expand Down Expand Up @@ -88,6 +89,7 @@ const orders = {

export default defineConfig(options => {
if (!options.vue) return []
const { resolve } = createRequire(import.meta.url)
const mixed = options.typescript && options.typescript.mixed || options.jsx
return [
...(options.vue.legacy ? vuePlugin.configs['flat/vue2-essential'] : vuePlugin.configs['flat/essential']),
Expand All @@ -104,13 +106,13 @@ export default defineConfig(options => {
languageOptions: {
parserOptions: {
parser: {
cts: '@typescript-eslint/parser',
mts: '@typescript-eslint/parser',
ts: '@typescript-eslint/parser',
tsx: '@typescript-eslint/parser',
cts: resolve('@typescript-eslint/parser'),
mts: resolve('@typescript-eslint/parser'),
ts: resolve('@typescript-eslint/parser'),
tsx: resolve('@typescript-eslint/parser'),
...(options.babel ? {
js: '@babel/eslint-parser',
jsx: '@babel/eslint-parser',
js: resolve('@babel/eslint-parser'),
jsx: resolve('@babel/eslint-parser'),
} : {}),
},
},
Expand All @@ -131,7 +133,7 @@ export default defineConfig(options => {
files: [GLOB_VUE],
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser',
parser: resolve('@typescript-eslint/parser'),
},
},
},
Expand All @@ -140,7 +142,7 @@ export default defineConfig(options => {
files: [GLOB_VUE],
languageOptions: {
parserOptions: {
parser: '@babel/eslint-parser',
parser: resolve('@babel/eslint-parser'),
},
},
},
Expand Down

0 comments on commit a6aecfe

Please sign in to comment.