@krosoft/tooling-eslint 0.0.1 → 0.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.
package/dist/base.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import tseslint from "typescript-eslint";
2
+ interface BaseConfigOptions {
3
+ tsconfigRootDir: string;
4
+ project?: string[];
5
+ }
6
+ export declare function createBaseConfig({ tsconfigRootDir, project, }: BaseConfigOptions): ReturnType<typeof tseslint.config>;
7
+ export {};
package/dist/base.js ADDED
@@ -0,0 +1,127 @@
1
+ import js from "@eslint/js";
2
+ import tseslint from "typescript-eslint";
3
+ import prettierConfig from "eslint-config-prettier";
4
+ import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
5
+ import globals from "globals";
6
+ export function createBaseConfig({ tsconfigRootDir, project = ["./tsconfig.json"], }) {
7
+ return tseslint.config({ ignores: ["dist"] }, js.configs.recommended, tseslint.configs.strictTypeChecked, prettierConfig, {
8
+ files: ["**/*.{ts,tsx}"],
9
+ languageOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: "module",
12
+ parser: tseslint.parser,
13
+ parserOptions: {
14
+ project,
15
+ tsconfigRootDir,
16
+ },
17
+ globals: {
18
+ ...globals.browser,
19
+ },
20
+ },
21
+ plugins: {
22
+ "@typescript-eslint": tseslint.plugin,
23
+ },
24
+ rules: {
25
+ // TypeScript - Very Strict
26
+ "@typescript-eslint/no-unused-vars": [
27
+ "error",
28
+ {
29
+ argsIgnorePattern: "^_",
30
+ varsIgnorePattern: "^_",
31
+ caughtErrorsIgnorePattern: "^_",
32
+ },
33
+ ],
34
+ "@typescript-eslint/no-explicit-any": "error",
35
+ "@typescript-eslint/explicit-function-return-type": [
36
+ "error",
37
+ {
38
+ allowExpressions: true,
39
+ allowTypedFunctionExpressions: true,
40
+ allowHigherOrderFunctions: true,
41
+ },
42
+ ],
43
+ "@typescript-eslint/explicit-module-boundary-types": "error",
44
+ "@typescript-eslint/no-non-null-assertion": "error",
45
+ "@typescript-eslint/no-unnecessary-condition": "error",
46
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
47
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
48
+ "@typescript-eslint/prefer-optional-chain": "error",
49
+ "@typescript-eslint/strict-boolean-expressions": [
50
+ "error",
51
+ {
52
+ allowString: false,
53
+ allowNumber: false,
54
+ allowNullableObject: false,
55
+ },
56
+ ],
57
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
58
+ "@typescript-eslint/no-floating-promises": "error",
59
+ "@typescript-eslint/no-misused-promises": "error",
60
+ "@typescript-eslint/await-thenable": "error",
61
+ "@typescript-eslint/require-await": "error",
62
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
63
+ "@typescript-eslint/prefer-readonly": "error",
64
+ "@typescript-eslint/prefer-readonly-parameter-types": "off",
65
+ "@typescript-eslint/no-confusing-void-expression": "error",
66
+ "@typescript-eslint/no-meaningless-void-operator": "error",
67
+ "@typescript-eslint/no-unsafe-argument": "error",
68
+ "@typescript-eslint/no-unsafe-assignment": "error",
69
+ "@typescript-eslint/no-unsafe-call": "error",
70
+ "@typescript-eslint/no-unsafe-member-access": "error",
71
+ "@typescript-eslint/no-unsafe-return": "error",
72
+ // Naming Conventions
73
+ "@typescript-eslint/naming-convention": [
74
+ "error",
75
+ {
76
+ selector: "default",
77
+ format: ["camelCase"],
78
+ leadingUnderscore: "allow",
79
+ trailingUnderscore: "forbid",
80
+ },
81
+ {
82
+ selector: "variable",
83
+ format: ["camelCase", "UPPER_CASE", "PascalCase"],
84
+ leadingUnderscore: "allow",
85
+ },
86
+ { selector: "function", format: ["camelCase", "PascalCase"] },
87
+ {
88
+ selector: "parameter",
89
+ format: ["camelCase"],
90
+ leadingUnderscore: "allow",
91
+ },
92
+ {
93
+ selector: "memberLike",
94
+ modifiers: ["private"],
95
+ format: ["camelCase"],
96
+ leadingUnderscore: "require",
97
+ },
98
+ { selector: "typeLike", format: ["PascalCase"] },
99
+ { selector: "enumMember", format: ["UPPER_CASE"] },
100
+ {
101
+ selector: "interface",
102
+ format: ["PascalCase"],
103
+ custom: { regex: "^I[A-Z]", match: false },
104
+ },
105
+ ],
106
+ // Code Quality
107
+ "no-console": ["warn", { allow: ["warn", "error"] }],
108
+ "no-debugger": "error",
109
+ "no-alert": "error",
110
+ "no-var": "error",
111
+ "prefer-const": "error",
112
+ "prefer-arrow-callback": "error",
113
+ "prefer-template": "error",
114
+ "no-nested-ternary": "error",
115
+ "no-unneeded-ternary": "error",
116
+ eqeqeq: ["error", "always"],
117
+ curly: ["error", "all"],
118
+ "no-else-return": "error",
119
+ "no-lonely-if": "error",
120
+ "no-useless-return": "error",
121
+ "prefer-destructuring": ["error", { object: true, array: false }],
122
+ "object-shorthand": ["error", "always"],
123
+ "no-param-reassign": "error",
124
+ "prettier/prettier": "error",
125
+ },
126
+ }, eslintPluginPrettier);
127
+ }
package/package.json CHANGED
@@ -1,20 +1,26 @@
1
1
  {
2
2
  "name": "@krosoft/tooling-eslint",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Krosoft ESLint shared config for TypeScript",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": "./base.js"
7
+ ".": "./dist/base.js"
8
8
  },
