@api3/commons 0.9.0 → 0.10.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.
Files changed (58) hide show
  1. package/README.md +10 -60
  2. package/dist/blockchain-utilities/derivation.d.ts.map +1 -1
  3. package/dist/blockchain-utilities/derivation.js +3 -3
  4. package/dist/blockchain-utilities/derivation.js.map +1 -1
  5. package/dist/blockchain-utilities/schema.js.map +1 -1
  6. package/dist/config-hash/index.js.map +1 -1
  7. package/dist/config-parsing/index.d.ts.map +1 -1
  8. package/dist/config-parsing/index.js +2 -2
  9. package/dist/config-parsing/index.js.map +1 -1
  10. package/dist/http/index.js +2 -2
  11. package/dist/http/index.js.map +1 -1
  12. package/dist/logger/async-storage.d.ts +0 -1
  13. package/dist/logger/async-storage.d.ts.map +1 -1
  14. package/dist/logger/index.d.ts.map +1 -1
  15. package/dist/logger/index.js +9 -1
  16. package/dist/logger/index.js.map +1 -1
  17. package/dist/node-index.d.ts.map +1 -1
  18. package/dist/node-index.js +0 -1
  19. package/dist/node-index.js.map +1 -1
  20. package/dist/processing/processing.d.ts.map +1 -1
  21. package/dist/processing/processing.js.map +1 -1
  22. package/dist/processing/unsafe-evaluate.d.ts.map +1 -1
  23. package/dist/processing/unsafe-evaluate.js +1 -3
  24. package/dist/processing/unsafe-evaluate.js.map +1 -1
  25. package/dist/processing/vm-timers.d.ts +0 -5
  26. package/dist/processing/vm-timers.d.ts.map +1 -1
  27. package/dist/processing/vm-timers.js.map +1 -1
  28. package/package.json +19 -36
  29. package/src/logger/index.test.ts +93 -83
  30. package/src/logger/index.ts +9 -1
  31. package/src/node-index.ts +0 -1
  32. package/src/processing/unsafe-evaluate.ts +0 -1
  33. package/dist/eslint/internal.d.ts +0 -15
  34. package/dist/eslint/internal.d.ts.map +0 -1
  35. package/dist/eslint/internal.js +0 -24
  36. package/dist/eslint/internal.js.map +0 -1
  37. package/dist/eslint/jest.d.ts +0 -29
  38. package/dist/eslint/jest.d.ts.map +0 -1
  39. package/dist/eslint/jest.js +0 -38
  40. package/dist/eslint/jest.js.map +0 -1
  41. package/dist/eslint/next-js.d.ts +0 -27
  42. package/dist/eslint/next-js.d.ts.map +0 -1
  43. package/dist/eslint/next-js.js +0 -33
  44. package/dist/eslint/next-js.js.map +0 -1
  45. package/dist/eslint/react.d.ts +0 -90
  46. package/dist/eslint/react.d.ts.map +0 -1
  47. package/dist/eslint/react.js +0 -85
  48. package/dist/eslint/react.js.map +0 -1
  49. package/dist/eslint/universal.d.ts +0 -173
  50. package/dist/eslint/universal.d.ts.map +0 -1
  51. package/dist/eslint/universal.js +0 -203
  52. package/dist/eslint/universal.js.map +0 -1
  53. package/src/eslint/README.md +0 -87
  54. package/src/eslint/internal.js +0 -24
  55. package/src/eslint/jest.js +0 -36
  56. package/src/eslint/next-js.js +0 -31
  57. package/src/eslint/react.js +0 -88
  58. package/src/eslint/universal.js +0 -209
