Skip to content

Commit 64db803

Browse files
committed
feat(eslint-config): auto ignore files in gitignore
1 parent 767ed2a commit 64db803

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eslint-config/index.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { includeIgnoreFile } from '@eslint/compat'
2+
import childProcess from 'node:child_process'
13
import fs from 'node:fs'
4+
import path from 'node:path'
25

36
import { htmlConfig } from './src/html.mjs'
47
import { javascriptConfig } from './src/javascript.mjs'
@@ -8,6 +11,12 @@ import { reactConfig } from './src/react.mjs'
811
import { typescriptConfig } from './src/typescript.mjs'
912
import { ymlConfig } from './src/yml.mjs'
1013

14+
const processPath = childProcess
15+
.execSync('git rev-parse --show-toplevel')
16+
.toString()
17+
.trim()
18+
19+
const gitignorePath = path.resolve(processPath, '.gitignore')
1120
const jsonData = fs.readFileSync('./package.json', 'utf8')
1221
const { name, version } = JSON.parse(jsonData)
1322

@@ -18,6 +27,7 @@ export default {
1827
},
1928
configs: {
2029
base: [
30+
includeIgnoreFile(gitignorePath),
2131
...htmlConfig,
2232
...javascriptConfig,
2333
...jsonConfig,
@@ -26,6 +36,7 @@ export default {
2636
...ymlConfig,
2737
],
2838
react: [
39+
includeIgnoreFile(gitignorePath),
2940
...htmlConfig,
3041
...javascriptConfig,
3142
...jsonConfig,

packages/eslint-config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
},
3232
"dependencies": {
3333
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
34+
"@eslint/compat": "^1.4.0",
3435
"@eslint/js": "^9.35.0",
3536
"@eslint/json": "^0.13.2",
3637
"@html-eslint/eslint-plugin": "^0.46.2",

0 commit comments

Comments
 (0)