9
9
  "files": [
10
- "base.js"
10
+ "dist"
11
11
  ],
12
+ "scripts": {
13
+ "build": "tsc -p tsconfig.build.json"
14
+ },
15
+ "devDependencies": {
16
+ "typescript": "^5.0.0"
17
+ },
12
18
  "peerDependencies": {
13
19
  "@eslint/js": ">=9.0.0",
14
20
  "eslint": ">=9.0.0",
15
21
  "eslint-config-prettier": ">=9.0.0",
16
22
  "eslint-plugin-prettier": ">=5.0.0",
17
- "globals": ">=15.0.0",
23
+ "globals": ">=15.15.0",
18
24
  "typescript-eslint": ">=8.0.0"
19
25
  },
20
26
  "repository": {
package/base.js DELETED
@@ -1,145 +0,0 @@
1
- import js from "@eslint/js";
2
- import tseslint from "typescript-eslint";
3
- import prettierConfig from "eslint-config-prettier";
4
- import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
5
- import globals from "globals";
6
-
7
- /**
8
- * @param {{ tsconfigRootDir: string, project?: string[] }} options
9
- * @returns {import("typescript-eslint").ConfigArray}
10
- */
11
- export function createBaseConfig({
12
- tsconfigRootDir,
13
- project = ["./tsconfig.json"],
14
- }) {
15
- return tseslint.config(
16
- { ignores: ["dist"] },
17
- js.configs.recommended,
18
- tseslint.configs.strictTypeChecked,
19
- prettierConfig,
20
- {
21
- files: ["**/*.{ts,tsx}"],
22
- languageOptions: {
23
- ecmaVersion: 2022,
24
- sourceType: "module",
25
- parser: tseslint.parser,
26
- parserOptions: {
27
- project,
28
- tsconfigRootDir,
29
- },
30
- globals: {
31
- ...globals.browser,
32
- },
33
- },
34
- plugins: {
35
- "@typescript-eslint": tseslint.plugin,
36
- },
37
- rules: {
38
- // TypeScript - Very Strict
39
- "@typescript-eslint/no-unused-vars": [
40
- "error",
41
- {
42
- argsIgnorePattern: "^_",
43
- varsIgnorePattern: "^_",
44
- caughtErrorsIgnorePattern: "^_",
45
- },
46
- ],
47
- "@typescript-eslint/no-explicit-any": "error",
48
- "@typescript-eslint/explicit-function-return-type": [
49
- "error",
50
- {
51
- allowExpressions: true,
52
- allowTypedFunctionExpressions: true,
53
- allowHigherOrderFunctions: true,
54
- },
55
- ],
56
- "@typescript-eslint/explicit-module-boundary-types": "error",
57
- "@typescript-eslint/no-non-null-assertion": "error",
58
- "@typescript-eslint/no-unnecessary-condition": "error",
59
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
60
- "@typescript-eslint/prefer-nullish-coalescing": "error",
61
- "@typescript-eslint/prefer-optional-chain": "error",
62
- "@typescript-eslint/strict-boolean-expressions": [
63
- "error",
64
- {
65
- allowString: false,
66
- allowNumber: false,
67
- allowNullableObject: false,
68
- },
69
- ],
70
- "@typescript-eslint/switch-exhaustiveness-check": "error",
71
- "@typescript-eslint/no-floating-promises": "error",
72
- "@typescript-eslint/no-misused-promises": "error",
73
- "@typescript-eslint/await-thenable": "error",
74
- "@typescript-eslint/require-await": "error",
75
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
76
- "@typescript-eslint/prefer-readonly": "error",
77
- "@typescript-eslint/prefer-readonly-parameter-types": "off",
78
- "@typescript-eslint/no-confusing-void-expression": "error",
79
- "@typescript-eslint/no-meaningless-void-operator": "error",
80
- "@typescript-eslint/no-unsafe-argument": "error",
81
- "@typescript-eslint/no-unsafe-assignment": "error",
82
- "@typescript-eslint/no-unsafe-call": "error",
83
- "@typescript-eslint/no-unsafe-member-access": "error",
84
- "@typescript-eslint/no-unsafe-return": "error",
85
-
86
- // Naming Conventions
87
- "@typescript-eslint/naming-convention": [
88
- "error",
89
- {
90
- selector: "default",
91
- format: ["camelCase"],
92
- leadingUnderscore: "allow",
93
- trailingUnderscore: "forbid",
94
- },
95
- {
96
- selector: "variable",
97
- format: ["camelCase", "UPPER_CASE", "PascalCase"],
98
- leadingUnderscore: "allow",
99
- },
100
- { selector: "function", format: ["camelCase", "PascalCase"] },
101
- {
102
- selector: "parameter",
103
- format: ["camelCase"],
104
- leadingUnderscore: "allow",
105
- },
106
- {
107
- selector: "memberLike",
108
- modifiers: ["private"],
109
- format: ["camelCase"],
110
- leadingUnderscore: "require",
111
- },
112
- { selector: "typeLike", format: ["PascalCase"] },
113
- { selector: "enumMember", format: ["UPPER_CASE"] },
114
- {
115
- selector: "interface",
116
- format: ["PascalCase"],
117
- custom: { regex: "^I[A-Z]", match: false },
118
- },
119
- ],
120
-
121
- // Code Quality
122
- "no-console": ["warn", { allow: ["warn", "error"] }],
123
- "no-debugger": "error",
124
- "no-alert": "error",
125
- "no-var": "error",
126
- "prefer-const": "error",
127
- "prefer-arrow-callback": "error",
128
- "prefer-template": "error",
129
- "no-nested-ternary": "error",
130
- "no-unneeded-ternary": "error",
131
- eqeqeq: ["error", "always"],
132
- curly: ["error", "all"],
133
- "no-else-return": "error",
134
- "no-lonely-if": "error",
135
- "no-useless-return": "error",
136
- "prefer-destructuring": ["error", { object: true, array: false }],
137
- "object-shorthand": ["error", "always"],
138
- "no-param-reassign": "error",
139
-
140
- "prettier/prettier": "error",
141
- },
142
- },
143
- eslintPluginPrettier,
144
- );
145
- }