@@ -1,173 +0,0 @@
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
- 'check-file/folder-naming-convention': (string | {
58
- '**/': string;
59
- })[];
60
- 'unicorn/filename-case': (string | {
61
- case: string;
62
- ignore: never[];
63
- })[];
64
- 'unicorn/consistent-function-scoping': string;
65
- 'unicorn/no-abusive-eslint-disable': string;
66
- 'unicorn/no-array-callback-reference': string;
67
- 'unicorn/no-array-reduce': string;
68
- 'unicorn/no-nested-ternary': string;
69
- 'unicorn/no-null': string;
70
- 'unicorn/no-object-as-default-parameter': string;
71
- 'unicorn/no-useless-undefined': (string | {
72
- checkArguments: boolean;
73
- })[];
74
- 'unicorn/prefer-module': string;
75
- 'unicorn/prevent-abbreviations': string;
76
- 'import/no-default-export': string;
77
- 'import/no-duplicates': string;
78
- 'import/no-named-as-default': string;
79
- 'import/no-unresolved': string;
80
- 'import/order': (string | {
81
- groups: string[];
82
- 'newlines-between': string;
83
- alphabetize: {
84
- order: string;
85
- caseInsensitive: boolean;
86
- };
87
- })[];
88
- '@typescript-eslint/comma-dangle': string;
89
- '@typescript-eslint/consistent-type-exports': (string | {
90
- fixMixedExportsWithInlineTypeSpecifier: boolean;
91
- })[];
92
- '@typescript-eslint/consistent-type-imports': (string | {
93
- prefer: string;
94
- disallowTypeAnnotations: boolean;
95
- fixStyle: string;
96
- })[];
97
- '@typescript-eslint/explicit-function-return-type': string;
98
- '@typescript-eslint/explicit-module-boundary-types': string;
99
- '@typescript-eslint/indent': string;
100
- '@typescript-eslint/init-declarations': string;
101
- '@typescript-eslint/lines-around-comment': string;
102
- '@typescript-eslint/member-delimiter-style': string;
103
- '@typescript-eslint/member-ordering': string;
104
- '@typescript-eslint/naming-convention': string;
105
- '@typescript-eslint/no-confusing-void-expression': (string | {
106
- ignoreArrowShorthand: boolean;
107
- })[];
108
- '@typescript-eslint/no-empty-function': string;
109
- '@typescript-eslint/no-explicit-any': string;
110
- '@typescript-eslint/no-extra-parens': string;
111
- '@typescript-eslint/no-magic-numbers': string;
112
- '@typescript-eslint/no-misused-promises': (string | {
113
- checksVoidReturn: {
114
- arguments: boolean;
115
- attributes: boolean;
116
- };
117
- })[];
118
- '@typescript-eslint/no-non-null-assertion': string;
119
- '@typescript-eslint/no-require-imports': string;
120
- '@typescript-eslint/no-restricted-imports': (string | {
121
- patterns: {
122
- group: string[];
123
- message: string;
124
- }[];
125
- })[];
126
- '@typescript-eslint/no-shadow': string;
127
- '@typescript-eslint/no-type-alias': string;
128
- '@typescript-eslint/no-unnecessary-condition': string;
129
- '@typescript-eslint/no-unsafe-argument': string;
130
- '@typescript-eslint/no-unsafe-assignment': string;
131
- '@typescript-eslint/no-unsafe-member-access': string;
132
- '@typescript-eslint/no-unsafe-return': string;
133
- '@typescript-eslint/no-unused-vars': (string | {
134
- argsIgnorePattern: string;
135
- varsIgnorePattern: string;
136
- vars: string;
137
- })[];
138
- '@typescript-eslint/no-use-before-define': string;
139
- '@typescript-eslint/object-curly-spacing': string;
140
- '@typescript-eslint/prefer-nullish-coalescing': (string | {
141
- ignoreConditionalTests: boolean;
142
- })[];
143
- '@typescript-eslint/prefer-readonly-parameter-types': string;
144
- '@typescript-eslint/quotes': string;
145
- '@typescript-eslint/semi': string;
146
- '@typescript-eslint/space-before-function-paren': string;
147
- '@typescript-eslint/strict-boolean-expressions': string;
148
- '@typescript-eslint/unbound-method': string;
149
- 'functional/no-classes': string;
150
- 'functional/no-promise-reject': string;
151
- 'functional/no-try-statements': string;
152
- 'functional/prefer-tacit': string;
153
- 'lodash/import-scope': string[];
154
- 'lodash/path-style': string;
155
- 'lodash/prefer-lodash-method': string;
156
- 'deprecation/deprecation': string;
157
- };
158
- export declare let overrides: {
159
- files: string[];
160
- env: {
161
- jest: boolean;
162
- };
163
- plugins: string[];
164
- extends: string[];
165
- rules: {
166
- 'jest/prefer-expect-assertions': string;
167
- 'jest/prefer-each': string;
168
- 'jest/require-top-level-describe': string;
169
- 'jest/max-expects': string;
170
- 'jest/valid-title': string;
171
- };
172
- }[];
173
- //# sourceMappingURL=universal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"universal.d.ts","sourceRoot":"","sources":["../../src/eslint/universal.js"],"names":[],"mappings":""}
@@ -1,203 +0,0 @@
1
- "use strict";
2
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3
- const { universalRestrictedImportsConfig, universalImportOrderConfig } = require('./internal');
4
- module.exports = {
5
- parser: '@typescript-eslint/parser',
6
- parserOptions: {
7
- ecmaVersion: 2022,
8
- sourceType: 'module', // Allows for the use of imports.
9
- },
10
- env: {
11
- node: true,
12
- browser: true,
13
- },
14
- extends: [
15
- 'eslint:recommended',
16
- 'plugin:@typescript-eslint/all',
17
- 'plugin:import/recommended',
18
- 'plugin:import/typescript',
19
- 'plugin:unicorn/recommended',
20
- 'plugin:promise/recommended',
21
- 'plugin:lodash/recommended',
22
- ],
23
- plugins: ['@typescript-eslint', 'deprecation', 'functional', 'unicorn', 'check-file', 'import', 'lodash'],
24
- rules: {
25
- /* Rule definitions and overrides for standard ESLint rules */
26
- camelcase: 'error',
27
- curly: ['error', 'multi-line', 'consistent'],
28
- eqeqeq: 'error',
29
- 'no-await-in-loop': 'off',
30
- 'no-console': ['error', { allow: ['info', 'groupCollapsed', 'groupEnd'] }],
31
- 'no-constant-condition': 'off',
32
- 'no-fallthrough': 'off',
33
- 'no-inline-comments': 'off',
34
- 'no-lonely-if': 'error',
35
- 'no-nested-ternary': 'error',
36
- 'no-new-wrappers': 'error',
37
- 'no-return-await': 'off',
38
- 'no-unexpected-multiline': 'off',
39
- 'no-unused-expressions': 'off',
40
- 'object-shorthand': 'error',
41
- 'prefer-destructuring': [
42
- 'error',
43
- {
44
- array: false,
45
- object: true,
46
- },
47
- {
48
- enforceForRenamedProperties: false,
49
- },
50
- ],
51
- 'prefer-exponentiation-operator': 'error',
52
- 'prefer-named-capture-group': 'error',
53
- 'prefer-object-spread': 'error',
54
- 'prefer-spread': 'error',
55
- 'prefer-template': 'error',
56
- radix: 'error',
57
- // Sort keys does not have a fixer, but sorting lines can be trivially done by IDE (or some plugin). This rule has a
58
- // nice configuration option "minKeys" which can specify how many keys should be present in an object before sorting
59
- // is enforced. This is useful for small objects, where sorting is not necessary. Also, it allows creating groups
60
- // (separated by newlines) which are sorted independently.
61
- 'sort-keys': ['error', 'asc', { caseSensitive: true, natural: true, minKeys: 10, allowLineSeparatedGroups: true }],
62
- 'spaced-comment': [
63
- 'error',
64
- 'always',
65
- {
66
- line: {
67
- markers: ['/'],
68
- },
69
- },
70
- ],
71
- /* Rules to enforce kebab-case folder structure */
72
- 'check-file/folder-naming-convention': [
73
- 'error',
74
- {
75
- '**/': 'KEBAB_CASE',
76
- },
77
- ],
78
- 'unicorn/filename-case': [
79
- 'error',
80
- {
81
- case: 'kebabCase',
82
- ignore: [],
83
- },
84
- ],
85
- /* Rule overrides for "unicorn" plugin */
86
- 'unicorn/consistent-function-scoping': 'off',
87
- 'unicorn/no-abusive-eslint-disable': 'off',
88
- 'unicorn/no-array-callback-reference': 'error',
89
- 'unicorn/no-array-reduce': 'off',
90
- 'unicorn/no-nested-ternary': 'off',
91
- 'unicorn/no-null': 'off',
92
- 'unicorn/no-object-as-default-parameter': 'off',
93
- 'unicorn/no-useless-undefined': ['error', { checkArguments: false }],
94
- 'unicorn/prefer-module': 'off',
95
- 'unicorn/prevent-abbreviations': 'off',
96
- /* Rule overrides for "import" plugin */
97
- 'import/no-default-export': 'error',
98
- 'import/no-duplicates': 'error',
99
- 'import/no-named-as-default': 'off',
100
- 'import/no-unresolved': 'off',
101
- 'import/order': ['error', universalImportOrderConfig],
102
- /* Rule overrides for "@typescript-eslint" plugin */
103
- '@typescript-eslint/comma-dangle': 'off',
104
- '@typescript-eslint/consistent-type-exports': [
105
- 'error',
106
- {
107
- fixMixedExportsWithInlineTypeSpecifier: true,
108
- },
109
- ],
110
- '@typescript-eslint/consistent-type-imports': [
111
- 'error',
112
- {
113
- prefer: 'type-imports',
114
- disallowTypeAnnotations: false,
115
- fixStyle: 'inline-type-imports',
116
- },
117
- ],
118
- '@typescript-eslint/explicit-function-return-type': 'off',
119
- '@typescript-eslint/explicit-module-boundary-types': 'off',
120
- '@typescript-eslint/indent': 'off',
121
- '@typescript-eslint/init-declarations': 'off',
122
- '@typescript-eslint/lines-around-comment': 'off',
123
- '@typescript-eslint/member-delimiter-style': 'off',
124
- '@typescript-eslint/member-ordering': 'off',
125
- '@typescript-eslint/naming-convention': 'off',
126
- '@typescript-eslint/no-confusing-void-expression': [
127
- 'error',
128
- {
129
- ignoreArrowShorthand: true, // See: https://typescript-eslint.io/rules/no-confusing-void-expression/#ignorearrowshorthand.
130
- },
131
- ],
132
- '@typescript-eslint/no-empty-function': 'off',
133
- '@typescript-eslint/no-explicit-any': 'off',
134
- '@typescript-eslint/no-extra-parens': 'off',
135
- '@typescript-eslint/no-magic-numbers': 'off',
136
- '@typescript-eslint/no-misused-promises': [
137
- 'error',
138
- {
139
- checksVoidReturn: {
140
- arguments: false,
141
- attributes: false, // It's common to pass async function where one expects a function returning void.
142
- },
143
- },
144
- ],
145
- '@typescript-eslint/no-non-null-assertion': 'off',
146
- '@typescript-eslint/no-require-imports': 'off',
147
- '@typescript-eslint/no-restricted-imports': ['error', universalRestrictedImportsConfig],
148
- '@typescript-eslint/no-shadow': 'off',
149
- '@typescript-eslint/no-type-alias': 'off',
150
- '@typescript-eslint/no-unnecessary-condition': 'off',
151
- '@typescript-eslint/no-unsafe-argument': 'off',
152
- '@typescript-eslint/no-unsafe-assignment': 'off',
153
- '@typescript-eslint/no-unsafe-member-access': 'off',
154
- '@typescript-eslint/no-unsafe-return': 'off',
155
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', vars: 'all' }],
156
- '@typescript-eslint/no-use-before-define': 'off',
157
- '@typescript-eslint/object-curly-spacing': 'off',
158
- '@typescript-eslint/prefer-nullish-coalescing': [
159
- 'error',
160
- {
161
- ignoreConditionalTests: true, // Its more intuitive to use logical operators in conditionals.
162
- },
163
- ],
164
- '@typescript-eslint/prefer-readonly-parameter-types': 'off',
165
- '@typescript-eslint/quotes': 'off',
166
- '@typescript-eslint/semi': 'off',
167
- '@typescript-eslint/space-before-function-paren': 'off',
168
- '@typescript-eslint/strict-boolean-expressions': 'off',
169
- '@typescript-eslint/unbound-method': 'off',
170
- /* Rule overrides for "functional" plugin */
171
- 'functional/no-classes': 'error',
172
- 'functional/no-promise-reject': 'error',
173
- 'functional/no-try-statements': 'error',
174
- 'functional/prefer-tacit': 'off',
175
- /* Overrides for "lodash" plugin */
176
- 'lodash/import-scope': ['error', 'member'],
177
- 'lodash/path-style': 'off',
178
- 'lodash/prefer-lodash-method': 'off',
179
- /* Rule overrides for other plugins and rules */
180
- // This rule unfortunately does not detect deprecated properties. See:
181
- // https://github.com/gund/eslint-plugin-deprecation/issues/13/
182
- 'deprecation/deprecation': 'error',
183
- },
184
- overrides: [
185
- // Overrides for Jest tests.
186
- {
187
- files: ['**/*.test.ts', '**/*.test.tsx'],
188
- env: {
189
- jest: true,
190
- },
191
- plugins: ['jest'],
192
- extends: ['plugin:jest/all', 'plugin:jest-formatting/recommended'],
193
- rules: {
194
- 'jest/prefer-expect-assertions': 'off',
195
- 'jest/prefer-each': 'off',
196
- 'jest/require-top-level-describe': 'off',
197
- 'jest/max-expects': 'off',
198
- 'jest/valid-title': 'off', // Prevents using "<function-name>.name" as a test name
199
- },
200
- },
201
- ],
202
- };
203
- //# sourceMappingURL=universal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"universal.js","sourceRoot":"","sources":["../../src/eslint/universal.js"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,MAAM,EAAE,gCAAgC,EAAE,0B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,IAAI,EAAE,+DAA+D;aAC9F;SACF;QACD,oDAAoD,EAAE,KAAK;QAC3D,2BAA2B,EAAE,KAAK;QAClC,yBAAyB,EAAE,KAAK;QAChC,gDAAgD,EAAE,KAAK;QACvD,+CAA+C,EAAE,KAAK;QACtD,mCAAmC,EAAE,KAAK;QAE1C,4CAA4C;QAC5C,uBAAuB,EAAE,OAAO;QAChC,8BAA8B,EAAE,OAAO;QACvC,8BAA8B,EAAE,OAAO;QACvC,yBAAyB,EAAE,KAAK;QAEhC,mCAAmC;QACnC,qBAAqB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC1C,mBAAmB,EAAE,KAAK;QAC1B,6BAA6B,EAAE,KAAK;QAEpC,gDAAgD;QAChD,sEAAsE;QACtE,+DAA+D;QAC/D,yBAAyB,EAAE,OAAO;KACnC;IACD,SAAS,EAAE;QACT,4BAA4B;QAC5B;YACE,KAAK,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;YACxC,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,EAAE,uDAAuD;aACnF;SACF;KACF;CACF,CAAC"}
@@ -1,87 +0,0 @@
1
- # eslint
2
-
3
- > ESLint configurations used across API3 projects.
4
-
5
- The modules consists of multiple ESLint configurations supporting wide variety of targets:
6
-
7
- - `universal` - Linting rules for universal (both FE and BE) JS/TS code (with the emphasis on TS).
8
- - `react` - Linting rules for React code.
9
- - `next-js` - Linting rules for Next.js code.
10
- - `jest` - Linting rules for Jest tests. Note, that these rules are only applied for JS/TS files with `*.test.*`
11
- extensions.
12
-
13
- ## Getting started
14
-
15
- 1. Create an `.eslintrc.js` configuration file in the repo root.
16
- 2. Extend the desired configuration(s).
17
- 3. Specify the `parserOptions.project` option with the path to the `tsconfig.json` file(s).
18
- 4. Install `eslint` (which is a peer dependency of this module) as dev dependencies.
19
-
20
- For example:
21
-
22
- ```js
23
- module.exports = {
24
- // Unfortunately, the plugin does not comply with official ESLint naming convention which demands the plugin to be
25
- // published as "@api3/eslint-config-commons". As a workaround, you need to use a relative path instead.
26
- //
27
- // See: https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L920
28
- extends: ['./node_modules/@api3/commons/dist/eslint/universal', './node_modules/@api3/commons/dist/eslint/jest'],
29
- parserOptions: {
30
- // We focus primarily on TS and for that we need to specify the TS configs which is project specific. The following
31
- // is a common monorepo setup (root config and a config for each package).
32
- project: ['./tsconfig.json', './packages/*/tsconfig.json'],
33
- },
34
- };
35
- ```
36
-
37
- ### Linting commands
38
-
39
- We recommend using the following linting commands inside `package.json` scripts:
40
-
41
- ```json
42
- {
43
- "eslint:check": "eslint --report-unused-disable-directives --cache --ext js,ts,tsx,jsx . --max-warnings 0",
44
- "eslint:fix": "pnpm run eslint:check --fix"
45
- }
46
- ```
47
-
48
- The `--cache` parameter makes ESLint create a `.eslintcache` file in the root of the project. This file should be put to
49
- `.gitignore`.
50
-
51
- ## Rules
52
-
53
- The configurations are a collection of various rulesets and the config is quite strict. In general there are rules that:
54
-
55
- - Have a fixer (import ordering)
56
- - Simplify code (combine two nested ifs)
57
- - Make code more consistent (make `return void` pattern be split on two lines)
58
- - Fix outdated stuff (avoid `!` ts operator when not necessary)
59
- - Avoid vulnerabilities and errors (Number.parseInt without radix)
60
-
61
- Tip: Some rules do have fixer with multiple variants of the fixes. You need to use the IDE to prompt the fixes and
62
- choose the one you want.
63
-
64
- ### Overriding rules
65
-
66
- To override a rule, you can use the `rules` section key in your `.eslintrc.js` file. For example:
67
-
68
- ```js
69
- {
70
- rules: {
71
- 'check-file/folder-naming-convention': 'off', // Turns of the kebab-case convention for folder names.
72
- 'unicorn/filename-case': 'off' // Turns of the kebab-case convention for filenames.
73
-
74
- 'import/no-default-export': 'off', // Turns off the rule that disallows default exports.
75
- 'import/prefer-default-export': 'error' // Turns on the rule that prefers default exports.
76
- }
77
- }
78
- ```
79
-
80
- ## Development notes
81
-
82
- - The implementation is intentionally written in JS so it can be used to lint the project itself. You can see that the
83
- root `.eslintrc.js` extends the configuration files from this module.
84
-
85
- - Unfortunately, the plugin does not comply with official ESLint naming convention which demands the plugin to be
86
- published as "@api3/eslint-config-commons". As a workaround, project need to use a relative path instead. See:
87
- https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L920
@@ -1,24 +0,0 @@
1
- const universalRestrictedImportsConfig = {
2
- patterns: [
3
- {
4
- group: ['date-fns/*'],
5
- // The date-fns library is tree-shakeable and it's more convenient to use named imports.
6
- message: "Please use named imports from 'date-fns'.",
7
- },
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
-
21
- module.exports = {
22
- universalRestrictedImportsConfig,
23
- universalImportOrderConfig,
24
- };
@@ -1,36 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- ecmaVersion: 2022, // Enable parsing modern ECMAScript features.
5
- sourceType: 'module', // Enable the use of ES6 import/export syntax.
6
- },
7
- env: {
8
- node: true,
9
- browser: true,
10
- },
11
- // Configuration for specific files is done under 'overrides'.
12
- overrides: [
13
- {
14
- files: ['**/*.test.ts', '**/*.test.tsx', '**/*.test.js', '**/*.test.jsx'],
15
- env: {
16
- jest: true,
17
- },
18
- plugins: ['jest'],
19
- extends: ['plugin:jest/all', 'plugin:jest-formatting/recommended'],
20
- rules: {
21
- 'jest/prefer-expect-assertions': 'off', // While useful, enforcing this can lead to verbose tests.
22
- 'jest/prefer-each': 'off', // We find traditional for-loops more readable in certain contexts.
23
- 'jest/require-top-level-describe': 'off', // Multiple top-level describe blocks or tests can be acceptable.
24
- 'jest/max-expects': 'off', // Limiting expect statements is beneficial, but enforcing a strict count can be restrictive.
25
- 'jest/valid-title': 'off', // This restriction can prevent using titles like "<function-name>.name".
26
- 'jest/no-hooks': [
27
- 'error', // We advocate for setup functions over beforeXXX hooks. However, afterXyz hooks are sometimes indispensable, like for resetting Jest timers. See: https://kentcdodds.com/blog/avoid-nesting-when-youre-testing#inline-it.
28
- {
29
- allow: ['afterEach', 'afterAll'],
30
- },
31
- ],
32
- 'prefer-lowercase-title': 'off', // Sometimes we want to start the test with a capital letter and some words are all uppercase (e.g. AWS).
33
- },
34
- },
35
- ],
36
- };
@@ -1,31 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- ecmaVersion: 2022, // Enable parsing of modern ECMAScript features.
5
- ecmaFeatures: {
6
- jsx: true, // Support JSX syntax.
7
- },
8
- sourceType: 'module', // Enable ES6 import/export syntax.
9
- },
10
- settings: {
11
- react: {
12
- version: 'detect',
13
- },
14
- },
15
- env: {
16
- node: true,
17
- browser: true,
18
- },
19
- extends: [
20
- 'next/core-web-vitals', // Enforce Next.js performance best practices. See: https://nextjs.org/docs/basic-features/eslint.
21
- ],
22
- overrides: [
23
- {
24
- files: ['pages/**/*'],
25
- rules: {
26
- 'import/no-default-export': 'off',
27
- 'import/prefer-default-export': 'error', // Next.js expects default exports in the pages directory.
28
- },
29
- },
30
- ],
31
- };
@@ -1,88 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires, lodash/import-scope
2
- const { merge } = require('lodash');
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-var-requires
5
- const { universalRestrictedImportsConfig, universalImportOrderConfig } = require('./internal');
6
-
7
- module.exports = {
8
- parser: '@typescript-eslint/parser',
9
- parserOptions: {
10
- ecmaVersion: 2022, // Enable parsing of modern ECMAScript features.
11
- ecmaFeatures: {
12
- jsx: true, // Support JSX syntax.
13
- },
14
- sourceType: 'module', // Enable ES6 import/export syntax.
15
- },
16
- settings: {
17
- react: {
18
- version: 'detect', // Automatically detect the version of React.
19
- },
20
- },
21
- env: {
22
- node: true,
23
- browser: true,
24
- },
25
- extends: ['plugin:react/all', 'plugin:react-hooks/recommended'],
26
- plugins: ['react', '@typescript-eslint', 'import', 'lodash'],
27
- rules: {
28
- 'import/order': [
29
- 'error',
30
- merge({}, universalImportOrderConfig, {
31
- // Prioritize react imports.
32
- pathGroups: [
33
- {
34
- pattern: 'react',
35
- group: 'builtin',
36
- position: 'before',
37
- },
38
- ],
39
- }),
40
- ],
41
- /* Overrides for "react" plugin */
42
- 'react/destructuring-assignment': ['error', 'always', { destructureInSignature: 'ignore' }],
43
- 'react/forbid-component-props': ['error', { forbid: [] }],
44
- 'react/forbid-dom-props': ['error', { forbid: [] }],
45
- 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never', propElementValues: 'always' }],
46
- 'react/jsx-curly-newline': 'off', // Conflicts with prettier.
47
- 'react/jsx-filename-extension': 'off', // We use .tsx extension.
48
- 'react/jsx-handler-names': 'off',
49
- 'react/jsx-indent': 'off', // Conflicts with prettier.
50
- 'react/jsx-indent-props': 'off', // Conflicts with prettier.
51
- 'react/jsx-max-depth': 'off', // Conflicts with prettier.
52
- 'react/jsx-max-props-per-line': 'off', // Conflicts with prettier.
53
- 'react/jsx-newline': 'off', // Conflicts with prettier.
54
- 'react/jsx-no-bind': 'off', // Conflicts with prettier.
55
- 'react/jsx-no-leaked-render': 'off',
56
- 'react/jsx-no-literals': 'off',
57
- 'react/jsx-one-expression-per-line': 'off', // Conflicts with prettier.
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
-
70
- /* Overrides for "@typescript-eslint" plugin */
71
- '@typescript-eslint/no-restricted-imports': [
72
- 'error',
73
- merge({}, universalRestrictedImportsConfig, {
74
- paths: [
75
- {
76
- name: 'react',
77
- importNames: ['default'],
78
- message:
79
- 'Starting from React version 17, there is no need to globally import React. Use named imports for specific React APIs.',
80
- },
81
- ],
82
- }),
83
- ],
84
-
85
- /* Overrides for "lodash" plugin */
86
- 'lodash/import-scope': ['error', 'method'],
87
- },
88
- };