@kamaal111/kamaal-quality-config 0.0.4 → 0.2.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 +28 -8
- package/dist/index.d.ts +82 -72
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -68
- package/dist/index.js.map +1 -1
- package/dist/oxlint.d.ts +78 -0
- package/dist/oxlint.d.ts.map +1 -0
- package/dist/oxlint.js +86 -0
- package/dist/oxlint.js.map +1 -0
- package/dist/oxlintrc.json +10 -0
- package/dist/plugins/consistent-inline-type-imports.d.ts +36 -0
- package/dist/plugins/consistent-inline-type-imports.d.ts.map +1 -0
- package/dist/plugins/consistent-inline-type-imports.js +47 -0
- package/dist/plugins/consistent-inline-type-imports.js.map +1 -0
- package/dist/plugins/no-nullish-check-first-ternary.d.ts +45 -0
- package/dist/plugins/no-nullish-check-first-ternary.d.ts.map +1 -0
- package/dist/plugins/no-nullish-check-first-ternary.js +52 -0
- package/dist/plugins/no-nullish-check-first-ternary.js.map +1 -0
- package/dist/plugins/rule-context.d.ts +19 -0
- package/dist/plugins/rule-context.d.ts.map +1 -0
- package/dist/plugins/rule-context.js +2 -0
- package/dist/plugins/rule-context.js.map +1 -0
- package/package.json +14 -4
- package/src/plugins/consistent-inline-type-imports.ts +76 -0
- package/src/plugins/no-nullish-check-first-ternary.ts +102 -0
package/README.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# @kamaal111/kamaal-quality-config
|
|
2
2
|
|
|
3
|
-
Kamaal Farah's shared [oxlint](https://oxc.rs) quality
|
|
3
|
+
Kamaal Farah's shared [oxlint](https://oxc.rs) quality configs.
|
|
4
4
|
|
|
5
5
|
Currently enables every rule from [`@kamaal111/oxlint-plugin-anti-slop`](https://github.com/kamaal111/anti-slop),
|
|
6
6
|
Kamaal's fork of [`dmmulroy/anti-slop`](https://github.com/dmmulroy/anti-slop), plus a curated set of
|
|
7
7
|
rules from oxlint's built-in `typescript`, `unicorn`, `oxc`, and `vitest` plugins and from
|
|
8
|
-
`eslint-plugin-import` (via oxlint's `jsPlugins`)
|
|
8
|
+
`eslint-plugin-import` (via oxlint's `jsPlugins`), plus two hand-written local rules:
|
|
9
|
+
|
|
10
|
+
- `kamaal-imports/no-all-inline-type-imports` — forbids `import { type A, type B } from 'x'` in favor
|
|
11
|
+
of a top-level `import type { A, B } from 'x'`.
|
|
12
|
+
- `kamaal-ternary/no-nullish-check-first-ternary` — forbids ternaries that check for a nullish value
|
|
13
|
+
first (e.g. `x == null ? undefined : x.trim()`), requiring the value-producing branch first instead
|
|
14
|
+
(`x != null ? x.trim() : undefined`).
|
|
15
|
+
|
|
16
|
+
More rule sources will be folded in over time.
|
|
9
17
|
|
|
10
18
|
## Table of contents
|
|
11
19
|
|
|
@@ -37,20 +45,30 @@ Extend it from your `.oxlintrc.json`:
|
|
|
37
45
|
The package ships a plain, statically-generated `dist/oxlintrc.json` — no `oxlint.config.ts` or
|
|
38
46
|
package-import support is needed, since `.oxlintrc.json`'s `extends` field accepts plain file paths.
|
|
39
47
|
|
|
40
|
-
Alternatively, if your project already uses `oxlint.config.ts`,
|
|
41
|
-
JS object instead:
|
|
48
|
+
Alternatively, if your project already uses `oxlint.config.ts`, import the config directly:
|
|
42
49
|
|
|
43
50
|
```ts
|
|
44
|
-
import
|
|
51
|
+
import kamaalOxlintConfig from '@kamaal111/kamaal-quality-config/oxlint';
|
|
45
52
|
import { defineConfig } from 'oxlint';
|
|
46
53
|
|
|
47
54
|
export default defineConfig({
|
|
48
|
-
extends: [
|
|
55
|
+
extends: [kamaalOxlintConfig],
|
|
49
56
|
});
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
The package root also exposes every config through a namespace object:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import kamaalQuality from '@kamaal111/kamaal-quality-config';
|
|
63
|
+
import { defineConfig } from 'oxlint';
|
|
64
|
+
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
extends: [kamaalQuality.oxlint],
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Both forms carry the same rules — `dist/oxlintrc.json` is generated from the oxlint config at build
|
|
71
|
+
time.
|
|
54
72
|
|
|
55
73
|
### oxfmt
|
|
56
74
|
|
|
@@ -69,6 +87,8 @@ export default defineConfig({
|
|
|
69
87
|
});
|
|
70
88
|
```
|
|
71
89
|
|
|
90
|
+
The same style is also available as `kamaalQuality.oxfmt` from the package-root namespace.
|
|
91
|
+
|
|
72
92
|
`./oxfmt` exports a plain style object (`printWidth`, `arrowParens`, `singleQuote`) with no
|
|
73
93
|
`ignorePatterns` — those are inherently project-specific, so each consumer supplies its own via the
|
|
74
94
|
spread above.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,77 +1,87 @@
|
|
|
1
|
+
import oxfmt from './oxfmt.ts';
|
|
2
|
+
import oxlint from './oxlint.ts';
|
|
3
|
+
export { oxfmt, oxlint };
|
|
1
4
|
declare const _default: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}[];
|
|
7
|
-
options: {
|
|
8
|
-
typeAware: true;
|
|
5
|
+
oxfmt: {
|
|
6
|
+
readonly printWidth: 120;
|
|
7
|
+
readonly arrowParens: 'avoid';
|
|
8
|
+
readonly singleQuote: true;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
10
|
+
oxlint: {
|
|
11
|
+
plugins: ("oxc" | "typescript" | "unicorn" | "vitest")[];
|
|
12
|
+
jsPlugins: {
|
|
13
|
+
name: string;
|
|
14
|
+
specifier: string;
|
|
15
|
+
}[];
|
|
16
|
+
options: {
|
|
17
|
+
typeAware: true;
|
|
18
|
+
};
|
|
19
|
+
categories: {
|
|
20
|
+
correctness: "error";
|
|
21
|
+
};
|
|
22
|
+
rules: {
|
|
23
|
+
curly: "error";
|
|
24
|
+
'typescript/no-deprecated': "error";
|
|
25
|
+
'typescript/consistent-type-imports': "error";
|
|
26
|
+
'typescript/no-non-null-assertion': "error";
|
|
27
|
+
'typescript/consistent-type-assertions': ["error", {
|
|
28
|
+
assertionStyle: "never";
|
|
29
|
+
}];
|
|
30
|
+
'typescript/no-explicit-any': "error";
|
|
31
|
+
'typescript/ban-ts-comment': ["error", {
|
|
32
|
+
minimumDescriptionLength: number;
|
|
33
|
+
}];
|
|
34
|
+
'typescript/no-duplicate-enum-values': "error";
|
|
35
|
+
'typescript/no-empty-object-type': "error";
|
|
36
|
+
'typescript/no-extra-non-null-assertion': "error";
|
|
37
|
+
'typescript/no-misused-new': "error";
|
|
38
|
+
'typescript/no-namespace': "error";
|
|
39
|
+
'typescript/no-non-null-asserted-optional-chain': "error";
|
|
40
|
+
'typescript/no-require-imports': "error";
|
|
41
|
+
'typescript/no-this-alias': "error";
|
|
42
|
+
'typescript/no-unnecessary-type-constraint': "error";
|
|
43
|
+
'typescript/no-unsafe-declaration-merging': "error";
|
|
44
|
+
'typescript/no-unsafe-function-type': "error";
|
|
45
|
+
'typescript/no-wrapper-object-types': "error";
|
|
46
|
+
'typescript/prefer-as-const': "error";
|
|
47
|
+
'typescript/prefer-namespace-keyword': "error";
|
|
48
|
+
'typescript/triple-slash-reference': "error";
|
|
49
|
+
'typescript/no-dynamic-delete': "error";
|
|
50
|
+
'typescript/no-extraneous-class': "error";
|
|
51
|
+
'typescript/no-invalid-void-type': "error";
|
|
52
|
+
'typescript/no-non-null-asserted-nullish-coalescing': "error";
|
|
53
|
+
'typescript/prefer-literal-enum-member': "error";
|
|
54
|
+
'typescript/unified-signatures': "error";
|
|
55
|
+
'typescript/adjacent-overload-signatures': "error";
|
|
56
|
+
'typescript/array-type': "error";
|
|
57
|
+
'typescript/ban-tslint-comment': "error";
|
|
58
|
+
'typescript/class-literal-property-style': "error";
|
|
59
|
+
'typescript/consistent-generic-constructors': "error";
|
|
60
|
+
'typescript/consistent-indexed-object-style': "error";
|
|
61
|
+
'typescript/consistent-type-definitions': "error";
|
|
62
|
+
'typescript/no-confusing-non-null-assertion': "error";
|
|
63
|
+
'typescript/no-inferrable-types': "error";
|
|
64
|
+
'typescript/prefer-for-of': "error";
|
|
65
|
+
'typescript/prefer-function-type': "error";
|
|
66
|
+
'oxc/no-accumulating-spread': "error";
|
|
67
|
+
'vitest/no-conditional-expect': "error";
|
|
68
|
+
'vitest/expect-expect': "error";
|
|
69
|
+
'anti-slop/no-runtime-typeof': ["error", {
|
|
70
|
+
allowInTypeGuards: boolean;
|
|
71
|
+
}];
|
|
72
|
+
'unicorn/no-abusive-eslint-disable': "error";
|
|
73
|
+
'import-js/order': ["error", {
|
|
74
|
+
groups: (string | string[])[];
|
|
75
|
+
'newlines-between': "always";
|
|
76
|
+
alphabetize: {
|
|
77
|
+
order: string;
|
|
78
|
+
caseInsensitive: boolean;
|
|
79
|
+
};
|
|
80
|
+
}];
|
|
81
|
+
};
|
|
82
|
+
env: {
|
|
83
|
+
builtin: true;
|
|
84
|
+
};
|
|
75
85
|
};
|
|
76
86
|
};
|
|
77
87
|
export default _default;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
plugins: ['typescript', 'unicorn', 'oxc', 'vitest'],
|
|
6
|
-
jsPlugins: [
|
|
7
|
-
{ name: 'anti-slop', specifier: '@kamaal111/oxlint-plugin-anti-slop' },
|
|
8
|
-
{ name: 'import-js', specifier: 'eslint-plugin-import' },
|
|
9
|
-
],
|
|
10
|
-
options: { typeAware: true },
|
|
11
|
-
categories: { correctness: 'error' },
|
|
12
|
-
rules: {
|
|
13
|
-
...antiSlopRules,
|
|
14
|
-
curly: 'error',
|
|
15
|
-
'typescript/no-deprecated': 'error',
|
|
16
|
-
'typescript/consistent-type-imports': 'error',
|
|
17
|
-
'typescript/no-non-null-assertion': 'error',
|
|
18
|
-
'typescript/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
|
|
19
|
-
'typescript/no-explicit-any': 'error',
|
|
20
|
-
'typescript/ban-ts-comment': ['error', { minimumDescriptionLength: 10 }],
|
|
21
|
-
'typescript/no-duplicate-enum-values': 'error',
|
|
22
|
-
'typescript/no-empty-object-type': 'error',
|
|
23
|
-
'typescript/no-extra-non-null-assertion': 'error',
|
|
24
|
-
'typescript/no-misused-new': 'error',
|
|
25
|
-
'typescript/no-namespace': 'error',
|
|
26
|
-
'typescript/no-non-null-asserted-optional-chain': 'error',
|
|
27
|
-
'typescript/no-require-imports': 'error',
|
|
28
|
-
'typescript/no-this-alias': 'error',
|
|
29
|
-
'typescript/no-unnecessary-type-constraint': 'error',
|
|
30
|
-
'typescript/no-unsafe-declaration-merging': 'error',
|
|
31
|
-
'typescript/no-unsafe-function-type': 'error',
|
|
32
|
-
'typescript/no-wrapper-object-types': 'error',
|
|
33
|
-
'typescript/prefer-as-const': 'error',
|
|
34
|
-
'typescript/prefer-namespace-keyword': 'error',
|
|
35
|
-
'typescript/triple-slash-reference': 'error',
|
|
36
|
-
'typescript/no-dynamic-delete': 'error',
|
|
37
|
-
'typescript/no-extraneous-class': 'error',
|
|
38
|
-
'typescript/no-invalid-void-type': 'error',
|
|
39
|
-
'typescript/no-non-null-asserted-nullish-coalescing': 'error',
|
|
40
|
-
'typescript/prefer-literal-enum-member': 'error',
|
|
41
|
-
'typescript/unified-signatures': 'error',
|
|
42
|
-
'typescript/adjacent-overload-signatures': 'error',
|
|
43
|
-
'typescript/array-type': 'error',
|
|
44
|
-
'typescript/ban-tslint-comment': 'error',
|
|
45
|
-
'typescript/class-literal-property-style': 'error',
|
|
46
|
-
'typescript/consistent-generic-constructors': 'error',
|
|
47
|
-
'typescript/consistent-indexed-object-style': 'error',
|
|
48
|
-
'typescript/consistent-type-definitions': 'error',
|
|
49
|
-
'typescript/no-confusing-non-null-assertion': 'error',
|
|
50
|
-
'typescript/no-inferrable-types': 'error',
|
|
51
|
-
'typescript/prefer-for-of': 'error',
|
|
52
|
-
'typescript/prefer-function-type': 'error',
|
|
53
|
-
'oxc/no-accumulating-spread': 'error',
|
|
54
|
-
'vitest/no-conditional-expect': 'error',
|
|
55
|
-
'vitest/expect-expect': 'error',
|
|
56
|
-
'anti-slop/no-runtime-typeof': ['error', { allowInTypeGuards: true }],
|
|
57
|
-
'unicorn/no-abusive-eslint-disable': 'error',
|
|
58
|
-
'import-js/order': [
|
|
59
|
-
'error',
|
|
60
|
-
{
|
|
61
|
-
groups: ['builtin', 'external', ['internal', 'parent', 'sibling', 'index']],
|
|
62
|
-
'newlines-between': 'always',
|
|
63
|
-
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
env: { builtin: true },
|
|
68
|
-
});
|
|
1
|
+
import oxfmt from './oxfmt.js';
|
|
2
|
+
import oxlint from './oxlint.js';
|
|
3
|
+
export { oxfmt, oxlint };
|
|
4
|
+
export default { oxfmt, oxlint };
|
|
69
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAEzB,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/oxlint.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
plugins: ("oxc" | "typescript" | "unicorn" | "vitest")[];
|
|
3
|
+
jsPlugins: {
|
|
4
|
+
name: string;
|
|
5
|
+
specifier: string;
|
|
6
|
+
}[];
|
|
7
|
+
options: {
|
|
8
|
+
typeAware: true;
|
|
9
|
+
};
|
|
10
|
+
categories: {
|
|
11
|
+
correctness: "error";
|
|
12
|
+
};
|
|
13
|
+
rules: {
|
|
14
|
+
curly: "error";
|
|
15
|
+
'typescript/no-deprecated': "error";
|
|
16
|
+
'typescript/consistent-type-imports': "error";
|
|
17
|
+
'typescript/no-non-null-assertion': "error";
|
|
18
|
+
'typescript/consistent-type-assertions': ["error", {
|
|
19
|
+
assertionStyle: "never";
|
|
20
|
+
}];
|
|
21
|
+
'typescript/no-explicit-any': "error";
|
|
22
|
+
'typescript/ban-ts-comment': ["error", {
|
|
23
|
+
minimumDescriptionLength: number;
|
|
24
|
+
}];
|
|
25
|
+
'typescript/no-duplicate-enum-values': "error";
|
|
26
|
+
'typescript/no-empty-object-type': "error";
|
|
27
|
+
'typescript/no-extra-non-null-assertion': "error";
|
|
28
|
+
'typescript/no-misused-new': "error";
|
|
29
|
+
'typescript/no-namespace': "error";
|
|
30
|
+
'typescript/no-non-null-asserted-optional-chain': "error";
|
|
31
|
+
'typescript/no-require-imports': "error";
|
|
32
|
+
'typescript/no-this-alias': "error";
|
|
33
|
+
'typescript/no-unnecessary-type-constraint': "error";
|
|
34
|
+
'typescript/no-unsafe-declaration-merging': "error";
|
|
35
|
+
'typescript/no-unsafe-function-type': "error";
|
|
36
|
+
'typescript/no-wrapper-object-types': "error";
|
|
37
|
+
'typescript/prefer-as-const': "error";
|
|
38
|
+
'typescript/prefer-namespace-keyword': "error";
|
|
39
|
+
'typescript/triple-slash-reference': "error";
|
|
40
|
+
'typescript/no-dynamic-delete': "error";
|
|
41
|
+
'typescript/no-extraneous-class': "error";
|
|
42
|
+
'typescript/no-invalid-void-type': "error";
|
|
43
|
+
'typescript/no-non-null-asserted-nullish-coalescing': "error";
|
|
44
|
+
'typescript/prefer-literal-enum-member': "error";
|
|
45
|
+
'typescript/unified-signatures': "error";
|
|
46
|
+
'typescript/adjacent-overload-signatures': "error";
|
|
47
|
+
'typescript/array-type': "error";
|
|
48
|
+
'typescript/ban-tslint-comment': "error";
|
|
49
|
+
'typescript/class-literal-property-style': "error";
|
|
50
|
+
'typescript/consistent-generic-constructors': "error";
|
|
51
|
+
'typescript/consistent-indexed-object-style': "error";
|
|
52
|
+
'typescript/consistent-type-definitions': "error";
|
|
53
|
+
'typescript/no-confusing-non-null-assertion': "error";
|
|
54
|
+
'typescript/no-inferrable-types': "error";
|
|
55
|
+
'typescript/prefer-for-of': "error";
|
|
56
|
+
'typescript/prefer-function-type': "error";
|
|
57
|
+
'oxc/no-accumulating-spread': "error";
|
|
58
|
+
'vitest/no-conditional-expect': "error";
|
|
59
|
+
'vitest/expect-expect': "error";
|
|
60
|
+
'anti-slop/no-runtime-typeof': ["error", {
|
|
61
|
+
allowInTypeGuards: boolean;
|
|
62
|
+
}];
|
|
63
|
+
'unicorn/no-abusive-eslint-disable': "error";
|
|
64
|
+
'import-js/order': ["error", {
|
|
65
|
+
groups: (string | string[])[];
|
|
66
|
+
'newlines-between': "always";
|
|
67
|
+
alphabetize: {
|
|
68
|
+
order: string;
|
|
69
|
+
caseInsensitive: boolean;
|
|
70
|
+
};
|
|
71
|
+
}];
|
|
72
|
+
};
|
|
73
|
+
env: {
|
|
74
|
+
builtin: true;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export default _default;
|
|
78
|
+
//# sourceMappingURL=oxlint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.d.ts","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2FuB,KAAK;gBAAS,eAAe"}
|
package/dist/oxlint.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import antiSlopPlugin from '@kamaal111/oxlint-plugin-anti-slop';
|
|
2
|
+
import { defineConfig } from 'oxlint';
|
|
3
|
+
import consistentInlineTypeImportsPlugin from './plugins/consistent-inline-type-imports.js';
|
|
4
|
+
import noNullishCheckFirstTernaryPlugin from './plugins/no-nullish-check-first-ternary.js';
|
|
5
|
+
function pluginRules(namespace, ruleNames) {
|
|
6
|
+
return Object.fromEntries(ruleNames.map(ruleName => [`${namespace}/${ruleName}`, 'error']));
|
|
7
|
+
}
|
|
8
|
+
const antiSlopRules = pluginRules('anti-slop', Object.keys(antiSlopPlugin.rules));
|
|
9
|
+
const consistentInlineTypeImportsRules = pluginRules(consistentInlineTypeImportsPlugin.meta.name, Object.keys(consistentInlineTypeImportsPlugin.rules));
|
|
10
|
+
const noNullishCheckFirstTernaryRules = pluginRules(noNullishCheckFirstTernaryPlugin.meta.name, Object.keys(noNullishCheckFirstTernaryPlugin.rules));
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
plugins: ['typescript', 'unicorn', 'oxc', 'vitest'],
|
|
13
|
+
jsPlugins: [
|
|
14
|
+
{ name: 'anti-slop', specifier: '@kamaal111/oxlint-plugin-anti-slop' },
|
|
15
|
+
{ name: 'import-js', specifier: 'eslint-plugin-import' },
|
|
16
|
+
{
|
|
17
|
+
name: consistentInlineTypeImportsPlugin.meta.name,
|
|
18
|
+
specifier: '@kamaal111/kamaal-quality-config/plugins/consistent-inline-type-imports',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: noNullishCheckFirstTernaryPlugin.meta.name,
|
|
22
|
+
specifier: '@kamaal111/kamaal-quality-config/plugins/no-nullish-check-first-ternary',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
options: { typeAware: true },
|
|
26
|
+
categories: { correctness: 'error' },
|
|
27
|
+
rules: {
|
|
28
|
+
...antiSlopRules,
|
|
29
|
+
...consistentInlineTypeImportsRules,
|
|
30
|
+
...noNullishCheckFirstTernaryRules,
|
|
31
|
+
curly: 'error',
|
|
32
|
+
'typescript/no-deprecated': 'error',
|
|
33
|
+
'typescript/consistent-type-imports': 'error',
|
|
34
|
+
'typescript/no-non-null-assertion': 'error',
|
|
35
|
+
'typescript/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
|
|
36
|
+
'typescript/no-explicit-any': 'error',
|
|
37
|
+
'typescript/ban-ts-comment': ['error', { minimumDescriptionLength: 10 }],
|
|
38
|
+
'typescript/no-duplicate-enum-values': 'error',
|
|
39
|
+
'typescript/no-empty-object-type': 'error',
|
|
40
|
+
'typescript/no-extra-non-null-assertion': 'error',
|
|
41
|
+
'typescript/no-misused-new': 'error',
|
|
42
|
+
'typescript/no-namespace': 'error',
|
|
43
|
+
'typescript/no-non-null-asserted-optional-chain': 'error',
|
|
44
|
+
'typescript/no-require-imports': 'error',
|
|
45
|
+
'typescript/no-this-alias': 'error',
|
|
46
|
+
'typescript/no-unnecessary-type-constraint': 'error',
|
|
47
|
+
'typescript/no-unsafe-declaration-merging': 'error',
|
|
48
|
+
'typescript/no-unsafe-function-type': 'error',
|
|
49
|
+
'typescript/no-wrapper-object-types': 'error',
|
|
50
|
+
'typescript/prefer-as-const': 'error',
|
|
51
|
+
'typescript/prefer-namespace-keyword': 'error',
|
|
52
|
+
'typescript/triple-slash-reference': 'error',
|
|
53
|
+
'typescript/no-dynamic-delete': 'error',
|
|
54
|
+
'typescript/no-extraneous-class': 'error',
|
|
55
|
+
'typescript/no-invalid-void-type': 'error',
|
|
56
|
+
'typescript/no-non-null-asserted-nullish-coalescing': 'error',
|
|
57
|
+
'typescript/prefer-literal-enum-member': 'error',
|
|
58
|
+
'typescript/unified-signatures': 'error',
|
|
59
|
+
'typescript/adjacent-overload-signatures': 'error',
|
|
60
|
+
'typescript/array-type': 'error',
|
|
61
|
+
'typescript/ban-tslint-comment': 'error',
|
|
62
|
+
'typescript/class-literal-property-style': 'error',
|
|
63
|
+
'typescript/consistent-generic-constructors': 'error',
|
|
64
|
+
'typescript/consistent-indexed-object-style': 'error',
|
|
65
|
+
'typescript/consistent-type-definitions': 'error',
|
|
66
|
+
'typescript/no-confusing-non-null-assertion': 'error',
|
|
67
|
+
'typescript/no-inferrable-types': 'error',
|
|
68
|
+
'typescript/prefer-for-of': 'error',
|
|
69
|
+
'typescript/prefer-function-type': 'error',
|
|
70
|
+
'oxc/no-accumulating-spread': 'error',
|
|
71
|
+
'vitest/no-conditional-expect': 'error',
|
|
72
|
+
'vitest/expect-expect': 'error',
|
|
73
|
+
'anti-slop/no-runtime-typeof': ['error', { allowInTypeGuards: true }],
|
|
74
|
+
'unicorn/no-abusive-eslint-disable': 'error',
|
|
75
|
+
'import-js/order': [
|
|
76
|
+
'error',
|
|
77
|
+
{
|
|
78
|
+
groups: ['builtin', 'external', ['internal', 'parent', 'sibling', 'index']],
|
|
79
|
+
'newlines-between': 'always',
|
|
80
|
+
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
env: { builtin: true },
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=oxlint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,iCAAiC,MAAM,6CAA6C,CAAC;AAC5F,OAAO,gCAAgC,MAAM,6CAA6C,CAAC;AAE3F,SAAS,WAAW,CAAC,SAAiB,EAAE,SAAmB;IACzD,OAAO,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,EAAE,OAAO,CAAU,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAElF,MAAM,gCAAgC,GAAG,WAAW,CAClD,iCAAiC,CAAC,IAAI,CAAC,IAAI,EAC3C,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,KAAK,CAAC,CACrD,CAAC;AAEF,MAAM,+BAA+B,GAAG,WAAW,CACjD,gCAAgC,CAAC,IAAI,CAAC,IAAI,EAC1C,MAAM,CAAC,IAAI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"kamaal-imports",
|
|
19
|
+
"specifier": "@kamaal111/kamaal-quality-config/plugins/consistent-inline-type-imports"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "kamaal-ternary",
|
|
23
|
+
"specifier": "@kamaal111/kamaal-quality-config/plugins/no-nullish-check-first-ternary"
|
|
16
24
|
}
|
|
17
25
|
],
|
|
18
26
|
"options": {
|
|
@@ -45,6 +53,8 @@
|
|
|
45
53
|
"anti-slop/no-widen-then-assert": "error",
|
|
46
54
|
"anti-slop/require-readable-spacing": "error",
|
|
47
55
|
"anti-slop/require-safety-comment-for-type-assertion": "error",
|
|
56
|
+
"kamaal-imports/no-all-inline-type-imports": "error",
|
|
57
|
+
"kamaal-ternary/no-nullish-check-first-ternary": "error",
|
|
48
58
|
"curly": "error",
|
|
49
59
|
"typescript/no-deprecated": "error",
|
|
50
60
|
"typescript/consistent-type-imports": "error",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AstNode, RuleContext } from './rule-context.ts';
|
|
2
|
+
interface ImportSpecifierNode extends AstNode {
|
|
3
|
+
type: 'ImportSpecifier';
|
|
4
|
+
importKind?: 'type' | 'value';
|
|
5
|
+
imported: {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
local: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ImportDeclarationNode extends AstNode {
|
|
13
|
+
type: 'ImportDeclaration';
|
|
14
|
+
importKind?: 'type' | 'value';
|
|
15
|
+
specifiers: (ImportSpecifierNode | {
|
|
16
|
+
type: 'ImportDefaultSpecifier' | 'ImportNamespaceSpecifier';
|
|
17
|
+
})[];
|
|
18
|
+
source: AstNode;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: {
|
|
21
|
+
meta: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
rules: {
|
|
25
|
+
'no-all-inline-type-imports': {
|
|
26
|
+
meta: {
|
|
27
|
+
fixable: string;
|
|
28
|
+
};
|
|
29
|
+
create(context: RuleContext): {
|
|
30
|
+
ImportDeclaration(node: ImportDeclarationNode): void;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default _default;
|
|
36
|
+
//# sourceMappingURL=consistent-inline-type-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistent-inline-type-imports.d.ts","sourceRoot":"","sources":["../../src/plugins/consistent-inline-type-imports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,UAAU,mBAAoB,SAAQ,OAAO;IAC3C,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB;AAED,UAAU,qBAAsB,SAAQ,OAAO;IAC7C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,UAAU,EAAE,CAAC,mBAAmB,GAAG;QAAE,IAAI,EAAE,wBAAwB,GAAG,0BAA0B,CAAA;KAAE,CAAC,EAAE,CAAC;IACtG,MAAM,EAAE,OAAO,CAAC;CACjB;;IAOC,IAAI;QAAI,IAAI;;IACZ,KAAK;QACH,4BAA4B;YAC1B,IAAI;gBAAI,OAAO;;YACf,MAAM,UAAU,WAAW;gBAEvB,iBAAiB,OAAO,qBAAqB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Forbids `import { type A, type B } from 'x'` in favor of `import type { A, B } from 'x'`.
|
|
2
|
+
// Mixed imports such as `import { ok, type Result } from 'neverthrow'` are left untouched,
|
|
3
|
+
// since splitting those into two statements is not desired here.
|
|
4
|
+
function isImportSpecifier(specifier) {
|
|
5
|
+
return specifier.type === 'ImportSpecifier';
|
|
6
|
+
}
|
|
7
|
+
export default {
|
|
8
|
+
meta: { name: 'kamaal-imports' },
|
|
9
|
+
rules: {
|
|
10
|
+
'no-all-inline-type-imports': {
|
|
11
|
+
meta: { fixable: 'code' },
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
ImportDeclaration(node) {
|
|
15
|
+
if (node.importKind === 'type') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const namedSpecifiers = node.specifiers.filter(isImportSpecifier);
|
|
19
|
+
if (namedSpecifiers.length === 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const hasNonNamedSpecifiers = namedSpecifiers.length !== node.specifiers.length;
|
|
23
|
+
if (hasNonNamedSpecifiers) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const allInlineType = namedSpecifiers.every(specifier => specifier.importKind === 'type');
|
|
27
|
+
if (!allInlineType) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
message: 'Use a top-level `import type` instead of marking every named specifier with an inline `type` modifier.',
|
|
33
|
+
fix(fixer) {
|
|
34
|
+
const names = namedSpecifiers.map(specifier => specifier.imported.name === specifier.local.name
|
|
35
|
+
? specifier.imported.name
|
|
36
|
+
: `${specifier.imported.name} as ${specifier.local.name}`);
|
|
37
|
+
const sourceText = context.sourceCode.getText(node.source);
|
|
38
|
+
return fixer.replaceText(node, `import type { ${names.join(', ')} } from ${sourceText};`);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=consistent-inline-type-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistent-inline-type-imports.js","sourceRoot":"","sources":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AS,CAAC,QAAQ,CAAC,IAAI;oCACzB,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAC5D,CAAC;gCAEF,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gCAE3D,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,UAAU,GAAG,CAAC,CAAC;4BAC5F,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AstNode, RuleContext } from './rule-context.ts';
|
|
2
|
+
interface LiteralNode extends AstNode {
|
|
3
|
+
type: 'Literal';
|
|
4
|
+
value: null;
|
|
5
|
+
}
|
|
6
|
+
interface IdentifierNode extends AstNode {
|
|
7
|
+
type: 'Identifier';
|
|
8
|
+
name: 'undefined';
|
|
9
|
+
}
|
|
10
|
+
type ExpressionNode = LiteralNode | IdentifierNode | BinaryExpressionNode | LogicalExpressionNode | AstNode;
|
|
11
|
+
interface BinaryExpressionNode extends AstNode {
|
|
12
|
+
type: 'BinaryExpression';
|
|
13
|
+
operator: '==' | '===';
|
|
14
|
+
left: ExpressionNode;
|
|
15
|
+
right: ExpressionNode;
|
|
16
|
+
}
|
|
17
|
+
interface LogicalExpressionNode extends AstNode {
|
|
18
|
+
type: 'LogicalExpression';
|
|
19
|
+
operator: '||';
|
|
20
|
+
left: ExpressionNode;
|
|
21
|
+
right: ExpressionNode;
|
|
22
|
+
}
|
|
23
|
+
interface ConditionalExpressionNode extends AstNode {
|
|
24
|
+
type: 'ConditionalExpression';
|
|
25
|
+
test: ExpressionNode;
|
|
26
|
+
consequent: ExpressionNode;
|
|
27
|
+
alternate: ExpressionNode;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: {
|
|
30
|
+
meta: {
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
rules: {
|
|
34
|
+
'no-nullish-check-first-ternary': {
|
|
35
|
+
meta: {
|
|
36
|
+
fixable: string;
|
|
37
|
+
};
|
|
38
|
+
create(context: RuleContext): {
|
|
39
|
+
ConditionalExpression(node: ConditionalExpressionNode): void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default _default;
|
|
45
|
+
//# sourceMappingURL=no-nullish-check-first-ternary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-nullish-check-first-ternary.d.ts","sourceRoot":"","sources":["../../src/plugins/no-nullish-check-first-ternary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,UAAU,WAAY,SAAQ,OAAO;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACb;AAED,UAAU,cAAe,SAAQ,OAAO;IACtC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,KAAK,cAAc,GAAG,WAAW,GAAG,cAAc,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,OAAO,CAAC;AAE5G,UAAU,oBAAqB,SAAQ,OAAO;IAC5C,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,UAAU,qBAAsB,SAAQ,OAAO;IAC7C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,IAAI,CAAC;IACf,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,UAAU,yBAA0B,SAAQ,OAAO;IACjD,IAAI,EAAE,uBAAuB,CAAC;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,cAAc,CAAC;CAC3B;;IA6BC,IAAI;QAAI,IAAI;;IACZ,KAAK;QACH,gCAAgC;YAC9B,IAAI;gBAAI,OAAO;;YACf,MAAM,UAAU,WAAW;gBAEvB,qBAAqB,OAAO,yBAAyB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const EQUALITY_OPERATORS = { '==': '!=', '===': '!==' };
|
|
2
|
+
function isNullish(node) {
|
|
3
|
+
return ((node.type === 'Literal' && 'value' in node && node.value === null) ||
|
|
4
|
+
(node.type === 'Identifier' && 'name' in node && node.name === 'undefined'));
|
|
5
|
+
}
|
|
6
|
+
function isNullishEqualityCheck(node) {
|
|
7
|
+
return (node.type === 'BinaryExpression' &&
|
|
8
|
+
'left' in node &&
|
|
9
|
+
'right' in node &&
|
|
10
|
+
(isNullish(node.left) || isNullish(node.right)));
|
|
11
|
+
}
|
|
12
|
+
function flattenOrOperands(node) {
|
|
13
|
+
if (node.type !== 'LogicalExpression' || !('left' in node && 'right' in node)) {
|
|
14
|
+
return [node];
|
|
15
|
+
}
|
|
16
|
+
return flattenOrOperands(node.left).concat(flattenOrOperands(node.right));
|
|
17
|
+
}
|
|
18
|
+
export default {
|
|
19
|
+
meta: { name: 'kamaal-ternary' },
|
|
20
|
+
rules: {
|
|
21
|
+
'no-nullish-check-first-ternary': {
|
|
22
|
+
meta: { fixable: 'code' },
|
|
23
|
+
create(context) {
|
|
24
|
+
return {
|
|
25
|
+
ConditionalExpression(node) {
|
|
26
|
+
const checks = flattenOrOperands(node.test);
|
|
27
|
+
if (!checks.every(isNullishEqualityCheck) || !isNullish(node.consequent)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
message: 'Put the value-producing branch first: use `!= null`/`!== null`/`!== undefined` (joined with `&&` for multiple checks) and swap the branches instead of checking nullish first.',
|
|
33
|
+
fix(fixer) {
|
|
34
|
+
const flippedTest = checks
|
|
35
|
+
.map(check => {
|
|
36
|
+
const leftText = context.sourceCode.getText(check.left);
|
|
37
|
+
const rightText = context.sourceCode.getText(check.right);
|
|
38
|
+
return `${leftText} ${EQUALITY_OPERATORS[check.operator]} ${rightText}`;
|
|
39
|
+
})
|
|
40
|
+
.join(' && ');
|
|
41
|
+
const consequentText = context.sourceCode.getText(node.consequent);
|
|
42
|
+
const alternateText = context.sourceCode.getText(node.alternate);
|
|
43
|
+
return fixer.replaceText(node, `${flippedTest} ? ${alternateText} : ${consequentText}`);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=no-nullish-check-first-ternary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-nullish-check-first-ternary.js","sourceRoot":"","sources":["../../src/plugins/no-nullish-check-first-ternary.ts"],"names":[],"mappings":"AAmCA,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAW,CAAC;AAEjE,SAAS,SAAS,CAAC,IAAoB;IACrC,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC;QACnE,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAoB;IAClD,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,kBAAkB;QAChC,MAAM,IAAI,IAAI;QACd,OAAO,IAAI,IAAI;QACf,CAAC,SAAS,CAAC,IAA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,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;gCAC1E,CAAC,CAAC;qCACD,IAAI,CAAC,MAAM,CAAC,CAAC;gCAEhB,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gCAEnE,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gCAEjE,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,WAAW,MAAM,aAAa,MAAM,cAAc,EAAE,CAAC,CAAC;4BAC1F,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface AstNode {
|
|
2
|
+
type: string;
|
|
3
|
+
}
|
|
4
|
+
interface RuleFixer {
|
|
5
|
+
replaceText(node: AstNode, text: string): AstNode;
|
|
6
|
+
}
|
|
7
|
+
interface SourceCode {
|
|
8
|
+
getText(node: AstNode): string;
|
|
9
|
+
}
|
|
10
|
+
export interface RuleContext {
|
|
11
|
+
sourceCode: SourceCode;
|
|
12
|
+
report(descriptor: {
|
|
13
|
+
node: AstNode;
|
|
14
|
+
message: string;
|
|
15
|
+
fix?: (fixer: RuleFixer) => AstNode;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=rule-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-context.d.ts","sourceRoot":"","sources":["../../src/plugins/rule-context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,SAAS;IACjB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACnD;AAED,UAAU,UAAU;IAClB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACnG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-context.js","sourceRoot":"","sources":["../../src/plugins/rule-context.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kamaal111/kamaal-quality-config",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Kamaal Farah's shared oxlint quality config.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lint",
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"url": "git+https://github.com/kamaal111/kamaal-quality-config.git"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"src/plugins/consistent-inline-type-imports.ts",
|
|
20
|
+
"src/plugins/no-nullish-check-first-ternary.ts"
|
|
19
21
|
],
|
|
20
22
|
"type": "module",
|
|
21
23
|
"main": "./dist/index.js",
|
|
@@ -25,10 +27,16 @@
|
|
|
25
27
|
"types": "./dist/index.d.ts",
|
|
26
28
|
"default": "./dist/index.js"
|
|
27
29
|
},
|
|
30
|
+
"./oxlint": {
|
|
31
|
+
"types": "./dist/oxlint.d.ts",
|
|
32
|
+
"default": "./dist/oxlint.js"
|
|
33
|
+
},
|
|
28
34
|
"./oxfmt": {
|
|
29
35
|
"types": "./dist/oxfmt.d.ts",
|
|
30
36
|
"default": "./dist/oxfmt.js"
|
|
31
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"./plugins/consistent-inline-type-imports": "./src/plugins/consistent-inline-type-imports.ts",
|
|
39
|
+
"./plugins/no-nullish-check-first-ternary": "./src/plugins/no-nullish-check-first-ternary.ts"
|
|
32
40
|
},
|
|
33
41
|
"publishConfig": {
|
|
34
42
|
"access": "public"
|
|
@@ -45,7 +53,8 @@
|
|
|
45
53
|
"oxfmt": "^0.67.0",
|
|
46
54
|
"oxlint": "^1.82.0",
|
|
47
55
|
"oxlint-tsgolint": "^7.0.2001",
|
|
48
|
-
"typescript": "^7.0.2"
|
|
56
|
+
"typescript": "^7.0.2",
|
|
57
|
+
"vitest": "^5.0.1"
|
|
49
58
|
},
|
|
50
59
|
"lint-staged": {
|
|
51
60
|
"*.{js,mjs,cjs,ts}": "pnpm run lint",
|
|
@@ -69,6 +78,7 @@
|
|
|
69
78
|
"format:check": "oxfmt --check",
|
|
70
79
|
"type-check": "tsc --noEmit",
|
|
71
80
|
"quality": "pnpm run lint && pnpm run format:check && pnpm run type-check",
|
|
81
|
+
"test": "pnpm run build && tsc -p tsconfig.tests.json && vitest run",
|
|
72
82
|
"release": "node ./scripts/publish.ts"
|
|
73
83
|
}
|
|
74
84
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Forbids `import { type A, type B } from 'x'` in favor of `import type { A, B } from 'x'`.
|
|
2
|
+
// Mixed imports such as `import { ok, type Result } from 'neverthrow'` are left untouched,
|
|
3
|
+
// since splitting those into two statements is not desired here.
|
|
4
|
+
|
|
5
|
+
import type { AstNode, RuleContext } from './rule-context.ts';
|
|
6
|
+
|
|
7
|
+
interface ImportSpecifierNode extends AstNode {
|
|
8
|
+
type: 'ImportSpecifier';
|
|
9
|
+
importKind?: 'type' | 'value';
|
|
10
|
+
imported: { name: string };
|
|
11
|
+
local: { name: string };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ImportDeclarationNode extends AstNode {
|
|
15
|
+
type: 'ImportDeclaration';
|
|
16
|
+
importKind?: 'type' | 'value';
|
|
17
|
+
specifiers: (ImportSpecifierNode | { type: 'ImportDefaultSpecifier' | 'ImportNamespaceSpecifier' })[];
|
|
18
|
+
source: AstNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isImportSpecifier(specifier: ImportDeclarationNode['specifiers'][number]): specifier is ImportSpecifierNode {
|
|
22
|
+
return specifier.type === 'ImportSpecifier';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
meta: { name: 'kamaal-imports' },
|
|
27
|
+
rules: {
|
|
28
|
+
'no-all-inline-type-imports': {
|
|
29
|
+
meta: { fixable: 'code' },
|
|
30
|
+
create(context: RuleContext) {
|
|
31
|
+
return {
|
|
32
|
+
ImportDeclaration(node: ImportDeclarationNode) {
|
|
33
|
+
if (node.importKind === 'type') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const namedSpecifiers = node.specifiers.filter(isImportSpecifier);
|
|
38
|
+
|
|
39
|
+
if (namedSpecifiers.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const hasNonNamedSpecifiers = namedSpecifiers.length !== node.specifiers.length;
|
|
44
|
+
|
|
45
|
+
if (hasNonNamedSpecifiers) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const allInlineType = namedSpecifiers.every(specifier => specifier.importKind === 'type');
|
|
50
|
+
|
|
51
|
+
if (!allInlineType) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
context.report({
|
|
56
|
+
node,
|
|
57
|
+
message:
|
|
58
|
+
'Use a top-level `import type` instead of marking every named specifier with an inline `type` modifier.',
|
|
59
|
+
fix(fixer) {
|
|
60
|
+
const names = namedSpecifiers.map(specifier =>
|
|
61
|
+
specifier.imported.name === specifier.local.name
|
|
62
|
+
? specifier.imported.name
|
|
63
|
+
: `${specifier.imported.name} as ${specifier.local.name}`,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const sourceText = context.sourceCode.getText(node.source);
|
|
67
|
+
|
|
68
|
+
return fixer.replaceText(node, `import type { ${names.join(', ')} } from ${sourceText};`);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { AstNode, RuleContext } from './rule-context.ts';
|
|
2
|
+
|
|
3
|
+
interface LiteralNode extends AstNode {
|
|
4
|
+
type: 'Literal';
|
|
5
|
+
value: null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface IdentifierNode extends AstNode {
|
|
9
|
+
type: 'Identifier';
|
|
10
|
+
name: 'undefined';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type ExpressionNode = LiteralNode | IdentifierNode | BinaryExpressionNode | LogicalExpressionNode | AstNode;
|
|
14
|
+
|
|
15
|
+
interface BinaryExpressionNode extends AstNode {
|
|
16
|
+
type: 'BinaryExpression';
|
|
17
|
+
operator: '==' | '===';
|
|
18
|
+
left: ExpressionNode;
|
|
19
|
+
right: ExpressionNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface LogicalExpressionNode extends AstNode {
|
|
23
|
+
type: 'LogicalExpression';
|
|
24
|
+
operator: '||';
|
|
25
|
+
left: ExpressionNode;
|
|
26
|
+
right: ExpressionNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ConditionalExpressionNode extends AstNode {
|
|
30
|
+
type: 'ConditionalExpression';
|
|
31
|
+
test: ExpressionNode;
|
|
32
|
+
consequent: ExpressionNode;
|
|
33
|
+
alternate: ExpressionNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const EQUALITY_OPERATORS = { '==': '!=', '===': '!==' } as const;
|
|
37
|
+
|
|
38
|
+
function isNullish(node: ExpressionNode): node is LiteralNode | IdentifierNode {
|
|
39
|
+
return (
|
|
40
|
+
(node.type === 'Literal' && 'value' in node && node.value === null) ||
|
|
41
|
+
(node.type === 'Identifier' && 'name' in node && node.name === 'undefined')
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isNullishEqualityCheck(node: ExpressionNode): node is BinaryExpressionNode {
|
|
46
|
+
return (
|
|
47
|
+
node.type === 'BinaryExpression' &&
|
|
48
|
+
'left' in node &&
|
|
49
|
+
'right' in node &&
|
|
50
|
+
(isNullish(node.left) || isNullish(node.right))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function flattenOrOperands(node: ExpressionNode): ExpressionNode[] {
|
|
55
|
+
if (node.type !== 'LogicalExpression' || !('left' in node && 'right' in node)) {
|
|
56
|
+
return [node];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return flattenOrOperands(node.left).concat(flattenOrOperands(node.right));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
meta: { name: 'kamaal-ternary' },
|
|
64
|
+
rules: {
|
|
65
|
+
'no-nullish-check-first-ternary': {
|
|
66
|
+
meta: { fixable: 'code' },
|
|
67
|
+
create(context: RuleContext) {
|
|
68
|
+
return {
|
|
69
|
+
ConditionalExpression(node: ConditionalExpressionNode) {
|
|
70
|
+
const checks = flattenOrOperands(node.test);
|
|
71
|
+
|
|
72
|
+
if (!checks.every(isNullishEqualityCheck) || !isNullish(node.consequent)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
context.report({
|
|
77
|
+
node,
|
|
78
|
+
message:
|
|
79
|
+
'Put the value-producing branch first: use `!= null`/`!== null`/`!== undefined` (joined with `&&` for multiple checks) and swap the branches instead of checking nullish first.',
|
|
80
|
+
fix(fixer) {
|
|
81
|
+
const flippedTest = checks
|
|
82
|
+
.map(check => {
|
|
83
|
+
const leftText = context.sourceCode.getText(check.left);
|
|
84
|
+
const rightText = context.sourceCode.getText(check.right);
|
|
85
|
+
|
|
86
|
+
return `${leftText} ${EQUALITY_OPERATORS[check.operator]} ${rightText}`;
|
|
87
|
+
})
|
|
88
|
+
.join(' && ');
|
|
89
|
+
|
|
90
|
+
const consequentText = context.sourceCode.getText(node.consequent);
|
|
91
|
+
|
|
92
|
+
const alternateText = context.sourceCode.getText(node.alternate);
|
|
93
|
+
|
|
94
|
+
return fixer.replaceText(node, `${flippedTest} ? ${alternateText} : ${consequentText}`);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|