@map-colonies/eslint-config 3.1.3 → 6.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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # ESLint config
2
+
3
+ A collection of [ESLint](https://eslint.org/) configs for various frameworks and environments.
4
+ The package only supports eslint 9 and above using the flat configuration.
5
+
6
+ ## Available Configs
7
+
8
+ - **ts-base**: base configurations for TypeScript.
9
+ - **React**: rules for React (extends react-app).
10
+ - **Jest**: rules for Jest.
11
+
12
+ ## Installation
13
+
14
+ ### base
15
+ ```bash
16
+ $ npm install --save-dev eslint @map-colonies/eslint-config
17
+ ```
18
+
19
+ ### react
20
+ ```
21
+ $ npm install --save-dev @map-colonies/eslint-config eslint-plugin-react eslint-plugin-react-hooks
22
+ ```
23
+
24
+ ### jest
25
+ ```
26
+ $ npm install --save-dev @map-colonies/eslint-config eslint-plugin-jest
27
+ ```
28
+
29
+
30
+ ## Usage
31
+
32
+ Add the configs you want to the eslint configuration file of your choice. In this example we are using the file `eslint.config.mjs`
33
+ For more information check the following link [Configuration Files
34
+ ](https://eslint.org/docs/latest/use/configure/configuration-files).
35
+ <br/>
36
+ **Note:** make sure to add `ts-base` last.
37
+
38
+ ```javascript
39
+ import tsBaseConfig from '@map-colonies/eslint-config/ts-base';
40
+ import { config } from '@map-colonies/eslint-config/helpers';
41
+
42
+ export default config(tsBaseConfig);
43
+
44
+ ```
45
+
46
+ ## Debug
47
+ If you want to check the ESLint configuration, debug problems or just see the final configuration, you can the following command that will open the eslint configuration UI in your browser.
48
+
49
+ ```bash
50
+ npx eslint --inspect-config .
51
+ ```
52
+
53
+ For more information check the following link [debug](https://eslint.org/docs/latest/use/configure/debug).
54
+
55
+
56
+ ## Adding new Configs
57
+
58
+ Add a new file and name it as you would like. Inside export the ESLint configuration.
59
+
60
+ ```js
61
+ module.exports = {
62
+ extends: ['plugin:jest/recommended', 'plugin:jest/style'],
63
+ plugins: ['jest'],
64
+ env: {
65
+ 'jest/globals': true,
66
+ },
67
+ };
68
+ ```
69
+
70
+ after you finished developing the config, make sure it works by using the `--print-config` flag of ESLint, in the project you use for testing.
71
+
72
+ ```bash
73
+ $ npx eslint --print-config index.ts
74
+ ```
75
+
76
+ Don't forget adding the config to this readme :blush:
77
+
78
+ ## Issues
79
+ If any linting error is appearing twice, or you have any other problem, please open an issue with all the details you have.
@@ -0,0 +1,14 @@
1
+ declare const jestConfig: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
2
+ /**
3
+ * The default export for the Jest configuration.
4
+ * This configuration is used to set up and customize the behavior of Jest,
5
+ * a JavaScript testing framework.
6
+ *
7
+ * @group configs
8
+ * @example
9
+ * import jestConfig from '@map-colonies/eslint-config/jest';
10
+ * import { config } from '@map-colonies/eslint-config/helpers';
11
+ *
12
+ * export default config(jestConfig);
13
+ */
14
+ export default jestConfig;
@@ -0,0 +1,29 @@
1
+ import { config } from '../helpers.mjs';
2
+ import { importOrThrow } from '../internal/helpers.js';
3
+ const jestPlugin = await importOrThrow('eslint-plugin-jest');
4
+ const jestConfig = config({
5
+ name: 'map-colonies/jest/rules',
6
+ files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'],
7
+ plugins: { jest: jestPlugin },
8
+ languageOptions: {
9
+ globals: jestPlugin.environments.globals.globals,
10
+ },
11
+ rules: {
12
+ ...jestPlugin.configs.recommended.rules,
13
+ ...jestPlugin.configs.style.rules,
14
+ },
15
+ });
16
+ /**
17
+ * The default export for the Jest configuration.
18
+ * This configuration is used to set up and customize the behavior of Jest,
19
+ * a JavaScript testing framework.
20
+ *
21
+ * @group configs
22
+ * @example
23
+ * import jestConfig from '@map-colonies/eslint-config/jest';
24
+ * import { config } from '@map-colonies/eslint-config/helpers';
25
+ *
26
+ * export default config(jestConfig);
27
+ */
28
+ export default jestConfig;
29
+ //# sourceMappingURL=jest.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.mjs","sourceRoot":"","sources":["../../src/configs/jest.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAwB,oBAAoB,CAAC,CAAC;AAEpF,MAAM,UAAU,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,CAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,CAAC;IACzE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;IAC7B,eAAe,EAAE;QACf,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO;KACjD;IACD,KAAK,EAAE;QACL,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;QACvC,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;KAClC;CACF,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAe,UAAU,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Combined React and React Hooks ESLint configuration
3
+ *
4
+ * Provides ESLint rules for React and React Hooks, including:
5
+ * - React recommended rules
6
+ * - JSX runtime configuration
7
+ * - Browser globals
8
+ * - React version detection
9
+ * - Custom React rules (boolean prop naming, useState hook usage)
10
+ * - React Hooks recommended rules
11
+ *
12
+ * @group configs
13
+ * @example
14
+ * import reactConfig from '@map-colonies/eslint-config/react';
15
+ * import { config } from '@map-colonies/eslint-config/helpers';
16
+ *
17
+ * export default config(reactConfig);
18
+ */
19
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
20
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import { config } from '../helpers.mjs';
2
+ import { importOrThrow } from '../internal/helpers.js';
3
+ const reactPlugin = await importOrThrow('eslint-plugin-react');
4
+ const pluginReactHooks = await importOrThrow('eslint-plugin-react-hooks');
5
+ const importedGlobals = await importOrThrow('globals');
6
+ const reactRules = config(reactPlugin.configs.flat.recommended ?? {}, reactPlugin.configs.flat['jsx-runtime'] ?? {}, {
7
+ name: 'map-colonies/react/rules',
8
+ files: ['**/*.tsx'],
9
+ languageOptions: {
10
+ globals: importedGlobals.browser,
11
+ },
12
+ settings: {
13
+ react: {
14
+ version: 'detect',
15
+ },
16
+ },
17
+ rules: {
18
+ 'react/boolean-prop-naming': 'error',
19
+ 'react/hook-use-state': 'error',
20
+ 'react/prop-types': 'off',
21
+ },
22
+ });
23
+ const reactHooksRules = config({
24
+ name: 'map-colonies/react-hooks/rules',
25
+ files: ['**/*.tsx'],
26
+ plugins: { 'react-hooks': pluginReactHooks },
27
+ rules: pluginReactHooks.configs.recommended.rules,
28
+ });
29
+ /**
30
+ * Combined React and React Hooks ESLint configuration
31
+ *
32
+ * Provides ESLint rules for React and React Hooks, including:
33
+ * - React recommended rules
34
+ * - JSX runtime configuration
35
+ * - Browser globals
36
+ * - React version detection
37
+ * - Custom React rules (boolean prop naming, useState hook usage)
38
+ * - React Hooks recommended rules
39
+ *
40
+ * @group configs
41
+ * @example
42
+ * import reactConfig from '@map-colonies/eslint-config/react';
43
+ * import { config } from '@map-colonies/eslint-config/helpers';
44
+ *
45
+ * export default config(reactConfig);
46
+ */
47
+ export default config(reactRules, reactHooksRules);
48
+ //# sourceMappingURL=react.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.mjs","sourceRoot":"","sources":["../../src/configs/react.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,MAAM,WAAW,GAAG,MAAM,aAAa,CAAyB,qBAAqB,CAAC,CAAC;AACvF,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAmB,2BAA2B,CAAC,CAAC;AAC5F,MAAM,eAAe,GAAG,MAAM,aAAa,CAAyF,SAAS,CAAC,CAAC;AAE/I,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE;IACnH,IAAI,EAAE,0BAA0B;IAChC,KAAK,EAAE,CAAC,UAAU,CAAC;IACnB,eAAe,EAAE;QACf,OAAO,EAAE,eAAe,CAAC,OAAO;KACjC;IACD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE,QAAQ;SAClB;KACF;IACD,KAAK,EAAE;QACL,2BAA2B,EAAE,OAAO;QACpC,sBAAsB,EAAE,OAAO;QAC/B,kBAAkB,EAAE,KAAK;KAC1B;CACF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,MAAM,CAAC;IAC7B,IAAI,EAAE,gCAAgC;IACtC,KAAK,EAAE,CAAC,UAAU,CAAC;IACnB,OAAO,EAAE,EAAE,aAAa,EAAE,gBAAgB,EAAE;IAC5C,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;CAClD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAe,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ESLint naming convention rules for TypeScript projects
3
+ *
4
+ * Defines naming patterns for:
5
+ * - Default identifiers (camelCase)
6
+ * - Variables (camelCase, UPPER_CASE, PascalCase for providers)
7
+ * - Parameters (camelCase with optional leading underscore)
8
+ * - Private members (camelCase)
9
+ * - Enum members (UPPER_CASE)
10
+ * - Types (PascalCase)
11
+ * - Quoted properties (any format)
12
+ */
13
+ export declare const namingConventions: ["error", {
14
+ readonly selector: "default";
15
+ readonly format: readonly ["camelCase"];
16
+ }, {
17
+ readonly selector: "variable";
18
+ readonly format: readonly ["camelCase", "UPPER_CASE"];
19
+ }, {
20
+ readonly selector: "variable";
21
+ readonly format: readonly ["PascalCase"];
22
+ readonly filter: {
23
+ readonly regex: "^.*Provider$";
24
+ readonly match: true;
25
+ };
26
+ }, {
27
+ readonly selector: "parameter";
28
+ readonly format: readonly ["camelCase"];
29
+ readonly leadingUnderscore: "allow";
30
+ }, {
31
+ readonly selector: "memberLike";
32
+ readonly modifiers: readonly ["private"];
33
+ readonly format: readonly ["camelCase"];
34
+ }, {
35
+ readonly selector: "enumMember";
36
+ readonly format: readonly ["UPPER_CASE"];
37
+ }, {
38
+ readonly selector: readonly ["classProperty", "objectLiteralProperty", "typeProperty", "classMethod", "objectLiteralMethod", "typeMethod", "accessor", "enumMember"];
39
+ readonly format: null;
40
+ readonly modifiers: readonly ["requiresQuotes"];
41
+ }, {
42
+ readonly selector: "typeLike";
43
+ readonly format: readonly ["PascalCase"];
44
+ }];
45
+ declare const combinedConfig: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
46
+ /**
47
+ * Combined ESLint configuration for TypeScript projects
48
+ * Includes:
49
+ * - ESLint recommended rules
50
+ * - TypeScript-ESLint recommended rules with type checking
51
+ * - Custom TypeScript rules
52
+ * - Jest-specific rule overrides
53
+ * - React component naming conventions
54
+ * - Import organization rules
55
+ * - Global ignores for build artifacts and dependencies
56
+ * - Parser configuration
57
+ * - Prettier integration
58
+ *
59
+ * @group configs
60
+ * @example
61
+ * import tsBaseConfig from '@map-colonies/eslint-config/ts-base';
62
+ * import { config } from '@map-colonies/eslint-config/helpers';
63
+ *
64
+ * export default config(tsBaseConfig);
65
+ */
66
+ export default combinedConfig;
@@ -0,0 +1,209 @@
1
+ import eslint from '@eslint/js';
2
+ import { configs as tsEslintConfigs } from 'typescript-eslint';
3
+ import eslintPluginImportX from 'eslint-plugin-import-x';
4
+ import eslintConfigPrettier from 'eslint-config-prettier';
5
+ import tsParser from '@typescript-eslint/parser';
6
+ import { config } from '../helpers.mjs';
7
+ /**
8
+ * ESLint naming convention rules for TypeScript projects
9
+ *
10
+ * Defines naming patterns for:
11
+ * - Default identifiers (camelCase)
12
+ * - Variables (camelCase, UPPER_CASE, PascalCase for providers)
13
+ * - Parameters (camelCase with optional leading underscore)
14
+ * - Private members (camelCase)
15
+ * - Enum members (UPPER_CASE)
16
+ * - Types (PascalCase)
17
+ * - Quoted properties (any format)
18
+ */
19
+ export const namingConventions = [
20
+ 'error',
21
+ {
22
+ selector: 'default',
23
+ format: ['camelCase'],
24
+ },
25
+ {
26
+ selector: 'variable',
27
+ format: ['camelCase', 'UPPER_CASE'],
28
+ },
29
+ {
30
+ selector: 'variable',
31
+ format: ['PascalCase'],
32
+ filter: {
33
+ regex: '^.*Provider$',
34
+ match: true,
35
+ },
36
+ },
37
+ {
38
+ selector: 'parameter',
39
+ format: ['camelCase'],
40
+ leadingUnderscore: 'allow',
41
+ },
42
+ {
43
+ selector: 'memberLike',
44
+ modifiers: ['private'],
45
+ format: ['camelCase'],
46
+ // leadingUnderscore: 'require',
47
+ },
48
+ {
49
+ selector: 'enumMember',
50
+ format: ['UPPER_CASE'],
51
+ },
52
+ {
53
+ selector: [
54
+ 'classProperty',
55
+ 'objectLiteralProperty',
56
+ 'typeProperty',
57
+ 'classMethod',
58
+ 'objectLiteralMethod',
59
+ 'typeMethod',
60
+ 'accessor',
61
+ 'enumMember',
62
+ ],
63
+ format: null,
64
+ modifiers: ['requiresQuotes'],
65
+ },
66
+ {
67
+ selector: 'typeLike',
68
+ format: ['PascalCase'],
69
+ },
70
+ ];
71
+ const typescriptEslintRules = config({
72
+ name: 'map-colonies/typescript-eslint/rules',
73
+ rules: {
74
+ '@typescript-eslint/array-type': ['error', { default: 'array' }],
75
+ '@typescript-eslint/ban-ts-comment': 'warn',
76
+ '@typescript-eslint/ban-tslint-comment': 'error',
77
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
78
+ '@typescript-eslint/explicit-function-return-type': 'warn',
79
+ '@typescript-eslint/explicit-member-accessibility': 'error',
80
+ '@typescript-eslint/member-ordering': 'warn',
81
+ '@typescript-eslint/method-signature-style': 'error',
82
+ '@typescript-eslint/no-empty-interface': 'off',
83
+ curly: 'error',
84
+ camelcase: 'off',
85
+ 'no-lonely-if': 'error',
86
+ '@typescript-eslint/naming-convention': namingConventions,
87
+ '@typescript-eslint/no-base-to-string': 'warn',
88
+ '@typescript-eslint/no-confusing-non-null-assertion': 'error',
89
+ '@typescript-eslint/no-extraneous-class': 'warn',
90
+ // '@typescript-eslint/no-throw-literal': 'error',
91
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
92
+ '@typescript-eslint/no-unnecessary-condition': 'error',
93
+ '@typescript-eslint/no-unnecessary-type-arguments': 'warn',
94
+ '@typescript-eslint/prefer-literal-enum-member': 'error',
95
+ '@typescript-eslint/prefer-nullish-coalescing': 'warn',
96
+ '@typescript-eslint/prefer-optional-chain': 'warn',
97
+ '@typescript-eslint/prefer-readonly': 'error',
98
+ '@typescript-eslint/prefer-string-starts-ends-with': 'error',
99
+ '@typescript-eslint/promise-function-async': 'error',
100
+ '@typescript-eslint/require-array-sort-compare': 'warn',
101
+ '@typescript-eslint/strict-boolean-expressions': 'warn',
102
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
103
+ '@typescript-eslint/no-magic-numbers': [
104
+ 'error',
105
+ {
106
+ ignoreArrayIndexes: true,
107
+ ignore: [1, 0],
108
+ ignoreNumericLiteralTypes: true,
109
+ },
110
+ ],
111
+ '@typescript-eslint/default-param-last': 'error',
112
+ '@typescript-eslint/no-dupe-class-members': 'error',
113
+ '@typescript-eslint/no-unused-expressions': 'error',
114
+ '@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true }],
115
+ '@typescript-eslint/return-await': 'error',
116
+ },
117
+ });
118
+ // This is not in the jest config as it only turns rules off, and needs to be applied after the other rules
119
+ const jestTurnedOffRules = config({
120
+ name: 'map-colonies/jest/disabled-rules',
121
+ files: ['**/*.spec.ts?(x)', '**/*.test.ts?(x)'],
122
+ rules: {
123
+ '@typescript-eslint/no-magic-numbers': 'off',
124
+ '@typescript-eslint/explicit-function-return-type': 'off',
125
+ },
126
+ });
127
+ // // This is not in the react config as it only turns rules off, and needs to be applied after the other rules
128
+ const reactNamingConventions = config({
129
+ name: 'map-colonies/react/naming-conventions',
130
+ files: ['**/*.tsx'],
131
+ rules: {
132
+ '@typescript-eslint/naming-convention': [
133
+ ...namingConventions,
134
+ {
135
+ selector: 'variable',
136
+ format: ['camelCase', 'PascalCase'],
137
+ types: ['function'],
138
+ },
139
+ ],
140
+ },
141
+ });
142
+ const importRulesAndConfig = config({
143
+ name: 'map-colonies/import-x/rules',
144
+ files: ['**/*.ts?(x)'],
145
+ ignores: ['eslint.config.*'],
146
+ languageOptions: {
147
+ parser: tsParser,
148
+ ecmaVersion: 'latest',
149
+ sourceType: 'module',
150
+ },
151
+ rules: {
152
+ 'import-x/order': [
153
+ 'error',
154
+ {
155
+ pathGroups: [
156
+ {
157
+ pattern: '@**',
158
+ group: 'external',
159
+ position: 'after',
160
+ },
161
+ {
162
+ pattern: '@*/**',
163
+ group: 'external',
164
+ position: 'after',
165
+ },
166
+ ],
167
+ },
168
+ ],
169
+ 'import-x/first': 'error',
170
+ 'import-x/exports-last': 'error',
171
+ 'import-x/newline-after-import': 'error',
172
+ },
173
+ });
174
+ const globalIgnoreConfig = config({
175
+ name: 'map-colonies/global-ignore',
176
+ ignores: ['.husky', 'coverage', 'reports', 'dist', 'node_modules', '**/*.{js,mjs,cjs}', 'helm'],
177
+ });
178
+ const parserOptions = config({
179
+ name: 'map-colonies/parser-options',
180
+ languageOptions: {
181
+ parserOptions: {
182
+ projectService: true,
183
+ tsconfigRootDir: process.cwd(),
184
+ },
185
+ },
186
+ });
187
+ const combinedConfig = config(eslint.configs.recommended, tsEslintConfigs.recommendedTypeChecked, typescriptEslintRules, jestTurnedOffRules, reactNamingConventions, eslintPluginImportX.flatConfigs.recommended, { name: 'import-x/typescript', ...eslintPluginImportX.flatConfigs.typescript }, importRulesAndConfig, globalIgnoreConfig, parserOptions, { name: 'eslint-prettier/disabled-rules', ...eslintConfigPrettier });
188
+ /**
189
+ * Combined ESLint configuration for TypeScript projects
190
+ * Includes:
191
+ * - ESLint recommended rules
192
+ * - TypeScript-ESLint recommended rules with type checking
193
+ * - Custom TypeScript rules
194
+ * - Jest-specific rule overrides
195
+ * - React component naming conventions
196
+ * - Import organization rules
197
+ * - Global ignores for build artifacts and dependencies
198
+ * - Parser configuration
199
+ * - Prettier integration
200
+ *
201
+ * @group configs
202
+ * @example
203
+ * import tsBaseConfig from '@map-colonies/eslint-config/ts-base';
204
+ * import { config } from '@map-colonies/eslint-config/helpers';
205
+ *
206
+ * export default config(tsBaseConfig);
207
+ */
208
+ export default combinedConfig;
209
+ //# sourceMappingURL=ts-base.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-base.mjs","sourceRoot":"","sources":["../../src/configs/ts-base.mts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO;IACP;QACE,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,CAAC,WAAW,CAAC;KACtB;IACD;QACE,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;KACpC;IACD;QACE,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,YAAY,CAAC;QACtB,MAAM,EAAE;YACN,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,IAAI;SACZ;KACF;IACD;QAC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AAI,EAAE,gCAAgC,EAAE,GAAG,oBAAoB,EAAE,CACpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAe,cAAc,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { config as importedConfig } from 'typescript-eslint';
2
+ /**
3
+ * Utility function to make it easy to strictly type your "Flat" config file
4
+ * @example
5
+ * ```js
6
+ * // @ts-check
7
+ *
8
+ * import eslint from '@eslint/js';
9
+ * import tseslint from 'typescript-eslint';
10
+ *
11
+ * export default tseslint.config(
12
+ * eslint.configs.recommended,
13
+ * tseslint.configs.recommended,
14
+ * {
15
+ * rules: {
16
+ * '@typescript-eslint/array-type': 'error',
17
+ * },
18
+ * },
19
+ * );
20
+ * ```
21
+ */
22
+ declare const config: typeof importedConfig;
23
+ export { config };
@@ -0,0 +1,24 @@
1
+ import { config as importedConfig } from 'typescript-eslint';
2
+ /**
3
+ * Utility function to make it easy to strictly type your "Flat" config file
4
+ * @example
5
+ * ```js
6
+ * // @ts-check
7
+ *
8
+ * import eslint from '@eslint/js';
9
+ * import tseslint from 'typescript-eslint';
10
+ *
11
+ * export default tseslint.config(
12
+ * eslint.configs.recommended,
13
+ * tseslint.configs.recommended,
14
+ * {
15
+ * rules: {
16
+ * '@typescript-eslint/array-type': 'error',
17
+ * },
18
+ * },
19
+ * );
20
+ * ```
21
+ */
22
+ const config = importedConfig;
23
+ export { config };
24
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","sourceRoot":"","sources":["../src/helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,GAAG,cAAc,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function importOrThrow<T extends object>(modulePath: string): Promise<T>;
@@ -0,0 +1,13 @@
1
+ export async function importOrThrow(modulePath) {
2
+ try {
3
+ const imported = (await import(modulePath));
4
+ if ('default' in imported) {
5
+ return imported.default;
6
+ }
7
+ return imported;
8
+ }
9
+ catch (error) {
10
+ throw new Error(`Failed to import optional module '${modulePath}', make sure its installed and try again`, { cause: error });
11
+ }
12
+ }
13
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/internal/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,aAAa,CAAmB,UAAkB;IACtE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAM,CAAC;QAEjD,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC,OAAY,CAAC;QAC/B,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,0CAA0C,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/H,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,47 @@
1
1
  {
2
2
  "name": "@map-colonies/eslint-config",
3
- "version": "3.1.3",
3
+ "version": "6.0.0",
4
4
  "description": "eslint configs for map colonies organization",
5
- "main": "index.js",
5
+ "type": "module",
6
+ "main": "./dist/configs/ts-base.mjs",
7
+ "types": "./dist/configs/ts-base.d.ts",
8
+ "exports": {
9
+ "./ts-base": {
10
+ "types": "./dist/configs/ts-base.d.ts",
11
+ "import": "./dist/configs/ts-base.mjs"
12
+ },
13
+ "./react": {
14
+ "types": "./dist/configs/react.d.ts",
15
+ "import": "./dist/configs/react.mjs"
16
+ },
17
+ "./jest": {
18
+ "types": "./dist/configs/jest.d.ts",
19
+ "import": "./dist/configs/jest.mjs"
20
+ },
21
+ "./helpers": {
22
+ "types": "./dist/helpers.d.ts",
23
+ "import": "./dist/helpers.mjs"
24
+ }
25
+ },
6
26
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "release": "standard-version"
27
+ "prepare": "husky",
28
+ "format": "prettier --check .",
29
+ "format:fix": "prettier --write .",
30
+ "prelint:fix": "npm run format:fix",
31
+ "prelint": "npm run format",
32
+ "lint": "eslint .",
33
+ "lint:fix": "eslint --fix .",
34
+ "pretest": "npm run build",
35
+ "test": "tsc --noEmit -p tsconfig.json && NODE_OPTIONS=--experimental-vm-modules jest --config=./tests/configurations/jest.config.mjs",
36
+ "prepack": "npm run build",
37
+ "prebuild": "npm run clean",
38
+ "clean": "rimraf dist",
39
+ "build": "tsc --project tsconfig.build.json",
40
+ "docs": "typedoc"
9
41
  },
42
+ "files": [
43
+ "dist/**/*"
44
+ ],
10
45
  "repository": {
11
46
  "type": "git",
12
47
  "url": "git+https://github.com/MapColonies/eslint-config.git"
@@ -17,33 +52,61 @@
17
52
  "url": "https://github.com/MapColonies/eslint-config/issues"
18
53
  },
19
54
  "homepage": "https://github.com/MapColonies/eslint-config#readme",
20
- "husky": {
21
- "hooks": {
22
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
23
- }
24
- },
25
- "config": {
26
- "commitizen": {
27
- "path": "./node_modules/cz-conventional-changelog"
28
- }
55
+ "engines": {
56
+ "node": ">=20"
29
57
  },
30
58
  "peerDependencies": {
31
- "eslint": "^8.15.0"
59
+ "eslint": "^9.19.0",
60
+ "eslint-plugin-jest": "^28.11.0",
61
+ "eslint-plugin-react": "^7.37.4",
62
+ "eslint-plugin-react-hooks": "^5.1.0",
63
+ "globals": "^15.14.0"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "eslint-plugin-jest": {
67
+ "optional": true
68
+ },
69
+ "eslint-plugin-react": {
70
+ "optional": true
71
+ },
72
+ "eslint-plugin-react-hooks": {
73
+ "optional": true
74
+ },
75
+ "globals": {
76
+ "optional": true
77
+ }
32
78
  },
33
79
  "dependencies": {
34
- "@typescript-eslint/eslint-plugin": "5.38.0",
35
- "@typescript-eslint/parser": "5.38.0",
36
- "eslint-config-prettier": "^8.5.0",
37
- "eslint-config-react-app": "^7.0.1",
38
- "eslint-plugin-import": "^2.26.0",
39
- "eslint-plugin-jest": "^26.2.2"
80
+ "@eslint/js": "^9.19.0",
81
+ "eslint-config-prettier": "^10.0.1",
82
+ "eslint-import-resolver-typescript": "^3.7.0",
83
+ "eslint-plugin-import-x": "^4.6.1",
84
+ "typescript-eslint": "^8.23.0"
40
85
  },
41
86
  "devDependencies": {
42
- "@commitlint/cli": "^17.0.0",
43
- "@commitlint/config-conventional": "^17.0.0",
44
- "commitlint": "^17.0.0",
45
- "cz-conventional-changelog": "^3.3.0",
46
- "husky": "^8.0.1",
47
- "standard-version": "^9.5.0"
87
+ "@commitlint/cli": "^19.6.1",
88
+ "@map-colonies/commitlint-config": "^1.1.0",
89
+ "@map-colonies/infra-copilot-instructions": "^1.0.0",
90
+ "@map-colonies/prettier-config": "^0.0.1",
91
+ "@map-colonies/tsconfig": "^1.0.0",
92
+ "@swc/core": "^1.10.16",
93
+ "@swc/jest": "^0.2.37",
94
+ "@types/eslint": "^9.6.1",
95
+ "@types/eslint-config-prettier": "^6.11.3",
96
+ "@types/jest": "^29.5.14",
97
+ "commitlint": "^19.6.1",
98
+ "cross-env": "^7.0.3",
99
+ "eslint": "^9.19.0",
100
+ "husky": "^9.1.7",
101
+ "jest": "^29.7.0",
102
+ "prettier": "^3.3.3",
103
+ "pretty-quick": "^4.0.0",
104
+ "rimraf": "^6.0.1",
105
+ "typedoc": "^0.27.7",
106
+ "typescript": "^5.7.3",
107
+ "globals": "^15.15.0",
108
+ "eslint-plugin-react-hooks": "^5.1.0",
109
+ "eslint-plugin-jest": "^28.11.0",
110
+ "eslint-plugin-react": "^7.37.4"
48
111
  }
49
112
  }
package/.licrc DELETED
@@ -1,19 +0,0 @@
1
- [licenses]
2
- # This indicates which are the only licenses that Licensebat will accept.
3
- # The rest will be flagged as not allowed.
4
- #accepted = ["MIT", "MSC", "BSD"]
5
- # This will indicate which licenses are not accepted.
6
- # The rest will be accepted, except for the unknown licenses or dependencies without licenses.
7
- unaccepted = ["LGPL"]
8
- # Note that only one of the previous options can be enabled at once.
9
- # If both of them are informed, only accepted will be considered.
10
-
11
- [dependencies]
12
- # This will allow users to flag some dependencies so that Licensebat will not check for their license.
13
- ignored=["ignored_dep1", "ignored_dep2"]
14
-
15
- [behavior]
16
- # False by default, if true, it will only run the checks when one of the dependency files or the .licrc file has been modified.
17
- run_only_on_dependency_modification = true
18
- # False by default, if true, it will never block the build.
19
- do_not_block_pr = true
package/CHANGELOG.md DELETED
@@ -1,92 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [3.1.3](https://github.com/MapColonies/eslint-config/compare/v3.1.2...v3.1.3) (2022-09-22)
6
-
7
- ### [3.1.2](https://github.com/MapColonies/eslint-config/compare/v3.1.1...v3.1.2) (2022-09-22)
8
-
9
- ### [3.1.1](https://github.com/MapColonies/eslint-config/compare/v3.1.0...v3.1.1) (2022-05-18)
10
-
11
- ## [3.1.0](https://github.com/MapColonies/eslint-config/compare/v3.0.1...v3.1.0) (2022-04-27)
12
-
13
- ### [3.0.1](https://github.com/MapColonies/eslint-config/compare/v3.0.0...v3.0.1) (2021-10-19)
14
-
15
-
16
- ### Bug Fixes
17
-
18
- * merged prettier/[@typescript-eslint](https://github.com/typescript-eslint) -> prettier ([f34d9dc](https://github.com/MapColonies/eslint-config/commit/f34d9dcf7665c66119fe4865bda964b9492789e0))
19
-
20
- ## [3.0.0](https://github.com/MapColonies/eslint-config/compare/v2.2.1...v3.0.0) (2021-10-19)
21
-
22
-
23
- ### ⚠ BREAKING CHANGES
24
-
25
- * upgrade to eslint v8
26
-
27
- * upgrade to eslint v8 ([ff2b536](https://github.com/MapColonies/eslint-config/commit/ff2b5367c1bd366ca1513345cacae16a20af8fda))
28
-
29
- ### [2.2.1](https://github.com/MapColonies/eslint-config/compare/v2.2.0...v2.2.1) (2021-06-06)
30
-
31
- ## [2.2.0](https://github.com/MapColonies/eslint-config/compare/v2.1.0...v2.2.0) (2021-02-01)
32
-
33
-
34
- ### Features
35
-
36
- * **ts-base:** added no-unused-vars ([#14](https://github.com/MapColonies/eslint-config/issues/14)) ([4a29a0e](https://github.com/MapColonies/eslint-config/commit/4a29a0e1d7f5b3fb680b947d0ca5f3a7380a1206))
37
-
38
- ## [2.1.0](https://github.com/MapColonies/eslint-config/compare/v2.1.0-0...v2.1.0) (2021-01-13)
39
-
40
- ## [2.1.0-0](https://github.com/MapColonies/eslint-config/compare/v2.0.0...v2.1.0-0) (2021-01-13)
41
-
42
-
43
- ### Features
44
-
45
- * added more bracket rules ([317dc7a](https://github.com/MapColonies/eslint-config/commit/317dc7a8680cb05259b5a78651f83e8c41638816))
46
-
47
- ## [2.0.0](https://github.com/MapColonies/eslint-config/compare/v1.1.0...v2.0.0) (2020-12-15)
48
-
49
-
50
- ### ⚠ BREAKING CHANGES
51
-
52
- * **deps:** changed deps for typescript 4 versions (#11)
53
-
54
- ### build
55
-
56
- * **deps:** changed deps for typescript 4 versions ([#11](https://github.com/MapColonies/eslint-config/issues/11)) ([4bd9177](https://github.com/MapColonies/eslint-config/commit/4bd9177fe07eec16a557f9178aa4cf1723feb167))
57
-
58
- ## [1.1.0](https://github.com/MapColonies/eslint-config/compare/v1.0.3...v1.1.0) (2020-09-02)
59
-
60
-
61
- ### Features
62
-
63
- * **ts-base:** ignored magic numbers in stories, and enabled order import rule ([#9](https://github.com/MapColonies/eslint-config/issues/9)) ([6234db7](https://github.com/MapColonies/eslint-config/commit/6234db7916e54cb7592c3037a29b1fed3d57cd0f))
64
-
65
- ### [1.0.3](https://github.com/MapColonies/eslint-config/compare/v1.0.2...v1.0.3) (2020-08-04)
66
-
67
-
68
- ### Bug Fixes
69
-
70
- * **ts-base:** fixed errors with integration ([#8](https://github.com/MapColonies/eslint-config/issues/8)) ([12be01f](https://github.com/MapColonies/eslint-config/commit/12be01f1b7932a04a52b862f386d694af029ded0))
71
-
72
- ### [1.0.2](https://github.com/MapColonies/eslint-config/compare/v1.0.1...v1.0.2) (2020-08-03)
73
-
74
-
75
- ### Bug Fixes
76
-
77
- * **ts-base:** typo ([93a0d62](https://github.com/MapColonies/eslint-config/commit/93a0d623a819a51a14a4224eea6a9c87202bcbc6))
78
-
79
- ### [1.0.1](https://github.com/MapColonies/eslint-config/compare/v1.0.0...v1.0.1) (2020-08-03)
80
-
81
-
82
- ### Bug Fixes
83
-
84
- * **ts-base:** fixed PR ([8b4cb52](https://github.com/MapColonies/eslint-config/commit/8b4cb529c4e2047909d9a983ff6a0e45ed23b666))
85
- * **ts-base:** tweaked rules based on conflict-ui integration ([9b020c1](https://github.com/MapColonies/eslint-config/commit/9b020c1370109df9535cc9ea5fb621fc8c21aae0))
86
-
87
- ## 1.0.0 (2020-08-02)
88
-
89
-
90
- ### Features
91
-
92
- * **ts-base, jest, react:** added configs ([#2](https://github.com/MapColonies/eslint-config/issues/2)) ([c8da394](https://github.com/MapColonies/eslint-config/commit/c8da39496c56909f8e2523e7b640797369a29601))
@@ -1 +0,0 @@
1
- module.exports = { extends: ['@commitlint/config-conventional'] };
package/jest.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- extends: ['plugin:jest/recommended', 'plugin:jest/style'],
3
- plugins: ['jest'],
4
- env: {
5
- 'jest/globals': true,
6
- },
7
- };
package/react.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['react-app', 'prettier', 'prettier/flowtype', 'prettier/react'],
3
- };
package/readme.md DELETED
@@ -1,71 +0,0 @@
1
- # Map Colonies ESLint configs
2
-
3
- A collection of ESlint configs for various frameworks and enviornments.
4
-
5
- ## Available Configs
6
-
7
- - **ts-base**: base configurations for typescript.
8
- - **react**: rules for react (extends react-app).
9
- - **jest**: rules for jest.
10
-
11
- ## Installation
12
-
13
- ```
14
- $ npm install --save-dev eslint @map-colonies/eslint-config
15
- ```
16
-
17
- or
18
-
19
- ```
20
- $ yarn add --dev eslint @map-colonies/eslint-config
21
- ```
22
-
23
- ## Usage
24
-
25
- Add the configs you want to the extend section of your `eslintConfig` of your `package.json`, or to your `.eslintrc` configuration file.
26
- <br/>
27
- **Note:** make sure to add `ts-base` last.
28
-
29
- ```
30
- "eslintConfig": {
31
- "extends": [
32
- "@map-colonies/eslint-config/react",
33
- "@map-colonies/eslint-config/ts-base"
34
- ]
35
- }
36
- ```
37
-
38
- Then add the path to your TypeScript configuration file to the `parserOptions`
39
-
40
- ```
41
- "eslintConfig": {
42
- "parserOptions": {
43
- "project": "./path/to/your/tsconfig.json"
44
- }
45
- }
46
- ```
47
-
48
- ## Adding new Configs
49
-
50
- Add a new file and name it as you would like. Inside export the ESLint configuration.
51
-
52
- ```
53
- module.exports = {
54
- extends: ['plugin:jest/recommended', 'plugin:jest/style'],
55
- plugins: ['jest'],
56
- env: {
57
- 'jest/globals': true,
58
- },
59
- };
60
- ```
61
-
62
- after you finished developing the config, make sure it works by using the `--print-config` flag of ESLint, in the project you use for testing.
63
-
64
- ```
65
- $ npx eslint --print-config index.ts
66
- ```
67
-
68
- Dont forget adding the config to this readme :blush:
69
-
70
- ## Issues
71
- If any linting error is appearing twice, or you have any other problem, please open an issue with all the details you have.
package/ts-base.js DELETED
@@ -1,184 +0,0 @@
1
- const namingConventions = [
2
- 'error',
3
- {
4
- selector: 'default',
5
- format: ['camelCase'],
6
- },
7
- {
8
- selector: 'variable',
9
- format: ['camelCase', 'UPPER_CASE'],
10
- },
11
- {
12
- selector: 'variable',
13
- format: ['PascalCase'],
14
- filter: {
15
- regex: '^.*Provider$',
16
- match: true,
17
- },
18
- },
19
- {
20
- selector: 'parameter',
21
- format: ['camelCase'],
22
- leadingUnderscore: 'allow',
23
- },
24
- {
25
- selector: 'memberLike',
26
- modifiers: ['private'],
27
- format: ['camelCase'],
28
- // leadingUnderscore: 'require',
29
- },
30
- {
31
- selector: 'enumMember',
32
- format: ['UPPER_CASE'],
33
- },
34
- {
35
- selector: 'typeLike',
36
- format: ['PascalCase'],
37
- },
38
- ];
39
-
40
- module.exports = {
41
- extends: [
42
- 'eslint:recommended',
43
- 'plugin:@typescript-eslint/recommended',
44
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
45
- "prettier"
46
- ],
47
- plugins: ['import', '@typescript-eslint'],
48
- parser: '@typescript-eslint/parser',
49
- parserOptions: {
50
- ecmaVersion: 2018,
51
- sourceType: 'module',
52
- },
53
- env: {
54
- browser: true,
55
- es6: true,
56
- node: true,
57
- },
58
- // overrides for TSX (mostly for react)
59
- overrides: [
60
- {
61
- files: ['**/*.tsx'],
62
- rules: {
63
- '@typescript-eslint/naming-convention': [
64
- ...namingConventions,
65
- {
66
- selector: 'variable',
67
- types: ['function'],
68
- format: ['camelCase', 'PascalCase'],
69
- },
70
- ],
71
- },
72
- },
73
- // overrides for storybook
74
- {
75
- files: ['**/*.stories.ts?(x)'],
76
- rules: {
77
- '@typescript-eslint/no-magic-numbers': 'off',
78
- },
79
- },
80
- // overrides for unit tests
81
- {
82
- files: ['**/*.spec.ts?(x)', '**/*.test.ts?(x)'],
83
- rules: {
84
- '@typescript-eslint/no-magic-numbers': 'off',
85
- '@typescript-eslint/explicit-function-return-type': 'off',
86
- },
87
- },
88
- ],
89
- rules: {
90
- '@typescript-eslint/array-type': ['error', { default: 'array' }],
91
-
92
- '@typescript-eslint/ban-ts-comment': 'warn',
93
-
94
- '@typescript-eslint/ban-tslint-comment': 'error',
95
-
96
- '@typescript-eslint/ban-types': 'error',
97
-
98
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
99
-
100
- '@typescript-eslint/explicit-function-return-type': 'warn',
101
-
102
- '@typescript-eslint/explicit-member-accessibility': 'error',
103
-
104
- '@typescript-eslint/member-ordering': 'warn',
105
-
106
- '@typescript-eslint/method-signature-style': 'error',
107
-
108
- '@typescript-eslint/no-empty-interface': 'off',
109
-
110
- 'brace-style': 'off',
111
-
112
- '@typescript-eslint/brace-style': ['error'],
113
-
114
- curly: 'error',
115
-
116
- camelcase: 'off',
117
-
118
- 'no-lonely-if': 'error',
119
-
120
- '@typescript-eslint/naming-convention': namingConventions,
121
-
122
- '@typescript-eslint/no-base-to-string': 'warn',
123
-
124
- '@typescript-eslint/no-confusing-non-null-assertion': 'error',
125
-
126
- '@typescript-eslint/no-extraneous-class': 'warn',
127
-
128
- '@typescript-eslint/no-throw-literal': 'error',
129
-
130
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
131
-
132
- '@typescript-eslint/no-unnecessary-condition': 'error',
133
-
134
- '@typescript-eslint/no-unnecessary-type-arguments': 'warn',
135
-
136
- '@typescript-eslint/prefer-literal-enum-member': 'error',
137
-
138
- '@typescript-eslint/prefer-nullish-coalescing': 'warn',
139
-
140
- '@typescript-eslint/prefer-optional-chain': 'warn',
141
-
142
- '@typescript-eslint/prefer-readonly': 'error',
143
-
144
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
145
-
146
- '@typescript-eslint/promise-function-async': 'error',
147
-
148
- '@typescript-eslint/require-array-sort-compare': 'warn',
149
-
150
- '@typescript-eslint/strict-boolean-expressions': 'warn',
151
-
152
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
153
-
154
- '@typescript-eslint/no-magic-numbers': [
155
- 'error',
156
- {
157
- ignoreArrayIndexes: true,
158
- ignore: [1, 0],
159
- ignoreNumericLiteralTypes: true,
160
- },
161
- ],
162
-
163
- '@typescript-eslint/default-param-last': 'error',
164
-
165
- '@typescript-eslint/no-dupe-class-members': 'error',
166
-
167
- '@typescript-eslint/no-unused-expressions': 'error',
168
-
169
- '@typescript-eslint/no-unused-vars': [
170
- 'warn',
171
- { ignoreRestSiblings: true },
172
- ],
173
-
174
- '@typescript-eslint/return-await': 'error',
175
-
176
- 'import/order': 'error',
177
-
178
- 'import/first': 'error',
179
-
180
- 'import/exports-last': 'error',
181
-
182
- 'import/newline-after-import': 'error',
183
- },
184
- };