Skip to content

Commit 0d2e74a

Browse files
markieo1Marco Havermans
and
Marco Havermans
authored
fix: add absolute path for reading file contents, fix rootDir issue (#108)
* Add absolute option for finding files * Only use absolutePath to read file contents --------- Co-authored-by: Marco Havermans <[email protected]>
1 parent ffbd03b commit 0d2e74a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import vueParser from 'vue-eslint-parser'
66
import pluginVue from 'eslint-plugin-vue'
77

88
import fg from 'fast-glob'
9+
import path from 'node:path'
910

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

0 commit comments

Comments
 (0)