@kyh/eslint-config 0.1.9 → 1.0.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # @kyh/eslint-config
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - update gitignore location
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - update to eslint 9
14
+
15
+ ## 0.1.9
16
+
17
+ ### Patch Changes
18
+
19
+ - update packages
20
+
21
+ ## 0.1.8
22
+
23
+ ### Patch Changes
24
+
25
+ - update tsconfig
26
+
27
+ ## 0.1.7
28
+
29
+ ### Patch Changes
30
+
31
+ - update packages, split up tsconfig
32
+
33
+ ## 0.1.6
34
+
35
+ ### Patch Changes
36
+
37
+ - update packages, allow usage in non monorepos
38
+
39
+ ## 0.1.5
40
+
41
+ ### Patch Changes
42
+
43
+ - update packages
44
+
45
+ ## 0.1.4
46
+
47
+ ### Patch Changes
48
+
49
+ - update deps
50
+
51
+ ## 0.1.3
52
+
53
+ ### Patch Changes
54
+
55
+ - remove hardcoded prettier import name
56
+
57
+ ## 0.1.2
58
+
59
+ ### Patch Changes
60
+
61
+ - update prettier path
62
+
63
+ ## 0.1.1
64
+
65
+ ### Patch Changes
66
+
67
+ - bump to latest
package/base.js CHANGED
@@ -1,62 +1,87 @@
1
- /** @type {import("eslint").Linter.Config} */
2
- const config = {
3
- extends: [
4
- "turbo",
5
- "eslint:recommended",
6
- "plugin:@typescript-eslint/recommended-type-checked",
7
- "plugin:@typescript-eslint/stylistic-type-checked",
8
- ],
9
- env: {
10
- es2022: true,
11
- node: true,
12
- },
13
- parser: "@typescript-eslint/parser",
14
- parserOptions: { project: true },
15
- plugins: ["@typescript-eslint", "import", "prefer-arrow-functions"],
16
- rules: {
17
- "turbo/no-undeclared-env-vars": "off",
18
- "@typescript-eslint/no-unused-vars": [
19
- "warn",
20
- { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
21
- ],
22
- "@typescript-eslint/consistent-type-imports": [
23
- "warn",
24
- { prefer: "type-imports", fixStyle: "separate-type-imports" },
25
- ],
26
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
27
- "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
28
- "@typescript-eslint/no-misused-promises": [
29
- "error",
30
- {
31
- checksVoidReturn: false,
32
- },
33
- ],
34
- "@typescript-eslint/no-unnecessary-condition": [
35
- "error",
36
- {
37
- allowConstantLoopConditions: true,
38
- },
39
- ],
40
- "@typescript-eslint/no-non-null-assertion": "error",
41
- "prefer-arrow-functions/prefer-arrow-functions": [
42
- "warn",
43
- {
44
- classPropertiesAllowed: false,
45
- disallowPrototype: false,
46
- returnStyle: "unchanged",
47
- singleReturnOnly: false,
48
- },
49
- ],
50
- },
51
- ignorePatterns: [
52
- "**/*.config.js",
53
- "**/*.config.cjs",
54
- "**/.eslintrc.cjs",
55
- ".next",
56
- "dist",
57
- "pnpm-lock.yaml",
58
- ],
59
- reportUnusedDisableDirectives: true,
1
+ /// <reference types="./types.d.ts" />
2
+
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ import * as url from "node:url";
6
+ import { includeIgnoreFile } from "@eslint/compat";
7
+ import eslint from "@eslint/js";
8
+ import importPlugin from "eslint-plugin-import";
9
+ import turboPlugin from "eslint-plugin-turbo";
10
+ import tseslint from "typescript-eslint";
11
+
12
+ const __filename = url.fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+
15
+ const fileExists = async (filePath) => {
16
+ try {
17
+ await fs.promises.access(filePath);
18
+ return true;
19
+ } catch {
20
+ return false;
21
+ }
60
22
  };
61
23
 
62
- module.exports = config;
24
+ const gitignorePath = path.join(__dirname, "../../.gitignore");
25
+ const gitignorePath2 = path.join(__dirname, "../../../.gitignore");
26
+
27
+ export default tseslint.config(
28
+ // 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
+ ),
36
+ { ignores: ["**/*.config.*"] },
37
+ {
38
+ files: ["**/*.js", "**/*.ts", "**/*.tsx"],
39
+ plugins: {
40
+ import: importPlugin,
41
+ turbo: turboPlugin,
42
+ },
43
+ extends: [
44
+ eslint.configs.recommended,
45
+ ...tseslint.configs.recommended,
46
+ ...tseslint.configs.recommendedTypeChecked,
47
+ ...tseslint.configs.stylisticTypeChecked,
48
+ ],
49
+ rules: {
50
+ ...turboPlugin.configs.recommended.rules,
51
+ "@typescript-eslint/no-unused-vars": [
52
+ "error",
53
+ { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
54
+ ],
55
+ "@typescript-eslint/consistent-type-imports": [
56
+ "warn",
57
+ { prefer: "type-imports", fixStyle: "separate-type-imports" },
58
+ ],
59
+ "@typescript-eslint/no-misused-promises": [
60
+ 2,
61
+ { checksVoidReturn: { attributes: false } },
62
+ ],
63
+ "@typescript-eslint/no-unnecessary-condition": [
64
+ "error",
65
+ {
66
+ allowConstantLoopConditions: true,
67
+ },
68
+ ],
69
+ "@typescript-eslint/no-non-null-assertion": "error",
70
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
71
+ // "prefer-arrow-functions/prefer-arrow-functions": [
72
+ // "warn",
73
+ // {
74
+ // classPropertiesAllowed: false,
75
+ // disallowPrototype: false,
76
+ // returnStyle: "unchanged",
77
+ // singleReturnOnly: false,
78
+ // },
79
+ // ],
80
+ "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
81
+ },
82
+ },
83
+ {
84
+ linterOptions: { reportUnusedDisableDirectives: true },
85
+ languageOptions: { parserOptions: { projectService: true } },
86
+ },
87
+ );
package/nextjs.js CHANGED
@@ -1,17 +1,24 @@
1
- /** @type {import('eslint').Linter.Config} */
2
- const config = {
3
- extends: ["plugin:@next/next/core-web-vitals"],
4
- rules: {
5
- "@next/next/no-html-link-for-pages": "off",
6
- "@typescript-eslint/require-await": "off",
7
- "react/function-component-definition": [
8
- "warn",
9
- {
10
- namedComponents: "arrow-function",
11
- unnamedComponents: "arrow-function",
12
- },
13
- ],
14
- },
15
- };
1
+ import nextPlugin from "@next/eslint-plugin-next";
16
2
 
17
- module.exports = config;
3
+ /** @type {Awaited<import('typescript-eslint').Config>} */
4
+ export default [
5
+ {
6
+ files: ["**/*.ts", "**/*.tsx"],
7
+ plugins: {
8
+ "@next/next": nextPlugin,
9
+ },
10
+ rules: {
11
+ ...nextPlugin.configs.recommended.rules,
12
+ ...nextPlugin.configs["core-web-vitals"].rules,
13
+ // TypeError: context.getAncestors is not a function
14
+ "@next/next/no-duplicate-head": "off",
15
+ "react/function-component-definition": [
16
+ "warn",
17
+ {
18
+ namedComponents: "arrow-function",
19
+ unnamedComponents: "arrow-function",
20
+ },
21
+ ],
22
+ },
23
+ },
24
+ ];
package/package.json CHANGED
@@ -1,44 +1,37 @@
1
1
  {
2
2
  "name": "@kyh/eslint-config",
3
- "version": "0.1.9",
3
+ "version": "1.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "files": [
8
- "./base.js",
9
- "./nextjs.js",
10
- "./react.js"
11
- ],
7
+ "type": "module",
8
+ "exports": {
9
+ "./base": "./base.js",
10
+ "./nextjs": "./nextjs.js",
11
+ "./react": "./react.js"
12
+ },
12
13
  "dependencies": {
13
- "@next/eslint-plugin-next": "^14.2.4",
14
- "@typescript-eslint/eslint-plugin": "^7.14.1",
15
- "@typescript-eslint/parser": "^7.14.1",
16
- "eslint-config-turbo": "^2.0.5",
14
+ "@eslint/compat": "^1.1.1",
15
+ "@next/eslint-plugin-next": "^14.2.5",
17
16
  "eslint-plugin-import": "^2.29.1",
18
17
  "eslint-plugin-jsx-a11y": "^6.9.0",
19
18
  "eslint-plugin-prefer-arrow-functions": "^3.3.2",
20
- "eslint-plugin-react": "^7.34.3",
21
- "eslint-plugin-react-hooks": "^4.6.2"
19
+ "eslint-plugin-react": "^7.35.0",
20
+ "eslint-plugin-react-hooks": "rc",
21
+ "eslint-plugin-turbo": "^2.0.12",
22
+ "typescript-eslint": "^8.0.1"
22
23
  },
23
24
  "devDependencies": {
24
- "@types/eslint": "^8.56.10",
25
- "eslint": "^8.57.0",
26
- "prettier": "^3.3.2",
27
- "typescript": "^5.5.2",
28
- "@kyh/prettier-config": "^0.1.9",
29
- "@kyh/tsconfig": "^0.1.9"
30
- },
31
- "eslintConfig": {
32
- "root": true,
33
- "extends": [
34
- "./base.js"
35
- ]
25
+ "eslint": "^9.9.0",
26
+ "prettier": "^3.3.3",
27
+ "typescript": "^5.5.4",
28
+ "@kyh/prettier-config": "1.0.1",
29
+ "@kyh/tsconfig": "1.0.1"
36
30
  },
37
31
  "prettier": "@kyh/prettier-config",
38
32
  "scripts": {
39
- "clean": "rm -rf .turbo node_modules",
33
+ "clean": "git clean -xdf .cache .nitro .output .turbo .vercel node_modules",
40
34
  "format": "prettier --check . --ignore-path ../../.gitignore",
41
- "lint": "eslint .",
42
35
  "typecheck": "tsc --noEmit"
43
36
  }
44
37
  }
package/react.js CHANGED
@@ -1,31 +1,29 @@
1
- /** @type {import('eslint').Linter.Config} */
2
- const config = {
3
- extends: [
4
- "plugin:react/recommended",
5
- "plugin:react-hooks/recommended",
6
- "plugin:jsx-a11y/recommended",
7
- ],
8
- rules: {
9
- "react/prop-types": "off",
10
- "react/function-component-definition": [
11
- "warn",
12
- {
13
- namedComponents: "arrow-function",
14
- unnamedComponents: "arrow-function",
1
+ import reactPlugin from "eslint-plugin-react";
2
+ import hooksPlugin from "eslint-plugin-react-hooks";
3
+
4
+ /** @type {Awaited<import('typescript-eslint').Config>} */
5
+ export default [
6
+ {
7
+ files: ["**/*.ts", "**/*.tsx"],
8
+ plugins: {
9
+ react: reactPlugin,
10
+ "react-hooks": hooksPlugin,
11
+ },
12
+ rules: {
13
+ ...reactPlugin.configs["jsx-runtime"].rules,
14
+ ...hooksPlugin.configs.recommended.rules,
15
+ "react/function-component-definition": [
16
+ "warn",
17
+ {
18
+ namedComponents: "arrow-function",
19
+ unnamedComponents: "arrow-function",
20
+ },
21
+ ],
22
+ },
23
+ languageOptions: {
24
+ globals: {
25
+ React: "writable",
15
26
  },
16
- ],
17
- },
18
- globals: {
19
- React: "writable",
20
- },
21
- settings: {
22
- react: {
23
- version: "detect",
24
27
  },
25
28
  },
26
- env: {
27
- browser: true,
28
- },
29
- };
30
-
31
- module.exports = config;
29
+ ];
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@kyh/tsconfig/base.json",
3
+ "include": ["."],
4
+ "exclude": ["node_modules"]
5
+ }
package/types.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Since the ecosystem hasn't fully migrated to ESLint's new FlatConfig system yet,
3
+ * we "need" to type some of the plugins manually :(
4
+ */
5
+
6
+ declare module "@eslint/js" {
7
+ // Why the hell doesn't eslint themselves export their types?
8
+ import type { Linter } from "eslint";
9
+
10
+ export const configs: {
11
+ readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> };
12
+ readonly all: { readonly rules: Readonly<Linter.RulesRecord> };
13
+ };
14
+ }
15
+
16
+ declare module "eslint-plugin-import" {
17
+ import type { Linter, Rule } from "eslint";
18
+
19
+ export const configs: {
20
+ recommended: { rules: Linter.RulesRecord };
21
+ };
22
+ export const rules: Record<string, Rule.RuleModule>;
23
+ }
24
+
25
+ declare module "eslint-plugin-react" {
26
+ import type { Linter, Rule } from "eslint";
27
+
28
+ export const configs: {
29
+ recommended: { rules: Linter.RulesRecord };
30
+ all: { rules: Linter.RulesRecord };
31
+ "jsx-runtime": { rules: Linter.RulesRecord };
32
+ };
33
+ export const rules: Record<string, Rule.RuleModule>;
34
+ }
35
+
36
+ declare module "eslint-plugin-react-hooks" {
37
+ import type { Linter, Rule } from "eslint";
38
+
39
+ export const configs: {
40
+ recommended: {
41
+ rules: {
42
+ "rules-of-hooks": Linter.RuleEntry;
43
+ "exhaustive-deps": Linter.RuleEntry;
44
+ };
45
+ };
46
+ };
47
+ export const rules: Record<string, Rule.RuleModule>;
48
+ }
49
+
50
+ declare module "@next/eslint-plugin-next" {
51
+ import type { Linter, Rule } from "eslint";
52
+
53
+ export const configs: {
54
+ recommended: { rules: Linter.RulesRecord };
55
+ "core-web-vitals": { rules: Linter.RulesRecord };
56
+ };
57
+ export const rules: Record<string, Rule.RuleModule>;
58
+ }
59
+
60
+ declare module "eslint-plugin-turbo" {
61
+ import type { Linter, Rule } from "eslint";
62
+
63
+ export const configs: {
64
+ recommended: { rules: Linter.RulesRecord };
65
+ };
66
+ export const rules: Record<string, Rule.RuleModule>;
67
+ }