Skip to content

Commit

Permalink
fix: add absolute path for reading file contents, fix rootDir issue (
Browse files Browse the repository at this point in the history
…#108)

* Add absolute option for finding files

* Only use absolutePath to read file contents

---------

Co-authored-by: Marco Havermans <[email protected]>
  • Loading branch information
markieo1 and Marco Havermans authored Dec 25, 2024
1 parent ffbd03b commit 0d2e74a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vueParser from 'vue-eslint-parser'
import pluginVue from 'eslint-plugin-vue'

import fg from 'fast-glob'
import path from 'node:path'

type ExtendableConfigName = keyof typeof tseslint.configs
type ScriptLang = 'ts' | 'tsx' | 'js' | 'jsx'
Expand Down Expand Up @@ -33,7 +34,8 @@ export default function createConfig({
})
.reduce(
(acc, file) => {
const contents = fs.readFileSync(file, 'utf8')
const absolutePath = path.resolve(rootDir, file)
const contents = fs.readFileSync(absolutePath, 'utf8')
// contents matches the <script lang="ts"> (there can be anything but `>` between `script` and `lang`)
if (/<script[^>]*\blang\s*=\s*"ts"[^>]*>/i.test(contents)) {
acc.vueFilesWithScriptTs.push(file)
Expand Down

0 comments on commit 0d2e74a

Please sign in to comment.