Skip to content

Commit 508f3c4

Browse files
feat(eslint): Add support to ignore .gitignore entries
1 parent f2154de commit 508f3c4

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

.changeset/empty-banks-stay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tcd-devkit/eslint-config': patch
3+
---
4+
5+
Add support to ignore .gitignore entries

packages/eslint/eslint-config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"test:watch": "vitest --watch"
6666
},
6767
"dependencies": {
68+
"@eslint/compat": "1.2.9",
6869
"@eslint/js": "9.27.0"
6970
},
7071
"devDependencies": {

packages/eslint/eslint-config/src/base.linter.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
import fs from 'node:fs';
2+
import { fileURLToPath } from 'node:url';
3+
4+
import { includeIgnoreFile } from '@eslint/compat';
15
import eslintPlugin from '@eslint/js';
26
import type { Linter } from 'eslint';
37
import { defineConfig } from 'eslint/config';
48

59
import { baseRules } from '#base.rules';
610

11+
const cwdURL = `file://${process.cwd()}/`;
12+
const gitignorePath = fileURLToPath(new URL(`.gitignore`, cwdURL));
13+
14+
const fileExists = fs.existsSync(gitignorePath);
15+
16+
let gitignoreConfig = {};
17+
18+
if (fileExists) {
19+
gitignoreConfig = includeIgnoreFile(gitignorePath);
20+
}
21+
722
export const baseConfig: Linter.Config[] = defineConfig([
23+
gitignoreConfig,
824
{
925
name: '@tcd-devkit/eslint-config',
1026
extends: [eslintPlugin.configs.recommended],

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)