@entva/styleguide 0.0.0
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/.github/workflows/ci.yml +14 -0
- package/LICENSE +21 -0
- package/README.md +88 -0
- package/css/README.md +385 -0
- package/css/packages/stylelint/LICENSE +21 -0
- package/css/packages/stylelint/README.md +27 -0
- package/css/packages/stylelint/eslint.config.js +3 -0
- package/css/packages/stylelint/index.js +84 -0
- package/css/packages/stylelint/package-lock.json +4042 -0
- package/css/packages/stylelint/package.json +42 -0
- package/html/README.md +98 -0
- package/javascript/README.md +3255 -0
- package/javascript/packages/eslint-base/LICENSE +21 -0
- package/javascript/packages/eslint-base/README.md +27 -0
- package/javascript/packages/eslint-base/eslint.config.js +3 -0
- package/javascript/packages/eslint-base/index.js +1084 -0
- package/javascript/packages/eslint-base/package-lock.json +2653 -0
- package/javascript/packages/eslint-base/package.json +36 -0
- package/javascript/packages/eslint-react/LICENSE +21 -0
- package/javascript/packages/eslint-react/README.md +27 -0
- package/javascript/packages/eslint-react/eslint.config.js +3 -0
- package/javascript/packages/eslint-react/index.js +526 -0
- package/javascript/packages/eslint-react/package-lock.json +3035 -0
- package/javascript/packages/eslint-react/package.json +42 -0
- package/package.json +15 -0
- package/react/README.md +726 -0
- package/scripts/for-each-package +12 -0
- package/test/css.js +36 -0
- package/test/index.js +7 -0
- package/test/js.js +35 -0
- package/test/utils.js +63 -0
- package/tooling/packages/biome/LICENSE +21 -0
- package/tooling/packages/biome/README.md +27 -0
- package/tooling/packages/biome/biome.json +1285 -0
- package/tooling/packages/biome/package-lock.json +183 -0
- package/tooling/packages/biome/package.json +38 -0
- package/tsconfig.json +31 -0
- package/typescript/README.md +66 -0
- package/typescript/packages/eslint-typescript-base/LICENSE +21 -0
- package/typescript/packages/eslint-typescript-base/README.md +27 -0
- package/typescript/packages/eslint-typescript-base/eslint.config.js +3 -0
- package/typescript/packages/eslint-typescript-base/index.js +272 -0
- package/typescript/packages/eslint-typescript-base/package-lock.json +3215 -0
- package/typescript/packages/eslint-typescript-base/package.json +41 -0
- package/typescript/packages/eslint-typescript-base/tsconfig.json +30 -0
- package/typescript/packages/eslint-typescript-react/LICENSE +21 -0
- package/typescript/packages/eslint-typescript-react/README.md +27 -0
- package/typescript/packages/eslint-typescript-react/eslint.config.js +3 -0
- package/typescript/packages/eslint-typescript-react/index.js +75 -0
- package/typescript/packages/eslint-typescript-react/package-lock.json +3630 -0
- package/typescript/packages/eslint-typescript-react/package.json +41 -0
- package/typescript/packages/eslint-typescript-react/tsconfig.json +30 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@entva/styleguide",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "@entva/styleguide",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@biomejs/biome": "^1.9.4"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@biomejs/biome": "^1.x.x"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"node_modules/@biomejs/biome": {
|
|
19
|
+
"version": "1.9.4",
|
|
20
|
+
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz",
|
|
21
|
+
"integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==",
|
|
22
|
+
"dev": true,
|
|
23
|
+
"hasInstallScript": true,
|
|
24
|
+
"license": "MIT OR Apache-2.0",
|
|
25
|
+
"bin": {
|
|
26
|
+
"biome": "bin/biome"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=14.21.3"
|
|
30
|
+
},
|
|
31
|
+
"funding": {
|
|
32
|
+
"type": "opencollective",
|
|
33
|
+
"url": "https://opencollective.com/biome"
|
|
34
|
+
},
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"@biomejs/cli-darwin-arm64": "1.9.4",
|
|
37
|
+
"@biomejs/cli-darwin-x64": "1.9.4",
|
|
38
|
+
"@biomejs/cli-linux-arm64": "1.9.4",
|
|
39
|
+
"@biomejs/cli-linux-arm64-musl": "1.9.4",
|
|
40
|
+
"@biomejs/cli-linux-x64": "1.9.4",
|
|
41
|
+
"@biomejs/cli-linux-x64-musl": "1.9.4",
|
|
42
|
+
"@biomejs/cli-win32-arm64": "1.9.4",
|
|
43
|
+
"@biomejs/cli-win32-x64": "1.9.4"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"node_modules/@biomejs/cli-darwin-arm64": {
|
|
47
|
+
"version": "1.9.4",
|
|
48
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz",
|
|
49
|
+
"integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==",
|
|
50
|
+
"cpu": [
|
|
51
|
+
"arm64"
|
|
52
|
+
],
|
|
53
|
+
"dev": true,
|
|
54
|
+
"license": "MIT OR Apache-2.0",
|
|
55
|
+
"optional": true,
|
|
56
|
+
"os": [
|
|
57
|
+
"darwin"
|
|
58
|
+
],
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=14.21.3"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"node_modules/@biomejs/cli-darwin-x64": {
|
|
64
|
+
"version": "1.9.4",
|
|
65
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz",
|
|
66
|
+
"integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==",
|
|
67
|
+
"cpu": [
|
|
68
|
+
"x64"
|
|
69
|
+
],
|
|
70
|
+
"dev": true,
|
|
71
|
+
"license": "MIT OR Apache-2.0",
|
|
72
|
+
"optional": true,
|
|
73
|
+
"os": [
|
|
74
|
+
"darwin"
|
|
75
|
+
],
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=14.21.3"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"node_modules/@biomejs/cli-linux-arm64": {
|
|
81
|
+
"version": "1.9.4",
|
|
82
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz",
|
|
83
|
+
"integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==",
|
|
84
|
+
"cpu": [
|
|
85
|
+
"arm64"
|
|
86
|
+
],
|
|
87
|
+
"dev": true,
|
|
88
|
+
"license": "MIT OR Apache-2.0",
|
|
89
|
+
"optional": true,
|
|
90
|
+
"os": [
|
|
91
|
+
"linux"
|
|
92
|
+
],
|
|
93
|
+
"engines": {
|
|
94
|
+
"node": ">=14.21.3"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"node_modules/@biomejs/cli-linux-arm64-musl": {
|
|
98
|
+
"version": "1.9.4",
|
|
99
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz",
|
|
100
|
+
"integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==",
|
|
101
|
+
"cpu": [
|
|
102
|
+
"arm64"
|
|
103
|
+
],
|
|
104
|
+
"dev": true,
|
|
105
|
+
"license": "MIT OR Apache-2.0",
|
|
106
|
+
"optional": true,
|
|
107
|
+
"os": [
|
|
108
|
+
"linux"
|
|
109
|
+
],
|
|
110
|
+
"engines": {
|
|
111
|
+
"node": ">=14.21.3"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"node_modules/@biomejs/cli-linux-x64": {
|
|
115
|
+
"version": "1.9.4",
|
|
116
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz",
|
|
117
|
+
"integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==",
|
|
118
|
+
"cpu": [
|
|
119
|
+
"x64"
|
|
120
|
+
],
|
|
121
|
+
"dev": true,
|
|
122
|
+
"license": "MIT OR Apache-2.0",
|
|
123
|
+
"optional": true,
|
|
124
|
+
"os": [
|
|
125
|
+
"linux"
|
|
126
|
+
],
|
|
127
|
+
"engines": {
|
|
128
|
+
"node": ">=14.21.3"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"node_modules/@biomejs/cli-linux-x64-musl": {
|
|
132
|
+
"version": "1.9.4",
|
|
133
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz",
|
|
134
|
+
"integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==",
|
|
135
|
+
"cpu": [
|
|
136
|
+
"x64"
|
|
137
|
+
],
|
|
138
|
+
"dev": true,
|
|
139
|
+
"license": "MIT OR Apache-2.0",
|
|
140
|
+
"optional": true,
|
|
141
|
+
"os": [
|
|
142
|
+
"linux"
|
|
143
|
+
],
|
|
144
|
+
"engines": {
|
|
145
|
+
"node": ">=14.21.3"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"node_modules/@biomejs/cli-win32-arm64": {
|
|
149
|
+
"version": "1.9.4",
|
|
150
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz",
|
|
151
|
+
"integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==",
|
|
152
|
+
"cpu": [
|
|
153
|
+
"arm64"
|
|
154
|
+
],
|
|
155
|
+
"dev": true,
|
|
156
|
+
"license": "MIT OR Apache-2.0",
|
|
157
|
+
"optional": true,
|
|
158
|
+
"os": [
|
|
159
|
+
"win32"
|
|
160
|
+
],
|
|
161
|
+
"engines": {
|
|
162
|
+
"node": ">=14.21.3"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"node_modules/@biomejs/cli-win32-x64": {
|
|
166
|
+
"version": "1.9.4",
|
|
167
|
+
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz",
|
|
168
|
+
"integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==",
|
|
169
|
+
"cpu": [
|
|
170
|
+
"x64"
|
|
171
|
+
],
|
|
172
|
+
"dev": true,
|
|
173
|
+
"license": "MIT OR Apache-2.0",
|
|
174
|
+
"optional": true,
|
|
175
|
+
"os": [
|
|
176
|
+
"win32"
|
|
177
|
+
],
|
|
178
|
+
"engines": {
|
|
179
|
+
"node": ">=14.21.3"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@entva/styleguide",
|
|
3
|
+
"description": "Shareable styleguide config for biome",
|
|
4
|
+
"author": "Max Degterev <max@degterev.me>",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"readmeFilename": "README.md",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/entva/styleguide"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/entva/styleguide/issues",
|
|
12
|
+
"version": "1.0.0",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"linter",
|
|
15
|
+
"config",
|
|
16
|
+
"eslint",
|
|
17
|
+
"biome",
|
|
18
|
+
"styleguide",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"biome.json"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./biome": "./biome.json"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"reinstall": "rm -rf node_modules package-lock.json && npm install",
|
|
30
|
+
"test": "echo \"Not supported by Biome\" && exit 0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@biomejs/biome": "^1.9.4"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@biomejs/biome": "^1.x.x"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"module": "esnext",
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"jsx": "preserve",
|
|
20
|
+
"incremental": true
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"**/*.ts",
|
|
24
|
+
"**/*.tsx",
|
|
25
|
+
"**/*.js",
|
|
26
|
+
"**/*.jsx"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# TypeScript Style Guide
|
|
2
|
+
|
|
3
|
+
In this document we outline coding preferences specific to TypeScript. Almost everything that is written in the [JavaScript](javascript/README.md) guide applies for TypeScript as well. It is always good to refresh your memory with the official language documentation [here](https://www.typescriptlang.org/docs/handbook/2/basic-types.html) and react specific guide [here](https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components).
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Use of Any](#any)
|
|
8
|
+
1. [Use of Enum](#enum)
|
|
9
|
+
1. [Namespaces](#namespaces)
|
|
10
|
+
1. [Types vs Interfaces](#interfaces)
|
|
11
|
+
1. [Global types](#globals)
|
|
12
|
+
1. [React uses](#react)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Use of Any
|
|
16
|
+
<a name="any"></a>
|
|
17
|
+
|
|
18
|
+
Use of `any` type is generally discouraged because it defeats the purpose of using TypeScript. However, there are some cases where it is necessary to use `any` type. For example, when you are using a third-party library that does not have type definitions, you can use `any` type to get around the type checking. In this case, you should always try to create a type definition for the library and use it instead of `any`.
|
|
19
|
+
|
|
20
|
+
When writing generic functions that don't care about the argument type or internal structure prefer using `unknown`. This is a type-safe alternative to `any` that ensures someone using your function must perform some type of checking before using the argument.
|
|
21
|
+
|
|
22
|
+
**[⬆ back to top](#table-of-contents)**
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Use of Enum
|
|
26
|
+
<a name="enum"></a>
|
|
27
|
+
|
|
28
|
+
Using Enums is frowned upon when the same functionality can be accomplished with simple constants. In many cases single values need to be used in arrays or object types and converting enums to other structures becomes repetitive and cumbersome. Try using constants and only switch to enums when clear benefits are present.
|
|
29
|
+
|
|
30
|
+
**[⬆ back to top](#table-of-contents)**
|
|
31
|
+
|
|
32
|
+
## Namespaces
|
|
33
|
+
<a name="namespaces"></a>
|
|
34
|
+
|
|
35
|
+
Namespaces is a legacy feature that was introduced before there was a stable module system in place. Use ES Modules import/export statements instead.
|
|
36
|
+
|
|
37
|
+
**[⬆ back to top](#table-of-contents)**
|
|
38
|
+
|
|
39
|
+
## Types vs Interfaces
|
|
40
|
+
<a name="interfaces"></a>
|
|
41
|
+
|
|
42
|
+
Almost everything that can be accomplished with Interfaces can be accomplished with Types as well. We prefer using Types because the type declarations are more consistent and explicit this way. Only use an interface when you need the extensibility and you can't accomplish the same thing with simple types. More on the subject [here](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces).
|
|
43
|
+
|
|
44
|
+
**[⬆ back to top](#table-of-contents)**
|
|
45
|
+
|
|
46
|
+
## Global types
|
|
47
|
+
<a name="globals"></a>
|
|
48
|
+
|
|
49
|
+
Some libraries like React are accompanied with type definitions that inject global types. This is a legacy feature from the times when there was no stable module system in place. This is no longer necessary and should be avoided. Instead, import the types from the library and use them as you would any other type. This way there is a clear dependency between your code and the library.
|
|
50
|
+
|
|
51
|
+
**[⬆ back to top](#table-of-contents)**
|
|
52
|
+
|
|
53
|
+
## React uses
|
|
54
|
+
<a name="react"></a>
|
|
55
|
+
|
|
56
|
+
Using React with TypeScript comes with it's own set of challenges. It is beneficial to read [react guide](https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components) including the extended hints explanations.
|
|
57
|
+
|
|
58
|
+
As a rule of thumb it is best to not use special types unless absolutely necessary and let TypeScript infer the types instead. For defining a React component in TypeScript this works great:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// you can also inline the type declaration; eliminates naming the prop types, but looks repetitive
|
|
62
|
+
const App = ({ message }: { message: string }) => <div>{message}</div>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**[⬆ back to top](#table-of-contents)**
|
|
66
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Maxim Degterev <max@degterev.me> (https://max.degterev.me)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# eslint-config-entva-typescript
|
|
2
|
+
|
|
3
|
+
> Shareable entva typescript styleguide config for eslint.
|
|
4
|
+
|
|
5
|
+
Extends [`eslint-config-airbnb-typescript`](https://github.com/iamturns/eslint-config-airbnb-typescript).
|
|
6
|
+
|
|
7
|
+
A shareable config to enforce entva styleguide: https://github.com/entva/styleguide
|
|
8
|
+
|
|
9
|
+
To see the rules that this config uses, please read the [config itself](./index.js).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install eslint-config-entva-typescript --save-dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
If you've installed `eslint-config-entva-typescript` locally within your project, just set your `eslint` config to:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"extends": "eslint-config-entva-typescript"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## [MIT License](LICENSE)
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import baseConfig from 'eslint-config-entva-base';
|
|
2
|
+
import importPlugin from 'eslint-plugin-import';
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
|
5
|
+
import tsParser from '@typescript-eslint/parser';
|
|
6
|
+
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
...baseConfig,
|
|
10
|
+
{
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.test.ts',
|
|
13
|
+
'**/*.spec.ts',
|
|
14
|
+
],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.jest,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{js,mjs,cjs,ts}'],
|
|
23
|
+
plugins: {
|
|
24
|
+
import: importPlugin,
|
|
25
|
+
'@typescript-eslint': typescriptEslint,
|
|
26
|
+
'@stylistic/ts': stylisticTs,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
languageOptions: {
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.browser,
|
|
32
|
+
...globals.node,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
parser: tsParser,
|
|
36
|
+
ecmaVersion: 'latest',
|
|
37
|
+
sourceType: 'module',
|
|
38
|
+
|
|
39
|
+
parserOptions: {
|
|
40
|
+
parser: '@typescript-eslint/parser',
|
|
41
|
+
project: './tsconfig.json',
|
|
42
|
+
|
|
43
|
+
ecmaFeatures: {
|
|
44
|
+
generators: false,
|
|
45
|
+
objectLiteralDuplicateProperties: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
settings: {
|
|
51
|
+
'import/parsers': {
|
|
52
|
+
'@typescript-eslint/parser': ['.ts', '.d.ts'],
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
'import/resolver': {
|
|
56
|
+
node: {
|
|
57
|
+
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
'import/extensions': ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
|
62
|
+
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
|
|
63
|
+
'import/core-modules': [],
|
|
64
|
+
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
rules: {
|
|
68
|
+
'@stylistic/ts/member-delimiter-style': ['error', {
|
|
69
|
+
multiline: {
|
|
70
|
+
delimiter: 'comma',
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
singleline: {
|
|
74
|
+
delimiter: 'comma',
|
|
75
|
+
},
|
|
76
|
+
}],
|
|
77
|
+
|
|
78
|
+
'@typescript-eslint/no-explicit-any': ['error', {
|
|
79
|
+
ignoreRestArgs: true,
|
|
80
|
+
}],
|
|
81
|
+
|
|
82
|
+
'@typescript-eslint/naming-convention': ['error', {
|
|
83
|
+
selector: 'variable',
|
|
84
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
85
|
+
leadingUnderscore: 'allowSingleOrDouble',
|
|
86
|
+
}, {
|
|
87
|
+
selector: 'function',
|
|
88
|
+
format: ['camelCase', 'PascalCase'],
|
|
89
|
+
leadingUnderscore: 'allowSingleOrDouble',
|
|
90
|
+
}, {
|
|
91
|
+
selector: 'typeLike',
|
|
92
|
+
format: ['PascalCase'],
|
|
93
|
+
leadingUnderscore: 'allowSingleOrDouble',
|
|
94
|
+
}],
|
|
95
|
+
|
|
96
|
+
'@stylistic/ts/brace-style': ['error', '1tbs', {
|
|
97
|
+
allowSingleLine: true,
|
|
98
|
+
}],
|
|
99
|
+
|
|
100
|
+
'@stylistic/ts/comma-dangle': ['error', {
|
|
101
|
+
arrays: 'always-multiline',
|
|
102
|
+
objects: 'always-multiline',
|
|
103
|
+
imports: 'always-multiline',
|
|
104
|
+
exports: 'always-multiline',
|
|
105
|
+
functions: 'always-multiline',
|
|
106
|
+
enums: 'always-multiline',
|
|
107
|
+
generics: 'always-multiline',
|
|
108
|
+
tuples: 'always-multiline',
|
|
109
|
+
}],
|
|
110
|
+
|
|
111
|
+
'@stylistic/ts/comma-spacing': ['error', {
|
|
112
|
+
before: false,
|
|
113
|
+
after: true,
|
|
114
|
+
}],
|
|
115
|
+
|
|
116
|
+
'default-param-last': 'off',
|
|
117
|
+
'@typescript-eslint/default-param-last': ['error'],
|
|
118
|
+
|
|
119
|
+
'@typescript-eslint/dot-notation': ['error', {
|
|
120
|
+
allowKeywords: true,
|
|
121
|
+
allowPattern: '',
|
|
122
|
+
allowPrivateClassPropertyAccess: false,
|
|
123
|
+
allowProtectedClassPropertyAccess: false,
|
|
124
|
+
allowIndexSignaturePropertyAccess: false,
|
|
125
|
+
}],
|
|
126
|
+
|
|
127
|
+
'@stylistic/ts/func-call-spacing': ['error', 'never'],
|
|
128
|
+
|
|
129
|
+
'@stylistic/ts/indent': ['error', 2, {
|
|
130
|
+
SwitchCase: 1,
|
|
131
|
+
VariableDeclarator: 1,
|
|
132
|
+
outerIIFEBody: 1,
|
|
133
|
+
|
|
134
|
+
FunctionDeclaration: {
|
|
135
|
+
parameters: 1,
|
|
136
|
+
body: 1,
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
FunctionExpression: {
|
|
140
|
+
parameters: 1,
|
|
141
|
+
body: 1,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
CallExpression: {
|
|
145
|
+
arguments: 1,
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
ArrayExpression: 1,
|
|
149
|
+
ObjectExpression: 1,
|
|
150
|
+
ImportDeclaration: 1,
|
|
151
|
+
flatTernaryExpressions: false,
|
|
152
|
+
|
|
153
|
+
ignoredNodes: [
|
|
154
|
+
'JSXElement',
|
|
155
|
+
'JSXElement > *',
|
|
156
|
+
'JSXAttribute',
|
|
157
|
+
'JSXIdentifier',
|
|
158
|
+
'JSXNamespacedName',
|
|
159
|
+
'JSXMemberExpression',
|
|
160
|
+
'JSXSpreadAttribute',
|
|
161
|
+
'JSXExpressionContainer',
|
|
162
|
+
'JSXOpeningElement',
|
|
163
|
+
'JSXClosingElement',
|
|
164
|
+
'JSXFragment',
|
|
165
|
+
'JSXOpeningFragment',
|
|
166
|
+
'JSXClosingFragment',
|
|
167
|
+
'JSXText',
|
|
168
|
+
'JSXEmptyExpression',
|
|
169
|
+
'JSXSpreadChild',
|
|
170
|
+
],
|
|
171
|
+
|
|
172
|
+
ignoreComments: false,
|
|
173
|
+
offsetTernaryExpressions: false,
|
|
174
|
+
}],
|
|
175
|
+
|
|
176
|
+
'@stylistic/ts/keyword-spacing': ['error', {
|
|
177
|
+
before: true,
|
|
178
|
+
after: true,
|
|
179
|
+
|
|
180
|
+
overrides: {
|
|
181
|
+
return: {
|
|
182
|
+
after: true,
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
throw: {
|
|
186
|
+
after: true,
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
case: {
|
|
190
|
+
after: true,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
}],
|
|
194
|
+
|
|
195
|
+
'@stylistic/ts/lines-between-class-members': ['error', 'always', {
|
|
196
|
+
exceptAfterSingleLine: false,
|
|
197
|
+
exceptAfterOverload: true,
|
|
198
|
+
}],
|
|
199
|
+
|
|
200
|
+
'@typescript-eslint/no-array-constructor': ['error'],
|
|
201
|
+
'@typescript-eslint/no-dupe-class-members': ['error'],
|
|
202
|
+
|
|
203
|
+
'@typescript-eslint/no-empty-function': ['error', {
|
|
204
|
+
allow: ['arrowFunctions', 'functions', 'methods'],
|
|
205
|
+
}],
|
|
206
|
+
|
|
207
|
+
'@typescript-eslint/no-extra-parens': ['off', 'all', {
|
|
208
|
+
conditionalAssign: true,
|
|
209
|
+
nestedBinaryExpressions: false,
|
|
210
|
+
returnAssign: false,
|
|
211
|
+
ignoreJSX: 'all',
|
|
212
|
+
enforceForArrowConditionals: false,
|
|
213
|
+
}],
|
|
214
|
+
|
|
215
|
+
'@stylistic/ts/no-extra-semi': ['error'],
|
|
216
|
+
'@typescript-eslint/no-implied-eval': ['error'],
|
|
217
|
+
'@typescript-eslint/no-loss-of-precision': ['error'],
|
|
218
|
+
'@typescript-eslint/no-loop-func': ['error'],
|
|
219
|
+
|
|
220
|
+
'@typescript-eslint/no-magic-numbers': ['off', {
|
|
221
|
+
ignore: [],
|
|
222
|
+
ignoreArrayIndexes: true,
|
|
223
|
+
enforceConst: true,
|
|
224
|
+
detectObjects: false,
|
|
225
|
+
}],
|
|
226
|
+
|
|
227
|
+
'@typescript-eslint/no-redeclare': ['error'],
|
|
228
|
+
'@stylistic/ts/space-before-blocks': ['error'],
|
|
229
|
+
|
|
230
|
+
'no-shadow': 'off',
|
|
231
|
+
'@typescript-eslint/no-shadow': ['error'],
|
|
232
|
+
|
|
233
|
+
'@typescript-eslint/no-unused-expressions': ['error', {
|
|
234
|
+
allowShortCircuit: false,
|
|
235
|
+
allowTernary: false,
|
|
236
|
+
allowTaggedTemplates: false,
|
|
237
|
+
enforceForJSX: false,
|
|
238
|
+
}],
|
|
239
|
+
|
|
240
|
+
'no-unused-vars': 'off',
|
|
241
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
242
|
+
vars: 'all',
|
|
243
|
+
args: 'after-used',
|
|
244
|
+
ignoreRestSiblings: true,
|
|
245
|
+
caughtErrors: 'none',
|
|
246
|
+
}],
|
|
247
|
+
|
|
248
|
+
'@typescript-eslint/no-use-before-define': ['error', {
|
|
249
|
+
functions: true,
|
|
250
|
+
classes: true,
|
|
251
|
+
variables: true,
|
|
252
|
+
}],
|
|
253
|
+
|
|
254
|
+
'@typescript-eslint/no-useless-constructor': ['error'],
|
|
255
|
+
|
|
256
|
+
'@stylistic/ts/quotes': ['error', 'single', {
|
|
257
|
+
avoidEscape: true,
|
|
258
|
+
}],
|
|
259
|
+
|
|
260
|
+
'@stylistic/ts/space-before-function-paren': ['error', {
|
|
261
|
+
anonymous: 'always',
|
|
262
|
+
named: 'never',
|
|
263
|
+
asyncArrow: 'always',
|
|
264
|
+
}],
|
|
265
|
+
|
|
266
|
+
'@typescript-eslint/require-await': ['off'],
|
|
267
|
+
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
|
|
268
|
+
'@stylistic/ts/space-infix-ops': ['error'],
|
|
269
|
+
'@stylistic/ts/object-curly-spacing': ['error', 'always'],
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
];
|