@cabify/eslint-config 3.0.1-beta-6 → 3.0.1-beta-9
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/configs/base.js +27 -28
- package/configs/best-practices.js +1 -1
- package/configs/errors.js +1 -1
- package/configs/es6.js +16 -14
- package/configs/formats.js +2 -2
- package/configs/imports.js +9 -8
- package/configs/jest.js +2 -2
- package/configs/lodash.js +2 -2
- package/configs/node.js +1 -1
- package/configs/postcss.js +1 -1
- package/configs/promises.js +1 -1
- package/configs/react-a11y.js +9 -11
- package/configs/react.js +3 -3
- package/configs/storybook.js +1 -1
- package/configs/strict.js +1 -1
- package/configs/style.js +1 -1
- package/configs/ts.js +27 -10
- package/configs/variables.js +2 -2
- package/eslint.config.js +3 -2
- package/package.json +6 -5
- package/recommended.js +5 -3
- package/utils.js +11 -11
package/configs/base.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable import/extensions */
|
|
2
|
+
import globals from 'globals';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { isPackageAvailable } from '../utils.js';
|
|
5
|
+
import bestPractices from './best-practices.js';
|
|
6
|
+
import errors from './errors.js';
|
|
7
|
+
import es6 from './es6.js';
|
|
8
|
+
import formats from './formats.js';
|
|
9
|
+
import imports from './imports.js';
|
|
10
|
+
import jest from './jest.js';
|
|
11
|
+
import lodash from './lodash.js';
|
|
12
|
+
import node from './node.js';
|
|
13
|
+
import postcss from './postcss.js';
|
|
14
|
+
import promises from './promises.js';
|
|
15
|
+
import react from './react.js';
|
|
16
|
+
import reactA11y from './react-a11y.js';
|
|
17
|
+
import storybook from './storybook.js';
|
|
18
|
+
import strict from './strict.js';
|
|
19
|
+
import style from './style.js';
|
|
20
|
+
import variables from './variables.js';
|
|
4
21
|
|
|
5
|
-
const isTSAvailable = isPackageAvailable('typescript');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const bestPractices = require('./best-practices');
|
|
13
|
-
const errors = require('./errors');
|
|
14
|
-
const es6 = require('./es6');
|
|
15
|
-
const imports = require('./imports');
|
|
16
|
-
const node = require('./node');
|
|
17
|
-
const promises = require('./promises');
|
|
18
|
-
const strict = require('./strict');
|
|
19
|
-
const style = require('./style');
|
|
20
|
-
const variables = require('./variables');
|
|
21
|
-
const react = require('./react');
|
|
22
|
-
const lodash = require('./lodash');
|
|
23
|
-
const reactA11y = require('./react-a11y');
|
|
24
|
-
const jest = require('./jest');
|
|
25
|
-
const formats = require('./formats');
|
|
22
|
+
const isTSAvailable = await isPackageAvailable('typescript');
|
|
23
|
+
let tsConfigs = [];
|
|
24
|
+
if (isTSAvailable) {
|
|
25
|
+
tsConfigs = await import('./ts.js');
|
|
26
|
+
}
|
|
27
|
+
const isJestAvailable = await isPackageAvailable('jest');
|
|
26
28
|
|
|
27
29
|
const configs = [
|
|
28
30
|
bestPractices,
|
|
@@ -42,10 +44,6 @@ const configs = [
|
|
|
42
44
|
].filter(Boolean);
|
|
43
45
|
|
|
44
46
|
const overrides = [
|
|
45
|
-
isTSAvailable && {
|
|
46
|
-
files: ['**/*.ts', '**/*.tsx'],
|
|
47
|
-
...ts,
|
|
48
|
-
},
|
|
49
47
|
{
|
|
50
48
|
files: ['*.story.tsx', '*.stories.tsx'],
|
|
51
49
|
...storybook,
|
|
@@ -56,7 +54,7 @@ const overrides = [
|
|
|
56
54
|
},
|
|
57
55
|
].filter(Boolean);
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
export default [
|
|
60
58
|
...configs,
|
|
61
59
|
{
|
|
62
60
|
name: 'base-cabify-eslint-config',
|
|
@@ -72,5 +70,6 @@ module.exports = [
|
|
|
72
70
|
strict: 'error',
|
|
73
71
|
},
|
|
74
72
|
},
|
|
73
|
+
...tsConfigs,
|
|
75
74
|
...overrides,
|
|
76
75
|
];
|
package/configs/errors.js
CHANGED
package/configs/es6.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
name: 'ES6-cabify-eslint-config',
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
languageOptions: {
|
|
6
|
+
ecmaVersion: 6,
|
|
7
|
+
sourceType: 'module',
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.es2015,
|
|
10
|
+
},
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaFeatures: {
|
|
13
|
+
generators: false,
|
|
14
|
+
objectLiteralDuplicateProperties: false,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
16
18
|
|
|
17
19
|
rules: {
|
|
18
20
|
// verify super() callings in constructors
|
package/configs/formats.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
name: 'formats-cabify-eslint-config',
|
|
5
5
|
...eslintPluginPrettierRecommended,
|
|
6
6
|
};
|
package/configs/imports.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import importPlugin from 'eslint-plugin-import';
|
|
2
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
3
|
+
import globals from 'globals';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export default {
|
|
5
6
|
name: 'imports-cabify-eslint-config',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.es2015,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
11
12
|
plugins: {
|
|
12
13
|
import: importPlugin,
|
|
13
14
|
'simple-import-sort': simpleImportSort,
|
package/configs/jest.js
CHANGED
package/configs/lodash.js
CHANGED
package/configs/node.js
CHANGED
package/configs/postcss.js
CHANGED
package/configs/promises.js
CHANGED
package/configs/react-a11y.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import jsxAllyPlugin from 'eslint-plugin-jsx-a11y';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
name: 'react-a11y-cabify-eslint-config',
|
|
5
5
|
plugins: { 'jsx-a11y': jsxAllyPlugin },
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// },
|
|
14
|
-
|
|
6
|
+
languageOptions: {
|
|
7
|
+
parserOptions: {
|
|
8
|
+
ecmaFeatures: {
|
|
9
|
+
jsx: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
15
13
|
rules: {
|
|
16
14
|
// Enforce that anchors have content
|
|
17
15
|
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
|
package/configs/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import react from 'eslint-plugin-react';
|
|
2
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default {
|
|
5
5
|
name: 'react-cabify-eslint-config',
|
|
6
6
|
plugins: {
|
|
7
7
|
react,
|
package/configs/storybook.js
CHANGED
package/configs/strict.js
CHANGED
package/configs/style.js
CHANGED
package/configs/ts.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
|
|
5
|
+
const tsCustomConfig = {
|
|
2
6
|
name: 'ts-cabify-eslint-config',
|
|
3
|
-
|
|
4
|
-
extends: [
|
|
5
|
-
'plugin:@typescript-eslint/recommended',
|
|
6
|
-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
7
|
-
],
|
|
7
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
8
8
|
rules: {
|
|
9
9
|
'@typescript-eslint/restrict-template-expressions': [
|
|
10
10
|
'error',
|
|
@@ -136,9 +136,26 @@ module.exports = {
|
|
|
136
136
|
'no-redeclare': 'off', // superseeded by @typescript-eslint/no-redeclare
|
|
137
137
|
'no-shadow': 'off', // superseeded by @typescript-eslint/no-shadow
|
|
138
138
|
},
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
139
|
+
languageOptions: {
|
|
140
|
+
parserOptions: {
|
|
141
|
+
projectService: true,
|
|
142
|
+
tsconfigRootDir: import.meta.dirname,
|
|
142
143
|
},
|
|
143
|
-
|
|
144
|
+
},
|
|
145
|
+
ignores: ['*.d.ts'],
|
|
144
146
|
};
|
|
147
|
+
|
|
148
|
+
const tsLintConfig = tseslint.config(
|
|
149
|
+
...tseslint.configs.recommended,
|
|
150
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
151
|
+
{ ...tsCustomConfig },
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
if (tsLintConfig.length) {
|
|
155
|
+
tsLintConfig.forEach((tsconfig) => {
|
|
156
|
+
tsconfig.files = ['**/*.ts', '**/*.tsx'];
|
|
157
|
+
tsconfig.ignores = ['**/*.d.ts'];
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default tsLintConfig;
|
package/configs/variables.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import confusingBrowserGlobals from 'confusing-browser-globals';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
name: 'variables-cabify-eslint-config',
|
|
5
5
|
rules: {
|
|
6
6
|
// enforce or disallow variable initializations at definition
|
package/eslint.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabify/eslint-config",
|
|
3
|
-
"version": "3.0.1-beta-
|
|
3
|
+
"version": "3.0.1-beta-9",
|
|
4
4
|
"description": "ESLint config for Cabify Javascript projects",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "echo 'No build to perform'",
|
|
7
8
|
"test": "npm run lint:check && npm run format:check",
|
|
@@ -38,7 +39,6 @@
|
|
|
38
39
|
".": "./recommended.js"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
42
42
|
"@typescript-eslint/parser": "^8.4.0",
|
|
43
43
|
"confusing-browser-globals": "^1.0.10",
|
|
44
44
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -50,14 +50,15 @@
|
|
|
50
50
|
"eslint-plugin-react": "^7.36.0",
|
|
51
51
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
52
52
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
53
|
-
"globals": "^15.9.0"
|
|
53
|
+
"globals": "^15.9.0",
|
|
54
|
+
"typescript-eslint": "^8.8.0"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"eslint": "9.11.0",
|
|
57
|
+
"eslint": ">= 9.11.0",
|
|
57
58
|
"prettier": ">= 2.2.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"eslint": "9.11.
|
|
61
|
+
"eslint": "^9.11.1",
|
|
61
62
|
"prettier": "3.3.3"
|
|
62
63
|
},
|
|
63
64
|
"publishConfig": {
|
package/recommended.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const eslintConfigPrettier = require('eslint-config-prettier');
|
|
1
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
// eslint-disable-next-line import/extensions
|
|
4
|
+
import base from './configs/base.js';
|
|
5
|
+
|
|
6
|
+
export default [...base, eslintConfigPrettier];
|
package/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
+
export async function isPackageAvailable(packageName) {
|
|
3
|
+
try {
|
|
4
|
+
// Dynamically import the package
|
|
5
|
+
await import(packageName);
|
|
6
|
+
return true;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.log(error);
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|