@cabify/eslint-config 3.0.1-beta-7 → 3.0.1-beta-10
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 +5 -5
- package/configs/es6.js +15 -13
- package/configs/imports.js +6 -5
- package/configs/react-a11y.js +7 -9
- package/configs/ts.js +25 -7
- package/package.json +3 -7
- package/utils.js +4 -2
package/configs/base.js
CHANGED
|
@@ -17,10 +17,13 @@ import reactA11y from './react-a11y.js';
|
|
|
17
17
|
import storybook from './storybook.js';
|
|
18
18
|
import strict from './strict.js';
|
|
19
19
|
import style from './style.js';
|
|
20
|
-
import ts from './ts.js';
|
|
21
20
|
import variables from './variables.js';
|
|
22
21
|
|
|
23
22
|
const isTSAvailable = await isPackageAvailable('typescript');
|
|
23
|
+
let tsConfigs = [];
|
|
24
|
+
if (isTSAvailable) {
|
|
25
|
+
tsConfigs = await import('./ts.js');
|
|
26
|
+
}
|
|
24
27
|
const isJestAvailable = await isPackageAvailable('jest');
|
|
25
28
|
|
|
26
29
|
const configs = [
|
|
@@ -41,10 +44,6 @@ const configs = [
|
|
|
41
44
|
].filter(Boolean);
|
|
42
45
|
|
|
43
46
|
const overrides = [
|
|
44
|
-
isTSAvailable && {
|
|
45
|
-
files: ['**/*.ts', '**/*.tsx'],
|
|
46
|
-
...ts,
|
|
47
|
-
},
|
|
48
47
|
{
|
|
49
48
|
files: ['*.story.tsx', '*.stories.tsx'],
|
|
50
49
|
...storybook,
|
|
@@ -71,5 +70,6 @@ export default [
|
|
|
71
70
|
strict: 'error',
|
|
72
71
|
},
|
|
73
72
|
},
|
|
73
|
+
...tsConfigs,
|
|
74
74
|
...overrides,
|
|
75
75
|
];
|
package/configs/es6.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
|
|
1
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/imports.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import importPlugin from 'eslint-plugin-import';
|
|
2
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/react-a11y.js
CHANGED
|
@@ -3,15 +3,13 @@ import jsxAllyPlugin from 'eslint-plugin-jsx-a11y';
|
|
|
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/ts.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
2
3
|
import tseslint from 'typescript-eslint';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const tsCustomConfig = {
|
|
5
6
|
name: 'ts-cabify-eslint-config',
|
|
6
|
-
|
|
7
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
7
8
|
rules: {
|
|
8
9
|
'@typescript-eslint/restrict-template-expressions': [
|
|
9
10
|
'error',
|
|
@@ -135,9 +136,26 @@ export default {
|
|
|
135
136
|
'no-redeclare': 'off', // superseeded by @typescript-eslint/no-redeclare
|
|
136
137
|
'no-shadow': 'off', // superseeded by @typescript-eslint/no-shadow
|
|
137
138
|
},
|
|
138
|
-
|
|
139
|
-
{
|
|
140
|
-
|
|
139
|
+
languageOptions: {
|
|
140
|
+
parserOptions: {
|
|
141
|
+
projectService: true,
|
|
142
|
+
tsconfigRootDir: import.meta.dirname,
|
|
141
143
|
},
|
|
142
|
-
|
|
144
|
+
},
|
|
145
|
+
ignores: ['*.d.ts'],
|
|
143
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabify/eslint-config",
|
|
3
|
-
"version": "3.0.1-beta-
|
|
3
|
+
"version": "3.0.1-beta-10",
|
|
4
4
|
"description": "ESLint config for Cabify Javascript projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
".": "./recommended.js"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
43
42
|
"@typescript-eslint/parser": "^8.4.0",
|
|
44
43
|
"confusing-browser-globals": "^1.0.10",
|
|
45
44
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -55,15 +54,12 @@
|
|
|
55
54
|
"typescript-eslint": "^8.8.0"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
|
-
"eslint": "9.11.0",
|
|
57
|
+
"eslint": ">= 9.11.0",
|
|
59
58
|
"prettier": ">= 2.2.1"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@eslint/js": "^9.11.1",
|
|
63
|
-
"@types/eslint__js": "^8.42.3",
|
|
64
61
|
"eslint": "^9.11.1",
|
|
65
|
-
"prettier": "3.3.3"
|
|
66
|
-
"typescript": "^5.6.2"
|
|
62
|
+
"prettier": "3.3.3"
|
|
67
63
|
},
|
|
68
64
|
"publishConfig": {
|
|
69
65
|
"access": "public"
|
package/utils.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
// eslint-disable-next-line import/prefer-default-export
|
|
3
2
|
export async function isPackageAvailable(packageName) {
|
|
4
3
|
try {
|
|
5
4
|
// Dynamically import the package
|
|
6
5
|
await import(packageName);
|
|
6
|
+
console.log(`Package ${packageName} is available`);
|
|
7
7
|
return true;
|
|
8
|
-
} catch (
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.log(error);
|
|
10
|
+
console.log(`Package ${packageName} is not available`);
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
13
|
}
|