@metamask-previews/oxlint-config-typescript 0.0.0-preview-d6c6adc

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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ [Unreleased]: https://github.com/MetaMask/oxlint-config/
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 MetaMask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # `@metamask/oxlint-config-typescript`
2
+
3
+ MetaMask's [TypeScript](https://www.typescriptlang.org) Oxlint configuration.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ yarn add --dev \
9
+ @metamask/oxlint-config@^0.0.0 \
10
+ @metamask/oxlint-config-typescript@^0.0.0 \
11
+ oxlint@^1.82.0 \
12
+ oxlint-tsgolint@^7.0.2001
13
+ ```
14
+
15
+ The order in which you extend ESLint rules matters.
16
+ The `@metamask/*` Oxlint configs should be added to the config array _last_,
17
+ with `@metamask/oxlint-config` first, and `@metamask/oxlint-config-*` in any
18
+ order thereafter.
19
+
20
+ ```js
21
+ import base, { createConfig } from '@metamask/oxlint-config';
22
+ import typescript from '@metamask/oxlint-config-typescript';
23
+
24
+ const config = createConfig({
25
+ extends: [
26
+ // Any custom shared config should be added here.
27
+ // ...
28
+
29
+ // This should be added last unless you know what you're doing.
30
+ base,
31
+ typescript,
32
+ ],
33
+ });
34
+ ```
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@metamask-previews/oxlint-config-typescript",
3
+ "version": "0.0.0-preview-d6c6adc",
4
+ "description": "Shareable MetaMask Oxlint config for TypeScript",
5
+ "homepage": "https://github.com/MetaMask/oxlint-config#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/MetaMask/oxlint-config/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/MetaMask/oxlint-config.git"
13
+ },
14
+ "files": [
15
+ "src/",
16
+ "!src/**/*.test.js",
17
+ "!src/**/__test__"
18
+ ],
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./src/index.d.ts",
23
+ "default": "./src/index.js"
24
+ }
25
+ },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
29
+ },
30
+ "scripts": {
31
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/oxlint-config-typescript",
32
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/oxlint-config-typescript",
33
+ "test": "oxlint ."
34
+ },
35
+ "devDependencies": {
36
+ "@metamask/auto-changelog": "^3.4.4",
37
+ "@metamask/oxlint-config": "^0.0.0",
38
+ "oxlint": "^1.82.0",
39
+ "oxlint-tsgolint": "^7.0.2001",
40
+ "typescript": "^5.9.3",
41
+ "typescript-eslint": "^8.58.1",
42
+ "vitest": "^2.1.9"
43
+ },
44
+ "peerDependencies": {
45
+ "@metamask/oxlint-config": "^0.0.0",
46
+ "oxlint": "^1.82.0",
47
+ "oxlint-tsgolint": "^7.0.2001"
48
+ },
49
+ "engines": {
50
+ "node": "^18.18 || >=20"
51
+ }
52
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { OxlintConfig } from 'oxlint';
2
+
3
+ declare const config: OxlintConfig;
4
+ export default config;
package/src/index.js ADDED
@@ -0,0 +1,131 @@
1
+ import { createConfig } from '@metamask/oxlint-config';
2
+
3
+ const config = createConfig({
4
+ plugins: ['typescript'],
5
+
6
+ categories: {
7
+ correctness: 'allow',
8
+ },
9
+
10
+ options: {
11
+ typeAware: true,
12
+ },
13
+
14
+ rules: {
15
+ // Our rules
16
+ 'typescript/array-type': 'error',
17
+ 'typescript/consistent-type-assertions': 'error',
18
+ 'typescript/consistent-type-definitions': ['error', 'type'],
19
+ 'typescript/explicit-function-return-type': 'error',
20
+ 'typescript/no-explicit-any': 'off',
21
+ 'typescript/no-namespace': ['error', { allowDefinitionFiles: true }],
22
+ 'typescript/no-non-null-assertion': 'error',
23
+ 'typescript/parameter-properties': 'error',
24
+ 'typescript/prefer-for-of': 'error',
25
+ 'typescript/prefer-function-type': 'error',
26
+ 'typescript/prefer-optional-chain': 'error',
27
+ 'typescript/unified-signatures': 'error',
28
+ 'typescript/no-dupe-class-members': 'error',
29
+ 'typescript/no-unused-vars': [
30
+ 'error',
31
+ {
32
+ vars: 'all',
33
+ args: 'all',
34
+ argsIgnorePattern: '[_]+',
35
+ ignoreRestSiblings: true,
36
+ },
37
+ ],
38
+
39
+ // Recommended rules that require type information
40
+ 'typescript/no-unsafe-argument': 'off',
41
+ 'typescript/no-unsafe-assignment': 'off',
42
+ 'typescript/no-unsafe-call': 'off',
43
+ 'typescript/no-unsafe-member-access': 'off',
44
+ 'typescript/no-unsafe-return': 'off',
45
+
46
+ // Recommended rules that we do not want to use
47
+ 'typescript/no-duplicate-type-constituents': 'off',
48
+ 'typescript/no-redundant-type-constituents': 'off',
49
+ 'typescript/no-unsafe-enum-comparison': 'off',
50
+ 'typescript/require-await': 'off',
51
+
52
+ // Disabled because unnecessary type arguments are sometimes helpful for
53
+ // readability
54
+ 'typescript/no-unnecessary-type-arguments': 'off',
55
+
56
+ // Our rules that require type information
57
+ 'typescript/consistent-type-exports': 'error',
58
+ 'typescript/no-meaningless-void-operator': 'error',
59
+ 'typescript/no-unnecessary-boolean-literal-compare': 'error',
60
+ 'typescript/no-unnecessary-qualifier': 'error',
61
+ 'typescript/prefer-enum-initializers': 'error',
62
+ 'typescript/prefer-includes': 'error',
63
+ 'typescript/prefer-nullish-coalescing': 'error',
64
+ 'typescript/prefer-promise-reject-errors': [
65
+ 'error',
66
+ { allowThrowingUnknown: true },
67
+ ],
68
+ 'typescript/prefer-readonly': 'error',
69
+ 'typescript/prefer-reduce-type-parameter': 'error',
70
+ 'typescript/prefer-string-starts-ends-with': 'error',
71
+ 'typescript/promise-function-async': 'error',
72
+ 'typescript/restrict-template-expressions': [
73
+ 'error',
74
+ {
75
+ allowBoolean: true,
76
+ allowNumber: true,
77
+ },
78
+ ],
79
+ 'typescript/switch-exhaustiveness-check': [
80
+ 'error',
81
+ {
82
+ considerDefaultExhaustiveForUnions: true,
83
+ },
84
+ ],
85
+
86
+ 'default-param-last': 'off',
87
+ 'typescript/default-param-last': 'error',
88
+
89
+ 'no-shadow': 'off',
90
+ 'typescript/no-shadow': ['error', { builtinGlobals: true }],
91
+
92
+ 'typescript/no-unused-expressions': [
93
+ 'error',
94
+ { allowShortCircuit: true, allowTernary: true },
95
+ ],
96
+
97
+ 'no-use-before-define': 'off',
98
+ 'typescript/no-use-before-define': ['error', { functions: false }],
99
+
100
+ 'no-useless-constructor': 'off',
101
+ 'typescript/no-useless-constructor': 'error',
102
+
103
+ /* Import plugin rules */
104
+
105
+ // This rule is too aggressive about combining type and non-type imports,
106
+ // which I'm not sure that we want.
107
+ // But more importantly, the auto-fixer is broken.
108
+ // See here for details on that bug: https://github.com/un-ts/eslint-plugin-import-x/issues/231
109
+ // TODO: Check if this is the case for Oxlint.
110
+ 'import/no-duplicates': 'off',
111
+
112
+ // Combined with the "verbatimModuleSyntax" tsconfig option, a better option
113
+ // than `typescript/consistent-type-imports`.
114
+ 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
115
+
116
+ /* JSDoc plugin rules */
117
+
118
+ // These all conflict with `jsdoc/no-types`.
119
+ 'jsdoc/require-param-type': 'off',
120
+ 'jsdoc/require-property-type': 'off',
121
+ 'jsdoc/require-returns-type': 'off',
122
+ // 'jsdoc/valid-types': 'off',
123
+
124
+ /* Promise plugin rules */
125
+
126
+ // TypeScript already validates Promise params, no need to validate them twice
127
+ 'promise/valid-params': 'off',
128
+ },
129
+ });
130
+
131
+ export default config;