@dfinity/eslint-config-oisy-wallet 0.2.3 → 0.3.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/configs/eslint.rules.mjs
CHANGED
|
@@ -67,7 +67,22 @@ export const eslintRules = [
|
|
|
67
67
|
|
|
68
68
|
"local-rules/prefer-object-params": "warn",
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// We want to enforce ONLY `'newlines-between': 'never'`. The order/sorting is handled elsewhere.
|
|
71
|
+
"import/order": [
|
|
72
|
+
"error",
|
|
73
|
+
{
|
|
74
|
+
// disable all default grouping behaviour
|
|
75
|
+
groups: [],
|
|
76
|
+
|
|
77
|
+
// disable alphabetising
|
|
78
|
+
alphabetize: {
|
|
79
|
+
order: "ignore",
|
|
80
|
+
caseInsensitive: false,
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
"newlines-between": "never",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
71
86
|
"import/no-relative-parent-imports": "error",
|
|
72
87
|
|
|
73
88
|
"object-shorthand": "error",
|
|
@@ -75,6 +90,7 @@ export const eslintRules = [
|
|
|
75
90
|
"no-console": ["error", { allow: ["error", "warn"] }],
|
|
76
91
|
"no-continue": "warn",
|
|
77
92
|
"no-delete-var": "error",
|
|
93
|
+
"no-duplicate-imports": "error",
|
|
78
94
|
"no-else-return": ["warn", { allowElseIf: false }],
|
|
79
95
|
"no-restricted-imports": [
|
|
80
96
|
"error",
|
package/eslint-local-rules.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"no-svelte-store-in-api": require("./rules/no-svelte-store-in-api.cjs"),
|
|
3
|
-
"use-option-type-wrapper": require("./rules/use-
|
|
3
|
+
"use-option-type-wrapper": require("./rules/use-nullish-type-wrapper.cjs"),
|
|
4
4
|
"prefer-object-params": require("./rules/prefer-object-params.cjs"),
|
|
5
5
|
"no-relative-imports": require("./rules/no-relative-imports.cjs"),
|
|
6
6
|
"explicit-non-void-return-type": require("./rules/explicit-non-void-return-type.cjs"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfinity/eslint-config-oisy-wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Shared ESLint configurations from the Oisy Wallet team",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"format:check": "prettier --check .",
|
|
45
45
|
"lint": "eslint .",
|
|
46
46
|
"lint:fix": "eslint --fix .",
|
|
47
|
-
"test": "vitest --run"
|
|
47
|
+
"test": "vitest --run",
|
|
48
|
+
"update:peer": "npm update $(node -e \"const p=require('./package.json');console.log(Object.keys(p.peerDependencies).filter(d=>/eslint|prettier/.test(d)).join(' '))\")"
|
|
48
49
|
},
|
|
49
50
|
"keywords": [
|
|
50
51
|
"eslint",
|
|
@@ -64,30 +65,30 @@
|
|
|
64
65
|
],
|
|
65
66
|
"peerDependencies": {
|
|
66
67
|
"@dfinity/utils": "*",
|
|
67
|
-
"@eslint/compat": "^
|
|
68
|
-
"@eslint/eslintrc": "^3.3.
|
|
69
|
-
"@eslint/js": "^9.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
71
|
-
"@vitest/eslint-plugin": "^1.
|
|
72
|
-
"eslint": "^9.
|
|
73
|
-
"eslint-config-love": "^122.0.0",
|
|
68
|
+
"@eslint/compat": "^2.0.2",
|
|
69
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
70
|
+
"@eslint/js": "^9.39.2",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
72
|
+
"@vitest/eslint-plugin": "^1.6.9",
|
|
73
|
+
"eslint": "^9.39.2",
|
|
74
74
|
"eslint-config-prettier": "^10.1.8",
|
|
75
75
|
"eslint-plugin-import": "^2.32.0",
|
|
76
76
|
"eslint-plugin-local-rules": "^3.0.2",
|
|
77
|
-
"eslint-plugin-n": "^17.
|
|
77
|
+
"eslint-plugin-n": "^17.24.0",
|
|
78
78
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
79
|
-
"eslint-plugin-prettier": "^5.5.
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
80
80
|
"eslint-plugin-promise": "^7.2.1",
|
|
81
|
-
"eslint-plugin-svelte": "^3",
|
|
82
|
-
"globals": "^
|
|
83
|
-
"prettier": "^3.
|
|
84
|
-
"prettier-plugin-organize-imports": "^4.
|
|
85
|
-
"typescript": "^5"
|
|
81
|
+
"eslint-plugin-svelte": "^3.15.0",
|
|
82
|
+
"globals": "^17.3.0",
|
|
83
|
+
"prettier": "^3.8.1",
|
|
84
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
85
|
+
"typescript": "^5",
|
|
86
|
+
"typescript-eslint": "^8.56.0"
|
|
86
87
|
},
|
|
87
88
|
"devDependencies": {
|
|
88
|
-
"@types/node": "^
|
|
89
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
90
|
-
"vitest": "^4.0.
|
|
89
|
+
"@types/node": "^25.3.0",
|
|
90
|
+
"@typescript-eslint/rule-tester": "^8.56.0",
|
|
91
|
+
"vitest": "^4.0.18"
|
|
91
92
|
},
|
|
92
93
|
"engines": {
|
|
93
94
|
"node": ">=22",
|
|
@@ -2,19 +2,19 @@ module.exports = {
|
|
|
2
2
|
meta: {
|
|
3
3
|
type: "suggestion",
|
|
4
4
|
docs: {
|
|
5
|
-
description: "Enforce use of
|
|
5
|
+
description: "Enforce use of Nullish<T> instead of T | null | undefined",
|
|
6
6
|
category: "Best Practices",
|
|
7
7
|
recommended: false,
|
|
8
8
|
},
|
|
9
9
|
messages: {
|
|
10
|
-
|
|
11
|
-
"Use
|
|
10
|
+
useNullish:
|
|
11
|
+
"Use Nullish<{{ type }}> instead of {{ type }} | null | undefined.",
|
|
12
12
|
},
|
|
13
13
|
fixable: "code",
|
|
14
14
|
schema: [],
|
|
15
15
|
},
|
|
16
16
|
create: (context) => {
|
|
17
|
-
const
|
|
17
|
+
const checkForNullishType = (node) => {
|
|
18
18
|
if (
|
|
19
19
|
node.typeAnnotation.type === "TSUnionType" &&
|
|
20
20
|
node.typeAnnotation.types.length === 3 &&
|
|
@@ -34,12 +34,12 @@ module.exports = {
|
|
|
34
34
|
try {
|
|
35
35
|
context.report({
|
|
36
36
|
node,
|
|
37
|
-
messageId: "
|
|
37
|
+
messageId: "useNullish",
|
|
38
38
|
data: {
|
|
39
39
|
type: typeText,
|
|
40
40
|
},
|
|
41
41
|
fix: (fixer) =>
|
|
42
|
-
fixer.replaceText(node.typeAnnotation, `
|
|
42
|
+
fixer.replaceText(node.typeAnnotation, `Nullish<${typeText}>`),
|
|
43
43
|
});
|
|
44
44
|
} catch (e) {
|
|
45
45
|
console.error(e);
|
|
@@ -52,10 +52,10 @@ module.exports = {
|
|
|
52
52
|
|
|
53
53
|
return {
|
|
54
54
|
TSTypeAnnotation: (node) => {
|
|
55
|
-
|
|
55
|
+
checkForNullishType(node);
|
|
56
56
|
},
|
|
57
57
|
TSTypeAliasDeclaration: (node) => {
|
|
58
|
-
|
|
58
|
+
checkForNullishType(node);
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
},
|