@kyh/eslint-config 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/base.js +16 -18
  3. package/package.json +5 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @kyh/eslint-config
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - update gitignore search
8
+
3
9
  ## 1.0.1
4
10
 
5
11
  ### Patch Changes
package/base.js CHANGED
@@ -2,37 +2,35 @@
2
2
 
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
- import * as url from "node:url";
6
5
  import { includeIgnoreFile } from "@eslint/compat";
7
6
  import eslint from "@eslint/js";
8
7
  import importPlugin from "eslint-plugin-import";
9
8
  import turboPlugin from "eslint-plugin-turbo";
10
9
  import tseslint from "typescript-eslint";
11
10
 
12
- const __filename = url.fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
11
+ async function findGitignorePath(startDir) {
12
+ const gitignorePath = path.join(startDir, ".gitignore");
14
13
 
15
- const fileExists = async (filePath) => {
16
14
  try {
17
- await fs.promises.access(filePath);
18
- return true;
15
+ await fs.promises.access(gitignorePath, fs.constants.F_OK);
16
+ return gitignorePath;
19
17
  } catch {
20
- return false;
21
- }
22
- };
18
+ // .gitignore not found in current directory
19
+ const parentDir = path.dirname(startDir);
20
+
21
+ // Check if we've reached the root directory
22
+ if (parentDir === startDir) {
23
+ return null; // .gitignore not found
24
+ }
23
25
 
24
- const gitignorePath = path.join(__dirname, "../../.gitignore");
25
- const gitignorePath2 = path.join(__dirname, "../../../.gitignore");
26
+ // Recursively search in the parent directory
27
+ return findGitignorePath(parentDir);
28
+ }
29
+ }
26
30
 
27
31
  export default tseslint.config(
28
32
  // Ignore files not tracked by VCS and any config files
29
- includeIgnoreFile(
30
- (await fileExists(gitignorePath))
31
- ? gitignorePath
32
- : (await fileExists(gitignorePath2))
33
- ? gitignorePath2
34
- : "",
35
- ),
33
+ includeIgnoreFile(await findGitignorePath(import.meta.dirname)),
36
34
  { ignores: ["**/*.config.*"] },
37
35
  {
38
36
  files: ["**/*.js", "**/*.ts", "**/*.tsx"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyh/eslint-config",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,18 +15,17 @@
15
15
  "@next/eslint-plugin-next": "^14.2.5",
16
16
  "eslint-plugin-import": "^2.29.1",
17
17
  "eslint-plugin-jsx-a11y": "^6.9.0",
18
- "eslint-plugin-prefer-arrow-functions": "^3.3.2",
19
18
  "eslint-plugin-react": "^7.35.0",
20
19
  "eslint-plugin-react-hooks": "rc",
21
- "eslint-plugin-turbo": "^2.0.12",
22
- "typescript-eslint": "^8.0.1"
20
+ "eslint-plugin-turbo": "^2.0.13",
21
+ "typescript-eslint": "^8.1.0"
23
22
  },
24
23
  "devDependencies": {
25
24
  "eslint": "^9.9.0",
26
25
  "prettier": "^3.3.3",
27
26
  "typescript": "^5.5.4",
28
- "@kyh/prettier-config": "1.0.1",
29
- "@kyh/tsconfig": "1.0.1"
27
+ "@kyh/prettier-config": "1.0.2",
28
+ "@kyh/tsconfig": "1.0.2"
30
29
  },
31
30
  "prettier": "@kyh/prettier-config",
32
31
  "scripts": {