@lidofinance/eslint-config 0.0.1 → 0.11.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/lib/env.js CHANGED
@@ -1,29 +1,60 @@
1
- const fs = require('fs')
2
- const path = require('path')
1
+ const fs = require("fs");
2
+ const path = require("path");
3
3
 
4
- let packageJsonPath = process.cwd()
4
+ let packageJsonPath = process.cwd();
5
5
 
6
- while (!fs.existsSync(path.join(packageJsonPath, 'package.json'))) {
7
- packageJsonPath = path.dirname(packageJsonPath)
8
- if (packageJsonPath === path.resolve('/')) {
9
- packageJsonPath = null
10
- break
11
- }
6
+ while (!fs.existsSync(path.join(packageJsonPath, "package.json"))) {
7
+ packageJsonPath = path.dirname(packageJsonPath);
8
+ if (packageJsonPath === path.resolve("/")) {
9
+ packageJsonPath = null;
10
+ break;
11
+ }
12
12
  }
13
13
 
14
- const packageJson = packageJsonPath === null ? null : require(path.join(packageJsonPath, 'package.json'))
14
+ let workspacePackageJsonPath = packageJsonPath
15
+ ? path.dirname(packageJsonPath)
16
+ : "/";
15
17
 
16
- const has = (...libs) =>
17
- libs.some((name) => {
18
- if (packageJsonPath === null) {
19
- return false
20
- }
21
- return !!packageJson.dependencies?.[name] || !!packageJson.devDependencies?.[name]
22
- })
18
+ while (!fs.existsSync(path.join(workspacePackageJsonPath, "package.json"))) {
19
+ workspacePackageJsonPath = path.dirname(workspacePackageJsonPath);
20
+ if (workspacePackageJsonPath === path.resolve("/")) {
21
+ workspacePackageJsonPath = null;
22
+ break;
23
+ }
24
+ }
23
25
 
24
- module.exports = {
25
- react: has('react'),
26
- next: has('next'),
27
- typescript: has('typescript'),
28
- jest: has('jest'),
26
+ const packageJson =
27
+ packageJsonPath === null
28
+ ? null
29
+ : require(path.join(packageJsonPath, "package.json"));
30
+
31
+ let workspaceJson =
32
+ workspacePackageJsonPath === null
33
+ ? null
34
+ : require(path.join(workspacePackageJsonPath, "package.json"));
35
+
36
+ if (!workspaceJson?.workspaces) {
37
+ workspaceJson = null;
29
38
  }
39
+
40
+ const dependencies = new Set([
41
+ ...(packageJson?.dependencies ? Object.keys(packageJson.dependencies) : []),
42
+ ...(packageJson?.devDependencies
43
+ ? Object.keys(packageJson.devDependencies)
44
+ : []),
45
+ ...(workspaceJson?.dependencies
46
+ ? Object.keys(workspaceJson?.dependencies)
47
+ : []),
48
+ ...(workspaceJson?.devDependencies
49
+ ? Object.keys(workspaceJson?.devDependencies)
50
+ : []),
51
+ ]);
52
+
53
+ const has = (...libs) => libs.some((name) => dependencies.has(name));
54
+
55
+ module.exports = {
56
+ react: has("react"),
57
+ next: has("next"),
58
+ typescript: has("typescript"),
59
+ jest: has("jest"),
60
+ };
package/package.json CHANGED
@@ -1,44 +1,52 @@
1
1
  {
2
2
  "name": "@lidofinance/eslint-config",
3
- "version": "0.0.1",
3
+ "description": "Automated, non-opinionated ESLint config foundation",
4
+ "repository": "git@github.com:lidofinance/warehouse.git",
5
+ "license": "MIT",
6
+ "version": "0.11.0",
4
7
  "main": "auto.js",
5
- "license": "unlicensed (yet)",
6
- "dependencies": {
7
- "typescript": "4.6"
8
- },
9
8
  "scripts": {
10
- "lint": "eslint --fix ."
9
+ "lint": "eslint .",
10
+ "lint:fix": "eslint --fix ."
11
11
  },
12
12
  "peerDependencies": {
13
- "@typescript-eslint/eslint-plugin": "^5.19.0",
14
- "@typescript-eslint/parser": "^5.19.0",
15
- "eslint": "^8.13.0",
16
- "eslint-import-resolver-typescript": "^2.7.1",
17
- "eslint-plugin-eslint-comments": "^3.2.0",
18
- "eslint-plugin-import": "^2.26.0",
19
- "eslint-plugin-jest": "^26.1.4",
20
- "eslint-plugin-promise": "^6.0.0",
21
- "eslint-plugin-react": "^7.29.4",
22
- "eslint-plugin-react-hooks": "^4.4.0",
23
- "eslint-plugin-sonarjs": "^0.13.0",
24
- "eslint-plugin-unicorn": "^42.0.0",
25
- "@next/eslint-plugin-next": "^12.1.6",
26
- "typescript": "4.6"
13
+ "@typescript-eslint/parser": "^5.46.0",
14
+ "@typescript-eslint/eslint-plugin": "^5",
15
+ "eslint-import-resolver-node": "^0.3.6",
16
+ "eslint-config-prettier": "^8.5.0",
17
+ "eslint-import-resolver-typescript": "^3",
18
+ "eslint-plugin-eslint-comments": "^3",
19
+ "eslint-plugin-import": "^2",
20
+ "eslint-plugin-jest": "^27",
21
+ "eslint-plugin-promise": "^6",
22
+ "eslint-plugin-react": "^7",
23
+ "eslint-plugin-react-hooks": "^4",
24
+ "eslint-plugin-sonarjs": "^0.14.0",
25
+ "eslint-plugin-unicorn": "^45",
26
+ "@next/eslint-plugin-next": "^13",
27
+ "eslint-plugin-prettier": "^4",
28
+ "eslint": "^8.29"
29
+ },
30
+ "dependencies": {
31
+ "typescript": "^4.7"
27
32
  },
28
33
  "devDependencies": {
29
- "@typescript-eslint/eslint-plugin": "^5.19.0",
30
- "@typescript-eslint/parser": "^5.19.0",
31
- "eslint": "^8.13.0",
32
- "eslint-plugin-prettier": "^4.0.0",
33
- "eslint-import-resolver-typescript": "^2.7.1",
34
- "eslint-plugin-import": "^2.26.0",
35
- "eslint-plugin-jest": "^26.1.4",
36
- "eslint-plugin-promise": "^6.0.0",
37
- "eslint-plugin-react": "^7.29.4",
38
- "eslint-plugin-react-hooks": "^4.4.0",
39
- "eslint-plugin-sonarjs": "^0.13.0",
40
- "eslint-plugin-unicorn": "^42.0.0",
41
- "@next/eslint-plugin-next": "^12.1.6",
42
- "typescript": "4.6"
34
+ "prettier": "^2.8.0",
35
+ "@typescript-eslint/parser": "^5.46.0",
36
+ "@typescript-eslint/eslint-plugin": "^5",
37
+ "eslint-import-resolver-node": "^0.3.6",
38
+ "eslint-config-prettier": "^8.5.0",
39
+ "eslint-import-resolver-typescript": "^3",
40
+ "eslint-plugin-eslint-comments": "^3",
41
+ "eslint-plugin-import": "^2",
42
+ "eslint-plugin-jest": "^27",
43
+ "eslint-plugin-promise": "^6",
44
+ "eslint-plugin-react": "^7",
45
+ "eslint-plugin-react-hooks": "^4",
46
+ "eslint-plugin-sonarjs": "^0.14.0",
47
+ "eslint-plugin-unicorn": "^45",
48
+ "@next/eslint-plugin-next": "^13",
49
+ "eslint-plugin-prettier": "^4",
50
+ "eslint": "^8.29"
43
51
  }
44
52
  }
package/prettier.js ADDED
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ extends: ["prettier"],
3
+ plugins: ["prettier"],
4
+ rules: {
5
+ "prettier/prettier": [
6
+ "error",
7
+ {
8
+ singleQuote: true,
9
+ printWidth: 120,
10
+ semi: false,
11
+ trailingComma: "all",
12
+ },
13
+ ],
14
+ },
15
+ };