@api3/commons 0.1.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/LICENSE +21 -0
- package/README.md +92 -0
- package/dist/eslint/internal.d.ts +15 -0
- package/dist/eslint/internal.d.ts.map +1 -0
- package/dist/eslint/internal.js +24 -0
- package/dist/eslint/internal.js.map +1 -0
- package/dist/eslint/jest.d.ts +28 -0
- package/dist/eslint/jest.d.ts.map +1 -0
- package/dist/eslint/jest.js +37 -0
- package/dist/eslint/jest.js.map +1 -0
- package/dist/eslint/next-js.d.ts +27 -0
- package/dist/eslint/next-js.d.ts.map +1 -0
- package/dist/eslint/next-js.js +33 -0
- package/dist/eslint/next-js.js.map +1 -0
- package/dist/eslint/react.d.ts +91 -0
- package/dist/eslint/react.d.ts.map +1 -0
- package/dist/eslint/react.js +86 -0
- package/dist/eslint/react.js.map +1 -0
- package/dist/eslint/universal.d.ts +177 -0
- package/dist/eslint/universal.d.ts.map +1 -0
- package/dist/eslint/universal.js +220 -0
- package/dist/eslint/universal.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/index.d.ts +34 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +85 -0
- package/dist/logger/index.js.map +1 -0
- package/package.json +70 -0
- package/src/eslint/README.md +92 -0
- package/src/eslint/internal.js +24 -0
- package/src/eslint/jest.js +35 -0
- package/src/eslint/next-js.js +31 -0
- package/src/eslint/react.js +89 -0
- package/src/eslint/universal.js +227 -0
- package/src/index.ts +2 -0
- package/src/logger/README.md +44 -0
- package/src/logger/index.ts +110 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 API3
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# commons
|
|
2
|
+
|
|
3
|
+
> Common utilities, modules and configurations used in API3 projects.
|
|
4
|
+
|
|
5
|
+
The commons library is meant to stop "reinventing the wheel". It holds the canonical implementations that can be
|
|
6
|
+
imported in other packages. This way we ensure that all package use the same logic, simplify bug fixes and avoid code
|
|
7
|
+
duplication.
|
|
8
|
+
|
|
9
|
+
The commons library is a single repo and a collection of multiple modules:
|
|
10
|
+
|
|
11
|
+
- [`eslint`](./src/eslint/README.md) - The configrations for ESLint.
|
|
12
|
+
|
|
13
|
+
Read the documentation of each module for more information.
|
|
14
|
+
|
|
15
|
+
## Related repositories
|
|
16
|
+
|
|
17
|
+
- [promise-utils](https://github.com/api3dao/promise-utils)
|
|
18
|
+
- [ois](https://github.com/api3dao/ois)
|
|
19
|
+
- [chains](https://github.com/api3dao/chains)
|
|
20
|
+
- [contracts](https://github.com/api3dao/contracts)
|
|
21
|
+
|
|
22
|
+
## Getting started
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# Feel free to use your favorite package manager
|
|
26
|
+
pnpm add @api3/commons
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Read the documentation of each module how to use it in the project.
|
|
30
|
+
|
|
31
|
+
### Import paths
|
|
32
|
+
|
|
33
|
+
We want the consumers to import common utilities like this:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { createLogger } from '@api3/commons/logger';
|
|
37
|
+
// and not like this
|
|
38
|
+
import { createLogger } from '@api3/commons/dist/logger';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This is done via `package.json` field called [exports](https://nodejs.org/api/packages.html#package-entry-points). This
|
|
42
|
+
field works for both CJS and ESM starting from Node version 12. In order for TS to support this, you need to make sure
|
|
43
|
+
you use `moduleResolution` and `module` set to `Node16`:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"compilerOptions": {
|
|
48
|
+
"module": "Node16",
|
|
49
|
+
"moduleResolution": "Node16"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Release
|
|
55
|
+
|
|
56
|
+
To release a new version follow these steps:
|
|
57
|
+
|
|
58
|
+
1. `git checkout main` - Always publish from `main` branch. Also, ensure that the working directory is clean (has no
|
|
59
|
+
uncommitted changes).
|
|
60
|
+
2. `pnpm version [major|minor|patch]` - Choose the right version bump. This will bump the version, create a git tag and
|
|
61
|
+
commit it.
|
|
62
|
+
3. `pnpm publish --access public` - Publish the new version to NPM.
|
|
63
|
+
4. `git push --follow-tags` - Push the tagged commit upstream.
|
|
64
|
+
|
|
65
|
+
## Development notes
|
|
66
|
+
|
|
67
|
+
### Adding new common utility
|
|
68
|
+
|
|
69
|
+
1. Create a new directory in `src` with the name of the utility.
|
|
70
|
+
2. Create `index.ts` file in the directory. This file will be the entry point for the utility.
|
|
71
|
+
3. Add the new utility to `package.json` `exports` field. See
|
|
72
|
+
[exports](https://nodejs.org/api/packages.html#package-entry-points) for more information.
|
|
73
|
+
4. Create a `README.md` with documentation.
|
|
74
|
+
|
|
75
|
+
### Working with verdaccio
|
|
76
|
+
|
|
77
|
+
The common pattern is to move some part of implementation to commons and then use it in some other repo. It is valuable
|
|
78
|
+
to see whether nothing broke in the process (before publishing the package). You can use
|
|
79
|
+
[verdaccio](https://verdaccio.org/).
|
|
80
|
+
|
|
81
|
+
1. Start verdaccio (either as a docker service or directly on host machine). See:
|
|
82
|
+
https://verdaccio.org/docs/installation.
|
|
83
|
+
2. Implement and commit your changes. You should have a clean working tree.
|
|
84
|
+
3. `pnpm version minor --no-git-tag-version` - Will bump the `package.json` version. Feel free to replace `minor` with a
|
|
85
|
+
`path` or `major` if necessary.
|
|
86
|
+
4. `pnpm publish --access public --registry http://localhost:4873 --no-git-checks` - Will do the publishing to the local
|
|
87
|
+
registry. It will disable git checks (which ensure that the working tree is clean).
|
|
88
|
+
5. You can now install the package in the target repository. Use
|
|
89
|
+
`pnpm add @api3/commons --registry http://localhost:4873`.
|
|
90
|
+
|
|
91
|
+
Tip: To unpublish a package from the local registry, you can just remove verdaccio storage. On my machine it can be done
|
|
92
|
+
via `rm -rf $HOME/.local/share/verdaccio/storage`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export namespace universalRestrictedImportsConfig {
|
|
2
|
+
let patterns: {
|
|
3
|
+
group: string[];
|
|
4
|
+
message: string;
|
|
5
|
+
}[];
|
|
6
|
+
}
|
|
7
|
+
export const universalImportOrderConfig: {
|
|
8
|
+
groups: string[];
|
|
9
|
+
'newlines-between': string;
|
|
10
|
+
alphabetize: {
|
|
11
|
+
order: string;
|
|
12
|
+
caseInsensitive: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/eslint/internal.js"],"names":[],"mappings":";;;;;;AAUA;;;;;;;EAQE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const universalRestrictedImportsConfig = {
|
|
3
|
+
patterns: [
|
|
4
|
+
{
|
|
5
|
+
group: ['date-fns/*'],
|
|
6
|
+
// The date-fns library is tree-shakeable and it's more convenient to use named imports.
|
|
7
|
+
message: "Please use named imports from 'date-fns'.",
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
const universalImportOrderConfig = {
|
|
12
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
|
|
13
|
+
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
14
|
+
'newlines-between': 'always',
|
|
15
|
+
alphabetize: {
|
|
16
|
+
order: 'asc',
|
|
17
|
+
caseInsensitive: true,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
module.exports = {
|
|
21
|
+
universalRestrictedImportsConfig,
|
|
22
|
+
universalImportOrderConfig,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/eslint/internal.js"],"names":[],"mappings":";AAAA,MAAM,gCAAgC,GAAG;IACvC,QAAQ,EAAE;QACR;YACE,KAAK,EAAE,CAAC,YAAY,CAAC;YACrB,wFAAwF;YACxF,OAAO,EAAE,2CAA2C;SACrD;KACF;CACF,CAAC;AAEF,MAAM,0BAA0B,GAAG;IACjC,oFAAoF;IACpF,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;IACzE,kBAAkB,EAAE,QAAQ;IAC5B,WAAW,EAAE;QACX,KAAK,EAAE,KAAK;QACZ,eAAe,EAAE,IAAI;KACtB;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG;IACf,gCAAgC;IAChC,0BAA0B;CAC3B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export let parser: string;
|
|
2
|
+
export namespace parserOptions {
|
|
3
|
+
let ecmaVersion: number;
|
|
4
|
+
let sourceType: string;
|
|
5
|
+
}
|
|
6
|
+
export namespace env {
|
|
7
|
+
let node: boolean;
|
|
8
|
+
let browser: boolean;
|
|
9
|
+
}
|
|
10
|
+
export let overrides: {
|
|
11
|
+
files: string[];
|
|
12
|
+
env: {
|
|
13
|
+
jest: boolean;
|
|
14
|
+
};
|
|
15
|
+
plugins: string[];
|
|
16
|
+
extends: string[];
|
|
17
|
+
rules: {
|
|
18
|
+
'jest/prefer-expect-assertions': string;
|
|
19
|
+
'jest/prefer-each': string;
|
|
20
|
+
'jest/require-top-level-describe': string;
|
|
21
|
+
'jest/max-expects': string;
|
|
22
|
+
'jest/valid-title': string;
|
|
23
|
+
'jest/no-hooks': (string | {
|
|
24
|
+
allow: string[];
|
|
25
|
+
})[];
|
|
26
|
+
};
|
|
27
|
+
}[];
|
|
28
|
+
//# sourceMappingURL=jest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../../src/eslint/jest.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
parserOptions: {
|
|
5
|
+
ecmaVersion: 2022,
|
|
6
|
+
sourceType: 'module', // Enable the use of ES6 import/export syntax.
|
|
7
|
+
},
|
|
8
|
+
env: {
|
|
9
|
+
node: true,
|
|
10
|
+
browser: true,
|
|
11
|
+
},
|
|
12
|
+
// Configuration for specific files is done under 'overrides'.
|
|
13
|
+
overrides: [
|
|
14
|
+
{
|
|
15
|
+
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.test.js', '**/*.test.jsx'],
|
|
16
|
+
env: {
|
|
17
|
+
jest: true,
|
|
18
|
+
},
|
|
19
|
+
plugins: ['jest'],
|
|
20
|
+
extends: ['plugin:jest/all', 'plugin:jest-formatting/recommended'],
|
|
21
|
+
rules: {
|
|
22
|
+
'jest/prefer-expect-assertions': 'off',
|
|
23
|
+
'jest/prefer-each': 'off',
|
|
24
|
+
'jest/require-top-level-describe': 'off',
|
|
25
|
+
'jest/max-expects': 'off',
|
|
26
|
+
'jest/valid-title': 'off',
|
|
27
|
+
'jest/no-hooks': [
|
|
28
|
+
'error',
|
|
29
|
+
{
|
|
30
|
+
allow: ['afterEach', 'afterAll'],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=jest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.js","sourceRoot":"","sources":["../../src/eslint/jest.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ,EAAE,8CAA8C;KACrE;IACD,GAAG,EAAE;QACH,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;KACd;IACD,8DAA8D;IAC9D,SAAS,EAAE;QACT;YACE,KAAK,EAAE,CAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,CAAC;YACzE,GAAG,EAAE;gBACH,IAAI,EAAE,IAAI;aACX;YACD,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,OAAO,EAAE,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;YAClE,KAAK,EAAE;gBACL,+BAA+B,EAAE,KAAK;gBACtC,kBAAkB,EAAE,KAAK;gBACzB,iCAAiC,EAAE,KAAK;gBACxC,kBAAkB,EAAE,KAAK;gBACzB,kBAAkB,EAAE,KAAK;gBACzB,eAAe,EAAE;oBACf,OAAO;oBACP;wBACE,KAAK,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;qBACjC;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare let parser: string;
|
|
2
|
+
export declare namespace parserOptions {
|
|
3
|
+
let ecmaVersion: number;
|
|
4
|
+
namespace ecmaFeatures {
|
|
5
|
+
let jsx: boolean;
|
|
6
|
+
}
|
|
7
|
+
let sourceType: string;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace settings {
|
|
10
|
+
namespace react {
|
|
11
|
+
let version: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare namespace env {
|
|
15
|
+
let node: boolean;
|
|
16
|
+
let browser: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare let _extends: string[];
|
|
19
|
+
export { _extends as extends };
|
|
20
|
+
export declare let overrides: {
|
|
21
|
+
files: string[];
|
|
22
|
+
rules: {
|
|
23
|
+
'import/no-default-export': string;
|
|
24
|
+
'import/prefer-default-export': string;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
//# sourceMappingURL=next-js.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-js.d.ts","sourceRoot":"","sources":["../../src/eslint/next-js.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
parserOptions: {
|
|
5
|
+
ecmaVersion: 2022,
|
|
6
|
+
ecmaFeatures: {
|
|
7
|
+
jsx: true, // Support JSX syntax.
|
|
8
|
+
},
|
|
9
|
+
sourceType: 'module', // Enable ES6 import/export syntax.
|
|
10
|
+
},
|
|
11
|
+
settings: {
|
|
12
|
+
react: {
|
|
13
|
+
version: 'detect',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
env: {
|
|
17
|
+
node: true,
|
|
18
|
+
browser: true,
|
|
19
|
+
},
|
|
20
|
+
extends: [
|
|
21
|
+
'next/core-web-vitals', // Enforce Next.js performance best practices. See: https://nextjs.org/docs/basic-features/eslint.
|
|
22
|
+
],
|
|
23
|
+
overrides: [
|
|
24
|
+
{
|
|
25
|
+
files: ['pages/**/*'],
|
|
26
|
+
rules: {
|
|
27
|
+
'import/no-default-export': 'off',
|
|
28
|
+
'import/prefer-default-export': 'error', // Next.js expects default exports in the pages directory.
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=next-js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-js.js","sourceRoot":"","sources":["../../src/eslint/next-js.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,YAAY,EAAE;YACZ,GAAG,EAAE,IAAI,EAAE,sBAAsB;SAClC;QACD,UAAU,EAAE,QAAQ,EAAE,mCAAmC;KAC1D;IACD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE,QAAQ;SAClB;KACF;IACD,GAAG,EAAE;QACH,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACP,sBAAsB,EAAE,kGAAkG;KAC3H;IACD,SAAS,EAAE;QACT;YACE,KAAK,EAAE,CAAC,YAAY,CAAC;YACrB,KAAK,EAAE;gBACL,0BAA0B,EAAE,KAAK;gBACjC,8BAA8B,EAAE,OAAO,EAAE,0DAA0D;aACpG;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare let parser: string;
|
|
2
|
+
export declare namespace parserOptions {
|
|
3
|
+
let ecmaVersion: number;
|
|
4
|
+
namespace ecmaFeatures {
|
|
5
|
+
let jsx: boolean;
|
|
6
|
+
}
|
|
7
|
+
let sourceType: string;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace settings {
|
|
10
|
+
namespace react {
|
|
11
|
+
let version: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare namespace env {
|
|
15
|
+
let node: boolean;
|
|
16
|
+
let browser: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare let _extends: string[];
|
|
19
|
+
export { _extends as extends };
|
|
20
|
+
export declare let plugins: string[];
|
|
21
|
+
export declare let rules: {
|
|
22
|
+
'import/order': (string | ({
|
|
23
|
+
groups: string[];
|
|
24
|
+
'newlines-between': string;
|
|
25
|
+
alphabetize: {
|
|
26
|
+
order: string;
|
|
27
|
+
caseInsensitive: boolean;
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
30
|
+
pathGroups: {
|
|
31
|
+
pattern: string;
|
|
32
|
+
group: string;
|
|
33
|
+
position: string;
|
|
34
|
+
}[];
|
|
35
|
+
}))[];
|
|
36
|
+
'react/destructuring-assignment': (string | {
|
|
37
|
+
destructureInSignature: string;
|
|
38
|
+
})[];
|
|
39
|
+
'react/forbid-component-props': (string | {
|
|
40
|
+
forbid: never[];
|
|
41
|
+
})[];
|
|
42
|
+
'react/forbid-dom-props': (string | {
|
|
43
|
+
forbid: never[];
|
|
44
|
+
})[];
|
|
45
|
+
'react/function-component-definition': string;
|
|
46
|
+
'react/jsx-curly-brace-presence': (string | {
|
|
47
|
+
props: string;
|
|
48
|
+
children: string;
|
|
49
|
+
propElementValues: string;
|
|
50
|
+
})[];
|
|
51
|
+
'react/jsx-curly-newline': string;
|
|
52
|
+
'react/jsx-filename-extension': string;
|
|
53
|
+
'react/jsx-handler-names': string;
|
|
54
|
+
'react/jsx-indent': string;
|
|
55
|
+
'react/jsx-indent-props': string;
|
|
56
|
+
'react/jsx-max-depth': string;
|
|
57
|
+
'react/jsx-max-props-per-line': string;
|
|
58
|
+
'react/jsx-newline': string;
|
|
59
|
+
'react/jsx-no-bind': string;
|
|
60
|
+
'react/jsx-no-leaked-render': string;
|
|
61
|
+
'react/jsx-no-literals': string;
|
|
62
|
+
'react/jsx-one-expression-per-line': string;
|
|
63
|
+
'react/jsx-props-no-spreading': string;
|
|
64
|
+
'react/jsx-sort-props': string;
|
|
65
|
+
'react/no-multi-comp': string;
|
|
66
|
+
'react/no-unescaped-entities': string;
|
|
67
|
+
'react/no-unused-prop-types': string;
|
|
68
|
+
'react/prefer-read-only-props': string;
|
|
69
|
+
'react/prop-types': string;
|
|
70
|
+
'react/react-in-jsx-scope': string;
|
|
71
|
+
'react/require-default-props': string;
|
|
72
|
+
'react/self-closing-comp': (string | {
|
|
73
|
+
component: boolean;
|
|
74
|
+
html: boolean;
|
|
75
|
+
})[];
|
|
76
|
+
'react/void-dom-elements-no-children': string;
|
|
77
|
+
'@typescript-eslint/no-restricted-imports': (string | ({
|
|
78
|
+
patterns: {
|
|
79
|
+
group: string[];
|
|
80
|
+
message: string;
|
|
81
|
+
}[];
|
|
82
|
+
} & {
|
|
83
|
+
paths: {
|
|
84
|
+
name: string;
|
|
85
|
+
importNames: string[];
|
|
86
|
+
message: string;
|
|
87
|
+
}[];
|
|
88
|
+
}))[];
|
|
89
|
+
'lodash/import-scope': string[];
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/eslint/react.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
3
|
+
const { merge } = require('lodash');
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
5
|
+
const { universalRestrictedImportsConfig, universalImportOrderConfig } = require('./internal');
|
|
6
|
+
module.exports = {
|
|
7
|
+
parser: '@typescript-eslint/parser',
|
|
8
|
+
parserOptions: {
|
|
9
|
+
ecmaVersion: 2022,
|
|
10
|
+
ecmaFeatures: {
|
|
11
|
+
jsx: true, // Support JSX syntax.
|
|
12
|
+
},
|
|
13
|
+
sourceType: 'module', // Enable ES6 import/export syntax.
|
|
14
|
+
},
|
|
15
|
+
settings: {
|
|
16
|
+
react: {
|
|
17
|
+
version: 'detect', // Automatically detect the version of React.
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
env: {
|
|
21
|
+
node: true,
|
|
22
|
+
browser: true,
|
|
23
|
+
},
|
|
24
|
+
extends: ['plugin:react/all', 'plugin:react-hooks/recommended'],
|
|
25
|
+
plugins: ['react', '@typescript-eslint', 'import', 'lodash'],
|
|
26
|
+
rules: {
|
|
27
|
+
'import/order': [
|
|
28
|
+
'error',
|
|
29
|
+
merge({}, universalImportOrderConfig, {
|
|
30
|
+
// Prioritize react imports.
|
|
31
|
+
pathGroups: [
|
|
32
|
+
{
|
|
33
|
+
pattern: 'react',
|
|
34
|
+
group: 'builtin',
|
|
35
|
+
position: 'before',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
/* Overrides for "react" plugin */
|
|
41
|
+
'react/destructuring-assignment': ['error', 'always', { destructureInSignature: 'ignore' }],
|
|
42
|
+
'react/forbid-component-props': ['error', { forbid: [] }],
|
|
43
|
+
'react/forbid-dom-props': ['error', { forbid: [] }],
|
|
44
|
+
'react/function-component-definition': 'off',
|
|
45
|
+
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never', propElementValues: 'always' }],
|
|
46
|
+
'react/jsx-curly-newline': 'off',
|
|
47
|
+
'react/jsx-filename-extension': 'off',
|
|
48
|
+
'react/jsx-handler-names': 'off',
|
|
49
|
+
'react/jsx-indent': 'off',
|
|
50
|
+
'react/jsx-indent-props': 'off',
|
|
51
|
+
'react/jsx-max-depth': 'off',
|
|
52
|
+
'react/jsx-max-props-per-line': 'off',
|
|
53
|
+
'react/jsx-newline': 'off',
|
|
54
|
+
'react/jsx-no-bind': 'off',
|
|
55
|
+
'react/jsx-no-leaked-render': 'off',
|
|
56
|
+
'react/jsx-no-literals': 'off',
|
|
57
|
+
'react/jsx-one-expression-per-line': 'off',
|
|
58
|
+
'react/jsx-props-no-spreading': 'off',
|
|
59
|
+
'react/jsx-sort-props': 'off',
|
|
60
|
+
'react/no-multi-comp': 'off',
|
|
61
|
+
'react/no-unescaped-entities': 'off',
|
|
62
|
+
'react/no-unused-prop-types': 'off',
|
|
63
|
+
'react/prefer-read-only-props': 'off',
|
|
64
|
+
'react/prop-types': 'off',
|
|
65
|
+
'react/react-in-jsx-scope': 'off',
|
|
66
|
+
'react/require-default-props': 'off',
|
|
67
|
+
'react/self-closing-comp': ['error', { component: true, html: true }],
|
|
68
|
+
'react/void-dom-elements-no-children': 'error',
|
|
69
|
+
/* Overrides for "@typescript-eslint" plugin */
|
|
70
|
+
'@typescript-eslint/no-restricted-imports': [
|
|
71
|
+
'error',
|
|
72
|
+
merge({}, universalRestrictedImportsConfig, {
|
|
73
|
+
paths: [
|
|
74
|
+
{
|
|
75
|
+
name: 'react',
|
|
76
|
+
importNames: ['default'],
|
|
77
|
+
message: 'Starting from React version 17, there is no need to globally import React. Use named imports for specific React APIs.',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
/* Overrides for "lodash" plugin */
|
|
83
|
+
'lodash/import-scope': ['error', 'method'],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/eslint/react.js"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEpC,8DAA8D;AAC9D,MAAM,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE/F,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,YAAY,EAAE;YACZ,GAAG,EAAE,IAAI,EAAE,sBAAsB;SAClC;QACD,UAAU,EAAE,QAAQ,EAAE,mCAAmC;KAC1D;IACD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE,QAAQ,EAAE,6CAA6C;SACjE;KACF;IACD,GAAG,EAAE;QACH,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;KACd;IACD,OAAO,EAAE,CAAC,kBAAkB,EAAE,gCAAgC,CAAC;IAC/D,OAAO,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,CAAC;IAC5D,KAAK,EAAE;QACL,cAAc,EAAE;YACd,OAAO;YACP,KAAK,CAAC,EAAE,EAAE,0BAA0B,EAAE;gBACpC,4BAA4B;gBAC5B,UAAU,EAAE;oBACV;wBACE,OAAO,EAAE,OAAO;wBAChB,KAAK,EAAE,SAAS;wBAChB,QAAQ,EAAE,QAAQ;qBACnB;iBACF;aACF,CAAC;SACH;QACD,kCAAkC;QAClC,gCAAgC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,sBAAsB,EAAE,QAAQ,EAAE,CAAC;QAC3F,8BAA8B,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACzD,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACnD,qCAAqC,EAAE,KAAK;QAC5C,gCAAgC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;QAC/G,yBAAyB,EAAE,KAAK;QAChC,8BAA8B,EAAE,KAAK;QACrC,yBAAyB,EAAE,KAAK;QAChC,kBAAkB,EAAE,KAAK;QACzB,wBAAwB,EAAE,KAAK;QAC/B,qBAAqB,EAAE,KAAK;QAC5B,8BAA8B,EAAE,KAAK;QACrC,mBAAmB,EAAE,KAAK;QAC1B,mBAAmB,EAAE,KAAK;QAC1B,4BAA4B,EAAE,KAAK;QACnC,uBAAuB,EAAE,KAAK;QAC9B,mCAAmC,EAAE,KAAK;QAC1C,8BAA8B,EAAE,KAAK;QACrC,sBAAsB,EAAE,KAAK;QAC7B,qBAAqB,EAAE,KAAK;QAC5B,6BAA6B,EAAE,KAAK;QACpC,4BAA4B,EAAE,KAAK;QACnC,8BAA8B,EAAE,KAAK;QACrC,kBAAkB,EAAE,KAAK;QACzB,0BAA0B,EAAE,KAAK;QACjC,6BAA6B,EAAE,KAAK;QACpC,yBAAyB,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACrE,qCAAqC,EAAE,OAAO;QAE9C,+CAA+C;QAC/C,0CAA0C,EAAE;YAC1C,OAAO;YACP,KAAK,CAAC,EAAE,EAAE,gCAAgC,EAAE;gBAC1C,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,CAAC,SAAS,CAAC;wBACxB,OAAO,EACL,uHAAuH;qBAC1H;iBACF;aACF,CAAC;SACH;QAED,mCAAmC;QACnC,qBAAqB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC3C;CACF,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export declare let parser: string;
|
|
2
|
+
export declare namespace parserOptions {
|
|
3
|
+
let ecmaVersion: number;
|
|
4
|
+
let sourceType: string;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace env {
|
|
7
|
+
let node: boolean;
|
|
8
|
+
let browser: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare let _extends: string[];
|
|
11
|
+
export { _extends as extends };
|
|
12
|
+
export declare let plugins: string[];
|
|
13
|
+
export declare let rules: {
|
|
14
|
+
camelcase: string;
|
|
15
|
+
curly: string[];
|
|
16
|
+
eqeqeq: string;
|
|
17
|
+
'no-await-in-loop': string;
|
|
18
|
+
'no-console': (string | {
|
|
19
|
+
allow: string[];
|
|
20
|
+
})[];
|
|
21
|
+
'no-constant-condition': string;
|
|
22
|
+
'no-fallthrough': string;
|
|
23
|
+
'no-inline-comments': string;
|
|
24
|
+
'no-lonely-if': string;
|
|
25
|
+
'no-nested-ternary': string;
|
|
26
|
+
'no-new-wrappers': string;
|
|
27
|
+
'no-return-await': string;
|
|
28
|
+
'no-unexpected-multiline': string;
|
|
29
|
+
'no-unused-expressions': string;
|
|
30
|
+
'object-shorthand': string;
|
|
31
|
+
'prefer-destructuring': (string | {
|
|
32
|
+
array: boolean;
|
|
33
|
+
object: boolean;
|
|
34
|
+
enforceForRenamedProperties?: never;
|
|
35
|
+
} | {
|
|
36
|
+
enforceForRenamedProperties: boolean;
|
|
37
|
+
array?: never;
|
|
38
|
+
object?: never;
|
|
39
|
+
})[];
|
|
40
|
+
'prefer-exponentiation-operator': string;
|
|
41
|
+
'prefer-named-capture-group': string;
|
|
42
|
+
'prefer-object-spread': string;
|
|
43
|
+
'prefer-spread': string;
|
|
44
|
+
'prefer-template': string;
|
|
45
|
+
radix: string;
|
|
46
|
+
'sort-keys': (string | {
|
|
47
|
+
caseSensitive: boolean;
|
|
48
|
+
natural: boolean;
|
|
49
|
+
minKeys: number;
|
|
50
|
+
allowLineSeparatedGroups: boolean;
|
|
51
|
+
})[];
|
|
52
|
+
'spaced-comment': (string | {
|
|
53
|
+
line: {
|
|
54
|
+
markers: string[];
|
|
55
|
+
};
|
|
56
|
+
})[];
|
|
57
|
+
'prefer-arrow/prefer-arrow-functions': (string | {
|
|
58
|
+
disallowPrototype: boolean;
|
|
59
|
+
singleReturnOnly: boolean;
|
|
60
|
+
classPropertiesAllowed: boolean;
|
|
61
|
+
})[];
|
|
62
|
+
'check-file/folder-naming-convention': (string | {
|
|
63
|
+
'**/': string;
|
|
64
|
+
})[];
|
|
65
|
+
'unicorn/filename-case': (string | {
|
|
66
|
+
case: string;
|
|
67
|
+
ignore: never[];
|
|
68
|
+
})[];
|
|
69
|
+
'unicorn/consistent-function-scoping': string;
|
|
70
|
+
'unicorn/no-abusive-eslint-disable': string;
|
|
71
|
+
'unicorn/no-array-callback-reference': string;
|
|
72
|
+
'unicorn/no-array-reduce': string;
|
|
73
|
+
'unicorn/no-nested-ternary': string;
|
|
74
|
+
'unicorn/no-null': string;
|
|
75
|
+
'unicorn/no-useless-undefined': (string | {
|
|
76
|
+
checkArguments: boolean;
|
|
77
|
+
})[];
|
|
78
|
+
'unicorn/prefer-module': string;
|
|
79
|
+
'unicorn/prevent-abbreviations': string;
|
|
80
|
+
'import/no-default-export': string;
|
|
81
|
+
'import/no-duplicates': string;
|
|
82
|
+
'import/no-named-as-default': string;
|
|
83
|
+
'import/no-unresolved': string;
|
|
84
|
+
'import/order': (string | {
|
|
85
|
+
groups: string[];
|
|
86
|
+
'newlines-between': string;
|
|
87
|
+
alphabetize: {
|
|
88
|
+
order: string;
|
|
89
|
+
caseInsensitive: boolean;
|
|
90
|
+
};
|
|
91
|
+
})[];
|
|
92
|
+
'@typescript-eslint/comma-dangle': string;
|
|
93
|
+
'@typescript-eslint/consistent-type-exports': (string | {
|
|
94
|
+
fixMixedExportsWithInlineTypeSpecifier: boolean;
|
|
95
|
+
})[];
|
|
96
|
+
'@typescript-eslint/consistent-type-imports': (string | {
|
|
97
|
+
prefer: string;
|
|
98
|
+
disallowTypeAnnotations: boolean;
|
|
99
|
+
fixStyle: string;
|
|
100
|
+
})[];
|
|
101
|
+
'@typescript-eslint/explicit-function-return-type': string;
|
|
102
|
+
'@typescript-eslint/explicit-module-boundary-types': string;
|
|
103
|
+
'@typescript-eslint/indent': string;
|
|
104
|
+
'@typescript-eslint/init-declarations': string;
|
|
105
|
+
'@typescript-eslint/lines-around-comment': string;
|
|
106
|
+
'@typescript-eslint/member-delimiter-style': string;
|
|
107
|
+
'@typescript-eslint/member-ordering': string;
|
|
108
|
+
'@typescript-eslint/naming-convention': string;
|
|
109
|
+
'@typescript-eslint/no-confusing-void-expression': (string | {
|
|
110
|
+
ignoreArrowShorthand: boolean;
|
|
111
|
+
})[];
|
|
112
|
+
'@typescript-eslint/no-empty-function': string;
|
|
113
|
+
'@typescript-eslint/no-explicit-any': string;
|
|
114
|
+
'@typescript-eslint/no-extra-parens': string;
|
|
115
|
+
'@typescript-eslint/no-magic-numbers': string;
|
|
116
|
+
'@typescript-eslint/no-misused-promises': (string | {
|
|
117
|
+
checksVoidReturn: {
|
|
118
|
+
arguments: boolean;
|
|
119
|
+
attributes: boolean;
|
|
120
|
+
};
|
|
121
|
+
})[];
|
|
122
|
+
'@typescript-eslint/no-non-null-assertion': string;
|
|
123
|
+
'@typescript-eslint/no-require-imports': string;
|
|
124
|
+
'@typescript-eslint/no-restricted-imports': (string | {
|
|
125
|
+
patterns: {
|
|
126
|
+
group: string[];
|
|
127
|
+
message: string;
|
|
128
|
+
}[];
|
|
129
|
+
})[];
|
|
130
|
+
'@typescript-eslint/no-shadow': string;
|
|
131
|
+
'@typescript-eslint/no-type-alias': string;
|
|
132
|
+
'@typescript-eslint/no-unnecessary-condition': string;
|
|
133
|
+
'@typescript-eslint/no-unsafe-argument': string;
|
|
134
|
+
'@typescript-eslint/no-unsafe-assignment': string;
|
|
135
|
+
'@typescript-eslint/no-unsafe-member-access': string;
|
|
136
|
+
'@typescript-eslint/no-unsafe-return': string;
|
|
137
|
+
'@typescript-eslint/no-unused-vars': (string | {
|
|
138
|
+
argsIgnorePattern: string;
|
|
139
|
+
varsIgnorePattern: string;
|
|
140
|
+
vars: string;
|
|
141
|
+
})[];
|
|
142
|
+
'@typescript-eslint/no-use-before-define': string;
|
|
143
|
+
'@typescript-eslint/object-curly-spacing': string;
|
|
144
|
+
'@typescript-eslint/prefer-nullish-coalescing': (string | {
|
|
145
|
+
ignoreConditionalTests: boolean;
|
|
146
|
+
})[];
|
|
147
|
+
'@typescript-eslint/prefer-readonly-parameter-types': string;
|
|
148
|
+
'@typescript-eslint/quotes': string;
|
|
149
|
+
'@typescript-eslint/semi': string;
|
|
150
|
+
'@typescript-eslint/space-before-function-paren': string;
|
|
151
|
+
'@typescript-eslint/strict-boolean-expressions': string;
|
|
152
|
+
'@typescript-eslint/unbound-method': string;
|
|
153
|
+
'functional/no-classes': string;
|
|
154
|
+
'functional/no-promise-reject': string;
|
|
155
|
+
'functional/no-try-statements': string;
|
|
156
|
+
'functional/prefer-tacit': string;
|
|
157
|
+
'lodash/import-scope': string[];
|
|
158
|
+
'lodash/path-style': string;
|
|
159
|
+
'lodash/prefer-lodash-method': string;
|
|
160
|
+
'deprecation/deprecation': string;
|
|
161
|
+
};
|
|
162
|
+
export declare let overrides: {
|
|
163
|
+
files: string[];
|
|
164
|
+
env: {
|
|
165
|
+
jest: boolean;
|
|
166
|
+
};
|
|
167
|
+
plugins: string[];
|
|
168
|
+
extends: string[];
|
|
169
|
+
rules: {
|
|
170
|
+
'jest/prefer-expect-assertions': string;
|
|
171
|
+
'jest/prefer-each': string;
|
|
172
|
+
'jest/require-top-level-describe': string;
|
|
173
|
+
'jest/max-expects': string;
|
|
174
|
+
'jest/valid-title': string;
|
|
175
|
+
};
|
|
176
|
+
}[];
|
|
177
|
+
//# sourceMappingURL=universal.d.ts.map
|