@kyh/eslint-config 1.0.1 → 1.0.3

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 +12 -0
  2. package/base.js +21 -18
  3. package/package.json +5 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @kyh/eslint-config
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - update
8
+
9
+ ## 1.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - update gitignore search
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
package/base.js CHANGED
@@ -2,37 +2,40 @@
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
+ /**
12
+ * Recursively search for a `.gitignore` file starting from the given directory.
13
+ * @param {string} startDir The directory to start searching from.
14
+ * @returns {Promise<string>} The path to the `.gitignore` file or `null` if not found.
15
+ */
16
+ async function findGitignorePath(startDir) {
17
+ const gitignorePath = path.join(startDir, ".gitignore");
14
18
 
15
- const fileExists = async (filePath) => {
16
19
  try {
17
- await fs.promises.access(filePath);
18
- return true;
20
+ await fs.promises.access(gitignorePath, fs.constants.F_OK);
21
+ return gitignorePath;
19
22
  } catch {
20
- return false;
21
- }
22
- };
23
+ // .gitignore not found in current directory
24
+ const parentDir = path.dirname(startDir);
25
+
26
+ // Check if we've reached the root directory
27
+ if (parentDir === startDir) {
28
+ return ""; // .gitignore not found
29
+ }
23
30
 
24
- const gitignorePath = path.join(__dirname, "../../.gitignore");
25
- const gitignorePath2 = path.join(__dirname, "../../../.gitignore");
31
+ // Recursively search in the parent directory
32
+ return findGitignorePath(parentDir);
33
+ }
34
+ }
26
35
 
27
36
  export default tseslint.config(
28
37
  // 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
- ),
38
+ includeIgnoreFile(await findGitignorePath(import.meta.dirname)),
36
39
  { ignores: ["**/*.config.*"] },
37
40
  {
38
41
  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.3",
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/tsconfig": "1.0.3",
28
+ "@kyh/prettier-config": "1.0.3"
30
29
  },
31
30
  "prettier": "@kyh/prettier-config",
32
31
  "scripts": {