@krosoft/tooling-eslint 0.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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/base.js +145 -0
  3. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # krosoft-tooling-eslint
2
+
3
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
4
+
5
+ Krosoft ESLint shared config for TypeScript.
package/base.js ADDED
@@ -0,0 +1,145 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@krosoft/tooling-eslint",
3
+ "version": "0.0.1",
4
+ "description": "Krosoft ESLint shared config for TypeScript",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./base.js"
8
+ },
9
+ "files": [
10
+ "base.js"
11
+ ],
12
+ "peerDependencies": {
13
+ "@eslint/js": ">=9.0.0",
14
+ "eslint": ">=9.0.0",
15
+ "eslint-config-prettier": ">=9.0.0",
16
+ "eslint-plugin-prettier": ">=5.0.0",
17
+ "globals": ">=15.0.0",
18
+ "typescript-eslint": ">=8.0.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/krosoft-dev/krosoft-tooling-eslint.git"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }