@10stars/config 9.1.0 → 9.1.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.
package/.eslintrc.js ADDED
@@ -0,0 +1,253 @@
1
+ const builtinModules = require("builtin-modules")
2
+ /**
3
+ * @todo
4
+ * - prohibit "whiteSpace" style rule
5
+ */
6
+ /**
7
+ * @return [0, 0.25, -0.25, 0.5, -0.5, 0.75, -0.75, 1, -1, ..., 10, -10]
8
+ */
9
+ const allowedMagicNumbers = (() => {
10
+ const magicNumbers = []
11
+ const max = 10
12
+
13
+ for (let i = 0; i < max + 1; i++) {
14
+ if (i === max) {
15
+ magicNumbers.push(i, -i)
16
+ continue
17
+ }
18
+
19
+ if (i === -i) magicNumbers.push(i)
20
+ else magicNumbers.push(i, -i)
21
+
22
+ const numOfDecimals = 4
23
+ const decimalPoint = 1 / numOfDecimals
24
+ for (let b = 1; b < numOfDecimals; b++) {
25
+ const decimal = i + b * decimalPoint
26
+ magicNumbers.push(decimal, -decimal)
27
+ }
28
+ }
29
+
30
+ return magicNumbers
31
+ })()
32
+
33
+ const reactUseHooks = [
34
+ `useUpdateEffect`,
35
+ `useIsomorphicLayoutEffect`,
36
+ `useDeepCompareEffect`,
37
+ `useShallowCompareEffect`,
38
+ `useCustomCompareEffect`,
39
+ ]
40
+
41
+ const type = {
42
+ ignore: 0,
43
+ warning: 1,
44
+ error: 2,
45
+ }
46
+
47
+ module.exports = {
48
+ root: true, // https://eslint.org/docs/latest/use/configure/configuration-files#using-configuration-files
49
+ parser: `@typescript-eslint/parser`, // Specifies the ESLint parser
50
+ parserOptions: {
51
+ ecmaVersion: `latest`, // Allows for the parsing of modern ECMAScript features
52
+ sourceType: `module`, // Allows for the use of imports
53
+ ecmaFeatures: {
54
+ jsx: true, // Allows for the parsing of JSX
55
+ },
56
+ },
57
+ ignorePatterns: [`**/node_modules`, `**/.git`, `**/dist`, `**/tmp`],
58
+ plugins: [
59
+ `@typescript-eslint`,
60
+ `import`,
61
+ `react`,
62
+ `@10stars/react-hooks`, // https://reactjs.org/docs/hooks-rules.html#eslint-plugin
63
+ `regexp`,
64
+ `simple-import-sort`,
65
+ `sort-keys-fix`,
66
+ // 'prettier' commented as we don't want to run prettier through eslint because of performance
67
+ ],
68
+ env: {
69
+ browser: true,
70
+ jest: true,
71
+ },
72
+ extends: [
73
+ `eslint:recommended`,
74
+ `plugin:@typescript-eslint/strict-type-checked`,
75
+ `plugin:@typescript-eslint/stylistic-type-checked`,
76
+ `plugin:react/recommended`,
77
+ `plugin:@10stars/react-hooks/recommended`,
78
+ `plugin:regexp/recommended`,
79
+
80
+ // We use only few custom rules from the import plugin and we override some aspects with simple-import-sort
81
+ // "plugin:import/typescript",
82
+ // "plugin:import/warnings",
83
+ // "plugin:import/errors",
84
+ `prettier`, // see: https://github.com/prettier/eslint-config-prettier
85
+ ],
86
+ settings: {
87
+ "import/parsers": { "@typescript-eslint/parser": [`.ts`, `.tsx`] },
88
+ "import/extensions": [`.ts`, `.tsx`, `.js`, `.jsx`],
89
+ react: {
90
+ version: `18.0.0`,
91
+ },
92
+ },
93
+ rules: {
94
+ /**
95
+ * ESLint core rules
96
+ */
97
+ "no-case-declarations": type.ignore, // TypeScript shows us error, if the variable is reused in the same scope, so this rule is not applicable
98
+ /**
99
+ * eslint-plugin-import @see https://github.com/benmosher/eslint-plugin-import
100
+ */
101
+ "import/order": type.ignore, // turn off in favor of eslint-plugin-simple-import-sort
102
+ "import/no-unresolved": type.ignore,
103
+ "import/no-duplicates": type.warning,
104
+ "import/no-nodejs-modules": [
105
+ type.error,
106
+ {
107
+ allow: builtinModules.flatMap((v) => [
108
+ `node:${v}`,
109
+ `node:${v}/promises`,
110
+ ]),
111
+ },
112
+ ],
113
+ /**
114
+ * eslint-plugin-simple-import-sort
115
+ */
116
+ "sort-imports": type.ignore, // we use eslint-plugin-import instead
117
+ "simple-import-sort/imports": type.warning,
118
+ "simple-import-sort/exports": type.warning,
119
+ /**
120
+ * React
121
+ */
122
+ "react/display-name": type.ignore,
123
+ "react/no-children-prop": type.ignore,
124
+ /** we ignore CSS, because we use Emotion @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md#rule-options */
125
+ "react/no-unknown-property": [type.error, { ignore: [`css`] }],
126
+ "react/prop-types": type.ignore,
127
+ "react/react-in-jsx-scope": type.ignore,
128
+ "react/jsx-filename-extension": [
129
+ type.warning,
130
+ { extensions: [`.jsx`, `.tsx`] },
131
+ ], // also want to use with ".tsx"
132
+ "react/no-invalid-html-attribute": type.error,
133
+ "react/prefer-stateless-function": type.error,
134
+ "react/jsx-boolean-value": [type.warning, "never"],
135
+ "react/jsx-curly-brace-presence": [type.warning, "always"],
136
+ "react/jsx-fragments": type.warning,
137
+ "react/jsx-no-bind": type.warning,
138
+ "react/jsx-no-constructed-context-values": type.warning,
139
+ "react/jsx-no-script-url": [
140
+ type.error,
141
+ [
142
+ { name: "Link", props: ["to"] },
143
+ { name: "NavLink", props: ["to"] },
144
+ { name: "a", props: ["href", "to"] },
145
+ ],
146
+ ],
147
+ "react/jsx-no-useless-fragment": type.warning,
148
+ "react/jsx-no-target-blank": type.error,
149
+ "react/jsx-sort-props": type.warning,
150
+ /**
151
+ * Hooks
152
+ */
153
+ "@10stars/react-hooks/exhaustive-deps": [
154
+ type.warning,
155
+ {
156
+ additionalHooks: `(${reactUseHooks.join(`|`)})`,
157
+ ignoreThisDependency: `always`,
158
+ },
159
+ ],
160
+ /**
161
+ * TypeScript
162
+ * List of ignored (not recommended) rules we also explored:
163
+ * - @typescript-eslint/consistent-type-assertions
164
+ * - @typescript-eslint/explicit-module-boundary-types
165
+ * - @typescript-eslint/no-require-imports
166
+ * - @typescript-eslint/no-type-alias
167
+ * - @typescript-eslint/strict-boolean-expressions // doesn't work well
168
+ */
169
+ // disabled recommended rules
170
+ "@typescript-eslint/prefer-nullish-coalescing": 0, // doesn't make sense sometimes and actually could introduce a bug
171
+ "@typescript-eslint/consistent-indexed-object-style": 0,
172
+ "@typescript-eslint/no-throw-literal": 0,
173
+ "@typescript-eslint/no-unnecessary-condition": 0,
174
+ "@typescript-eslint/no-confusing-void-expression": 0,
175
+ "@typescript-eslint/no-invalid-void-type": 0,
176
+ "@typescript-eslint/no-unused-vars": type.ignore, // removed by bundler, so it shouldn't be a rule
177
+ "@typescript-eslint/no-empty-function": type.ignore, // used for prototyping
178
+ "@typescript-eslint/no-explicit-any": type.ignore,
179
+ "@typescript-eslint/ban-types": type.ignore,
180
+ // ---- we ignore these "no-unsafe-*" as it noticeably slows down the code writing
181
+ "@typescript-eslint/no-unsafe-assignment": type.ignore,
182
+ "@typescript-eslint/no-unsafe-member-access": type.ignore,
183
+ "@typescript-eslint/no-unsafe-return": type.ignore,
184
+ "@typescript-eslint/no-non-null-assertion": type.ignore, // sometimes TS incorrectly asserts, so there's a need to override
185
+ "@typescript-eslint/unbound-method": type.ignore,
186
+ // other
187
+ quotes: type.ignore,
188
+ "@typescript-eslint/array-type": [type.warning, { default: `array` }],
189
+ "@typescript-eslint/quotes": [type.warning, `backtick`],
190
+ "@typescript-eslint/consistent-type-definitions": [
191
+ type.warning, // @see https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces
192
+ `interface`, // VSCode's Code lens can only highlight use of properties in "interface" definitions
193
+ ],
194
+ "no-magic-numbers": type.ignore,
195
+ "@typescript-eslint/no-magic-numbers": [
196
+ type.warning,
197
+ {
198
+ ignore: allowedMagicNumbers,
199
+ ignoreTypeIndexes: true,
200
+ ignoreReadonlyClassProperties: true,
201
+ ignoreNumericLiteralTypes: true,
202
+ ignoreEnums: true,
203
+ },
204
+ ],
205
+ "@typescript-eslint/no-unnecessary-type-arguments": type.warning,
206
+ "@typescript-eslint/unified-signatures": type.warning,
207
+ // string
208
+ "@typescript-eslint/prefer-string-starts-ends-with": type.warning,
209
+ // RegExp
210
+ "@typescript-eslint/prefer-regexp-exec": type.warning,
211
+ // array
212
+ "@typescript-eslint/prefer-includes": type.warning,
213
+ "@typescript-eslint/require-array-sort-compare": type.warning,
214
+ // loops
215
+ "@typescript-eslint/prefer-for-of": type.warning,
216
+ // promises
217
+ "@typescript-eslint/no-misused-promises": [
218
+ type.warning,
219
+ { checksVoidReturn: false },
220
+ ],
221
+ "@typescript-eslint/no-floating-promises": [
222
+ type.warning,
223
+ { ignoreVoid: true },
224
+ ],
225
+ // namespace
226
+ "@typescript-eslint/no-unnecessary-qualifier": type.warning,
227
+ // for classes
228
+ "@typescript-eslint/no-extraneous-class": type.warning,
229
+ "@typescript-eslint/explicit-member-accessibility": type.warning,
230
+ "@typescript-eslint/member-ordering": [
231
+ type.warning,
232
+ {
233
+ default: [
234
+ `public-static-field`,
235
+ `public-instance-field`,
236
+ `public-constructor`,
237
+ `private-static-field`,
238
+ `private-instance-field`,
239
+ `private-constructor`,
240
+ `public-instance-method`,
241
+ `protected-instance-method`,
242
+ `private-instance-method`,
243
+ ],
244
+ },
245
+ ],
246
+ "no-useless-constructor": type.ignore,
247
+ "@typescript-eslint/no-useless-constructor": type.warning,
248
+ /**
249
+ * Regex
250
+ */
251
+ "regexp/no-useless-escape": type.warning,
252
+ },
253
+ }
package/.prettierrc.js ADDED
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ parser: "typescript",
3
+ arrowParens: "always",
4
+ trailingComma: "all",
5
+ tabWidth: 2,
6
+ semi: false,
7
+ singleQuote: false,
8
+ overrides: [
9
+ {
10
+ files: "*.yml",
11
+ options: { parser: "yaml" },
12
+ },
13
+ {
14
+ files: "*.yaml",
15
+ options: { parser: "yaml" },
16
+ },
17
+ {
18
+ files: "*.md",
19
+ options: { parser: "markdown" },
20
+ },
21
+ {
22
+ files: "*.mdx",
23
+ options: { parser: "mdx" },
24
+ },
25
+ {
26
+ files: "*.json",
27
+ options: { parser: "json" },
28
+ },
29
+ {
30
+ files: "*.html",
31
+ options: { parser: "html" },
32
+ },
33
+ {
34
+ files: "*.css",
35
+ options: { parser: "css" },
36
+ },
37
+ ],
38
+ }
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ extends: [`@commitlint/config-conventional`],
3
+ /**
4
+ * For explanation on how to write rules @see https://commitlint.js.org/#/reference-rules
5
+ */
6
+ rules: {
7
+ "body-leading-blank": [1, `always`],
8
+ "footer-leading-blank": [1, `always`],
9
+ "header-max-length": [2, `always`, 72],
10
+ "scope-case": [2, `always`, `lower-case`],
11
+ "subject-case": [2, `never`, [`start-case`, `pascal-case`, `upper-case`]],
12
+ "subject-empty": [2, `never`],
13
+ "subject-full-stop": [2, `never`, `.`],
14
+ "type-case": [2, `always`, `upper-case`],
15
+ "type-empty": [2, `never`],
16
+ "type-enum": [
17
+ 2,
18
+ `always`,
19
+ [
20
+ `ADDED`, // new features
21
+ `CHANGED`, // changes in existing functionality
22
+ `DEPRECATED`, // soon-to-be removed features
23
+ `FIXED`, // any bug fixes
24
+ `REMOVED`, // removed features
25
+ `SECURITY`, // in case of vulnerabilities
26
+ ],
27
+ ],
28
+ },
29
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "name": "@10stars/config",
7
- "version": "9.1.0",
7
+ "version": "9.1.2",
8
8
  "author": "10stars.dev <web@alexandrov.co> (https://alexandrov.co)",
9
9
  "license": "MIT",
10
10
  "module": "./src/index.ts",