eslint-config-opencover 3.0.5
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/LICENSE +9 -0
- package/README.md +80 -0
- package/dist/globs.d.ts +6 -0
- package/dist/globs.d.ts.map +1 -0
- package/dist/globs.js +23 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +164 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +36 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 OpenCover
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# eslint-config-opencover
|
|
2
|
+
|
|
3
|
+
ESLint flat config for OpenCover's TypeScript coding style.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D eslint-config-opencover eslint typescript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### TypeScript project
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// eslint.config.mjs
|
|
17
|
+
import opencover from 'eslint-config-opencover';
|
|
18
|
+
|
|
19
|
+
export default [...opencover];
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### React project
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
// eslint.config.mjs
|
|
26
|
+
import opencover from 'eslint-config-opencover';
|
|
27
|
+
import react from 'eslint-config-opencover/react';
|
|
28
|
+
|
|
29
|
+
export default [...opencover, ...react];
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Next.js project
|
|
33
|
+
|
|
34
|
+
Install Next.js ESLint config alongside this package:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pnpm add -D eslint-config-next
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// eslint.config.mjs
|
|
42
|
+
import opencover from 'eslint-config-opencover';
|
|
43
|
+
import nextVitals from 'eslint-config-next/core-web-vitals';
|
|
44
|
+
import nextTs from 'eslint-config-next/typescript';
|
|
45
|
+
|
|
46
|
+
export default [...nextVitals, ...nextTs, ...opencover];
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
OpenCover's config should come **last** so its rules take precedence.
|
|
50
|
+
|
|
51
|
+
## Overriding rules
|
|
52
|
+
|
|
53
|
+
Each config object in the exported array has a `name` property for debugging (for example in ESLint's config inspector), but flat config overrides are matched by `files`/`ignores`, not by `name`. To override TypeScript-specific rules, add a later config object that matches the same files:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// eslint.config.mjs
|
|
57
|
+
import opencover from 'eslint-config-opencover';
|
|
58
|
+
|
|
59
|
+
export default [
|
|
60
|
+
...opencover,
|
|
61
|
+
{
|
|
62
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
63
|
+
rules: {
|
|
64
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Later matching config objects override earlier ones for those files.
|
|
71
|
+
|
|
72
|
+
Available config names:
|
|
73
|
+
|
|
74
|
+
| Name | Description |
|
|
75
|
+
| ---------------------- | ------------------------------------ |
|
|
76
|
+
| `opencover` | Base rules (stylistic, imports, etc) |
|
|
77
|
+
| `opencover/gitignore` | Ignores files from `.gitignore` |
|
|
78
|
+
| `opencover/typescript` | TypeScript-specific rules |
|
|
79
|
+
| `opencover/test` | Test file rules (vitest) |
|
|
80
|
+
| `opencover/react` | React-specific TSX rules |
|
package/dist/globs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globs.d.ts","sourceRoot":"","sources":["../src/globs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAiC,CAAC;AAEtD,eAAO,MAAM,QAAQ,UAAe,CAAC;AAErC,eAAO,MAAM,QAAQ,UAAe,CAAC;AAErC,eAAO,MAAM,SAAS,UAA+F,CAAC;AAEtH,eAAO,MAAM,YAAY,UAkBxB,CAAC"}
|
package/dist/globs.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const GLOB_TS = ['**/*.?([cm])ts', '**/*.tsx'];
|
|
2
|
+
export const GLOB_JSX = ['**/*.jsx'];
|
|
3
|
+
export const GLOB_TSX = ['**/*.tsx'];
|
|
4
|
+
export const GLOB_TEST = ['**/*.spec.?([cm])[jt]s', '**/*.spec.[jt]sx', '**/*.test.?([cm])[jt]s', '**/*.test.[jt]sx'];
|
|
5
|
+
export const GLOB_EXCLUDE = [
|
|
6
|
+
'**/dist',
|
|
7
|
+
'**/.dist',
|
|
8
|
+
'**/coverage',
|
|
9
|
+
'**/build',
|
|
10
|
+
'**/.cache',
|
|
11
|
+
'**/.nuxt',
|
|
12
|
+
'**/.next',
|
|
13
|
+
'**/.vercel',
|
|
14
|
+
'**/.changeset',
|
|
15
|
+
'**/.idea',
|
|
16
|
+
'**/.output',
|
|
17
|
+
'**/.vitepress/cache',
|
|
18
|
+
'**/.vscode',
|
|
19
|
+
'**/__snapshots__',
|
|
20
|
+
'**/*.min.*',
|
|
21
|
+
'**/__fixtures__',
|
|
22
|
+
'**/fixtures/**',
|
|
23
|
+
];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EA0J1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import stylisticPlugin from '@stylistic/eslint-plugin';
|
|
3
|
+
import vitest from '@vitest/eslint-plugin';
|
|
4
|
+
import gitignore from 'eslint-config-flat-gitignore';
|
|
5
|
+
import { globalIgnores } from 'eslint/config';
|
|
6
|
+
import { flatConfigs as importPlugin } from 'eslint-plugin-import-x';
|
|
7
|
+
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
8
|
+
import { configs as tseslint } from 'typescript-eslint';
|
|
9
|
+
import prettier from 'eslint-config-prettier/flat';
|
|
10
|
+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
11
|
+
import { GLOB_EXCLUDE, GLOB_TEST, GLOB_TS } from './globs.js';
|
|
12
|
+
const config = [
|
|
13
|
+
eslint.configs.recommended,
|
|
14
|
+
stylisticPlugin.configs.recommended,
|
|
15
|
+
importPlugin.recommended,
|
|
16
|
+
unicornPlugin.configs.recommended,
|
|
17
|
+
{
|
|
18
|
+
files: GLOB_TEST,
|
|
19
|
+
...vitest.configs.recommended,
|
|
20
|
+
},
|
|
21
|
+
...tseslint.strictTypeChecked.map((config) => ({
|
|
22
|
+
files: GLOB_TS,
|
|
23
|
+
...config,
|
|
24
|
+
})),
|
|
25
|
+
{
|
|
26
|
+
files: GLOB_TS,
|
|
27
|
+
...importPlugin.typescript,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
files: GLOB_TS,
|
|
31
|
+
settings: {
|
|
32
|
+
'import-x/resolver-next': [createTypeScriptImportResolver()],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'opencover',
|
|
37
|
+
rules: {
|
|
38
|
+
'capitalized-comments': [
|
|
39
|
+
'warn',
|
|
40
|
+
'always',
|
|
41
|
+
{
|
|
42
|
+
ignoreConsecutiveComments: true,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
46
|
+
'no-restricted-syntax': [
|
|
47
|
+
'error',
|
|
48
|
+
{
|
|
49
|
+
selector: 'TSEnumDeclaration',
|
|
50
|
+
message: 'Enums are not allowed.',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
'no-unneeded-ternary': 'error',
|
|
54
|
+
'no-use-before-define': 'error',
|
|
55
|
+
'@stylistic/padding-line-between-statements': [
|
|
56
|
+
'error',
|
|
57
|
+
{ blankLine: 'always', prev: '*', next: ['function', 'class', 'export'] },
|
|
58
|
+
{ blankLine: 'always', prev: ['function', 'class', 'export'], next: '*' },
|
|
59
|
+
{ blankLine: 'always', prev: '*', next: 'if' },
|
|
60
|
+
{ blankLine: 'always', prev: 'block-like', next: 'if' },
|
|
61
|
+
{ blankLine: 'always', prev: 'if', next: '*' },
|
|
62
|
+
],
|
|
63
|
+
'import-x/order': [
|
|
64
|
+
'warn',
|
|
65
|
+
{
|
|
66
|
+
pathGroups: [
|
|
67
|
+
{
|
|
68
|
+
pattern: '@/**',
|
|
69
|
+
group: 'parent',
|
|
70
|
+
position: 'before',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
pattern: '@tests/**',
|
|
74
|
+
group: 'parent',
|
|
75
|
+
position: 'before',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
pattern: '@data/**',
|
|
79
|
+
group: 'parent',
|
|
80
|
+
position: 'before',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
'import-x/no-unresolved': 'off',
|
|
86
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
87
|
+
'unicorn/no-array-for-each': 'off',
|
|
88
|
+
'unicorn/no-array-reduce': 'off',
|
|
89
|
+
'unicorn/no-null': 'off',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'opencover/typescript',
|
|
94
|
+
files: GLOB_TS,
|
|
95
|
+
languageOptions: {
|
|
96
|
+
parserOptions: {
|
|
97
|
+
projectService: true,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
rules: {
|
|
101
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
102
|
+
'error',
|
|
103
|
+
{ prefer: 'type-imports', disallowTypeAnnotations: false },
|
|
104
|
+
],
|
|
105
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
106
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
107
|
+
'error',
|
|
108
|
+
{
|
|
109
|
+
accessibility: 'explicit',
|
|
110
|
+
overrides: {
|
|
111
|
+
constructors: 'off',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
116
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
117
|
+
'@typescript-eslint/no-unused-vars': [
|
|
118
|
+
'error',
|
|
119
|
+
{
|
|
120
|
+
argsIgnorePattern: '^_',
|
|
121
|
+
varsIgnorePattern: '^_',
|
|
122
|
+
destructuredArrayIgnorePattern: '^_',
|
|
123
|
+
caughtErrorsIgnorePattern: '^_',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
'no-use-before-define': 'off',
|
|
127
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
128
|
+
'@typescript-eslint/no-restricted-types': [
|
|
129
|
+
'error',
|
|
130
|
+
{
|
|
131
|
+
types: {
|
|
132
|
+
Map: { message: 'Map is not allowed. Use Object instead.' },
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
137
|
+
'error',
|
|
138
|
+
{
|
|
139
|
+
ignoreConditionalTests: true,
|
|
140
|
+
ignoreIfStatements: true,
|
|
141
|
+
ignorePrimitives: {
|
|
142
|
+
boolean: true,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'opencover/test',
|
|
150
|
+
files: GLOB_TEST,
|
|
151
|
+
rules: {
|
|
152
|
+
'vitest/padding-around-before-all-blocks': 'error',
|
|
153
|
+
'vitest/padding-around-describe-blocks': 'error',
|
|
154
|
+
'vitest/padding-around-before-each-blocks': 'error',
|
|
155
|
+
'vitest/padding-around-after-all-blocks': 'error',
|
|
156
|
+
'vitest/padding-around-after-each-blocks': 'error',
|
|
157
|
+
'vitest/padding-around-test-blocks': 'error',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
prettier,
|
|
161
|
+
globalIgnores(GLOB_EXCLUDE),
|
|
162
|
+
gitignore({ name: 'opencover/gitignore', strict: false }),
|
|
163
|
+
];
|
|
164
|
+
export default config;
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,QAAA,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EA+B/B,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import react from 'eslint-plugin-react';
|
|
2
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
|
+
import { GLOB_JSX, GLOB_TSX } from './globs.js';
|
|
4
|
+
const reactConfig = [
|
|
5
|
+
{
|
|
6
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
7
|
+
settings: {
|
|
8
|
+
react: {
|
|
9
|
+
version: 'detect',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
react.configs.flat.recommended,
|
|
14
|
+
react.configs.flat['jsx-runtime'],
|
|
15
|
+
reactHooks.configs.flat.recommended,
|
|
16
|
+
{
|
|
17
|
+
name: 'opencover/react',
|
|
18
|
+
files: GLOB_TSX,
|
|
19
|
+
languageOptions: {
|
|
20
|
+
parserOptions: {
|
|
21
|
+
projectService: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
'@typescript-eslint/no-misused-promises': [
|
|
26
|
+
'error',
|
|
27
|
+
{
|
|
28
|
+
checksVoidReturn: {
|
|
29
|
+
attributes: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
export default reactConfig;
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-config-opencover",
|
|
3
|
+
"version": "3.0.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenCover specific linting rules for ESLint",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "OpenCover",
|
|
8
|
+
"email": "team@opencover.com",
|
|
9
|
+
"url": "https://opencover.com"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"eslint",
|
|
13
|
+
"eslintconfig",
|
|
14
|
+
"eslint-config",
|
|
15
|
+
"opencover"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/OpenCoverDeFi/eslint-config-opencover.git"
|
|
21
|
+
},
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./react": {
|
|
30
|
+
"types": "./dist/react.d.ts",
|
|
31
|
+
"default": "./dist/react.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
39
|
+
"format": "eslint --fix . && prettier --write .",
|
|
40
|
+
"lint": "eslint --max-warnings=0 . && prettier --check .",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"changeset": "changeset",
|
|
43
|
+
"changeset:version": "changeset version",
|
|
44
|
+
"changeset:release": "pnpm build && npm publish --verbose --access public",
|
|
45
|
+
"prepare": "husky",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:coverage": "vitest run --coverage"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@eslint/js": "^10.0.1",
|
|
51
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
52
|
+
"@vitest/eslint-plugin": "^1.6.9",
|
|
53
|
+
"eslint-config-flat-gitignore": "^2.2.1",
|
|
54
|
+
"eslint-config-prettier": "^10.1.8",
|
|
55
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
56
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
57
|
+
"eslint-plugin-react": "^7.37.5",
|
|
58
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
59
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
60
|
+
"typescript-eslint": "^8.56.1"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"eslint": "^10.0.0",
|
|
64
|
+
"typescript": "^5.9.3"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
68
|
+
"@changesets/cli": "^2.30.0",
|
|
69
|
+
"@types/node": "^22.19.15",
|
|
70
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
71
|
+
"eslint": "^10.0.2",
|
|
72
|
+
"husky": "^9.1.7",
|
|
73
|
+
"jiti": "^2.6.1",
|
|
74
|
+
"knip": "^5.85.0",
|
|
75
|
+
"lint-staged": "^16.3.2",
|
|
76
|
+
"prettier": "^3.8.1",
|
|
77
|
+
"tsc-alias": "^1.8.16",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"vitest": "^4.0.18"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=22",
|
|
83
|
+
"pnpm": ">=10.28.2"
|
|
84
|
+
},
|
|
85
|
+
"lint-staged": {
|
|
86
|
+
"**/*.{ts,tsx,js,jsx,mjs}": [
|
|
87
|
+
"eslint --cache --max-warnings=0 --fix",
|
|
88
|
+
"prettier --cache --write"
|
|
89
|
+
],
|
|
90
|
+
"*.{json,yml,yaml,md}": "prettier --cache --write",
|
|
91
|
+
".prettierrc": "prettier --cache --write"
|
|
92
|
+
},
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"registry": "https://registry.npmjs.org/",
|
|
95
|
+
"access": "public"
|
|
96
|
+
},
|
|
97
|
+
"packageManager": "pnpm@10.30.3"
|
|
98
|
+
}
|