@appium/eslint-config-appium-ts 0.3.2 → 1.0.1

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.
Files changed (5) hide show
  1. package/README.md +12 -11
  2. package/index.mjs +230 -0
  3. package/package.json +14 -12
  4. package/LICENSE +0 -201
  5. package/index.js +0 -120
package/README.md CHANGED
@@ -1,10 +1,9 @@
1
- # @appium/eslint-config-appium
1
+ # @appium/eslint-config-appium-ts
2
2
 
3
- > Provides a reusable [ESLint](http://eslint.org/) [shared configuration](http://eslint.org/docs/developer-guide/shareable-configs) for [Appium](https://github.com/appium/appium) and Appium-adjacent projects (for TypeScript)
3
+ > Provides a reusable [ESLint](http://eslint.org/) [shared configuration](http://eslint.org/docs/developer-guide/shareable-configs) for [Appium](https://github.com/appium/appium) and Appium-adjacent projects.
4
4
 
5
- ## Motivation
6
-
7
- **If your package has no TypeScript sources, you don't need this.** However, if your package _does_ have TypeScript sources, you can't lint those files without this.
5
+ [![NPM version](http://img.shields.io/npm/v/@appium/eslint-config-appium-ts.svg)](https://npmjs.org/package/@appium/eslint-config-appium-ts)
6
+ [![Downloads](http://img.shields.io/npm/dm/@appium/eslint-config-appium-ts.svg)](https://npmjs.org/package/@appium/eslint-config-appium-ts)
8
7
 
9
8
  ## Usage
10
9
 
@@ -14,12 +13,15 @@ Install the package with **`npm` v8 or newer**:
14
13
  npm install @appium/eslint-config-appium-ts --save-dev
15
14
  ```
16
15
 
17
- And then, in your `.eslintrc` file, extend the configuration:
16
+ And then, in your `eslint.config.mjs` file, extend the configuration:
17
+
18
+ ```js
19
+ import appiumConfig from '@appium/eslint-config-appium-ts';
18
20
 
19
- ```json
20
- {
21
- "extends": "@appium/eslint-config-appium-ts"
22
- }
21
+ export default [
22
+ ...appiumConfig,
23
+ // add any other config changes
24
+ ];
23
25
  ```
24
26
 
25
27
  ## Peer Dependencies
@@ -31,7 +33,6 @@ This config requires the following packages be installed (as peer dependencies)
31
33
  - [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import)
32
34
  - [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha)
33
35
  - [eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise)
34
- - [@appium/eslint-config-appium](https://www.npmjs.com/package/@appium/eslint-config-appium)
35
36
  - [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
36
37
  - [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser)
37
38
 
package/index.mjs ADDED
@@ -0,0 +1,230 @@
1
+ import path from 'node:path';
2
+ import {fileURLToPath} from 'node:url';
3
+ import fs from 'node:fs';
4
+
5
+ import js from '@eslint/js';
6
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
7
+ import tsParser from '@typescript-eslint/parser';
8
+ import globals from 'globals';
9
+ import pluginPromise from 'eslint-plugin-promise';
10
+ import importPlugin from 'eslint-plugin-import';
11
+ import mochaPlugin from 'eslint-plugin-mocha';
12
+ import {includeIgnoreFile} from '@eslint/compat';
13
+
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = path.dirname(__filename);
16
+ const gitignorePath = path.resolve(__dirname, '.gitignore');
17
+
18
+ export default [
19
+ js.configs.recommended,
20
+ pluginPromise.configs['flat/recommended'],
21
+ importPlugin.flatConfigs.recommended,
22
+
23
+ {
24
+ name: 'Script Files',
25
+ files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
26
+ languageOptions: {
27
+ ecmaVersion: 2022,
28
+ sourceType: 'module',
29
+ parser: tsParser,
30
+ globals: {
31
+ ...globals.node,
32
+ NodeJS: 'readonly',
33
+ BufferEncoding: 'readonly',
34
+ },
35
+ },
36
+ plugins: {
37
+ '@typescript-eslint': tsPlugin,
38
+ },
39
+ settings: {
40
+ /**
41
+ * This stuff enables `eslint-plugin-import` to resolve TS modules.
42
+ */
43
+ 'import/parsers': {
44
+ '@typescript-eslint/parser': ['.ts', '.tsx', '.mtsx'],
45
+ },
46
+ 'import/resolver': {
47
+ typescript: {
48
+ project: ['tsconfig.json', './packages/*/tsconfig.json'],
49
+ },
50
+ },
51
+ },
52
+ rules: {
53
+ ...tsPlugin.configs.recommended.rules,
54
+ /**
55
+ * This rule is configured to warn if a `@ts-ignore` or `@ts-expect-error` directive is used
56
+ * without explanation.
57
+ * @remarks It's good practice to explain why things break!
58
+ */
59
+ '@typescript-eslint/ban-ts-comment': [
60
+ 'warn',
61
+ {
62
+ 'ts-expect-error': 'allow-with-description',
63
+ 'ts-ignore': 'allow-with-description',
64
+ },
65
+ ],
66
+ /**
67
+ * Empty functions are allowed.
68
+ * @remarks This is disabled because I need someone to explain to me why empty functions are bad. I suppose they _could_ be bugs, but so could literally any line of code.
69
+ */
70
+ '@typescript-eslint/no-empty-function': 'off',
71
+ /**
72
+ * Empty interfaces are allowed.
73
+ * @remarks This is because empty interfaces have a use case in declaration merging. Otherwise,
74
+ * an empty interface can be a type alias, e.g., `type Foo = Bar` where `Bar` is an interface.
75
+ */
76
+ '@typescript-eslint/no-empty-interface': 'off',
77
+ '@typescript-eslint/no-empty-object-type': 'off',
78
+ /**
79
+ * Explicit `any` types are allowed.
80
+ * @remarks Eventually this should be a warning, and finally an error, as we fully type the codebases.
81
+ */
82
+ '@typescript-eslint/no-explicit-any': 'off',
83
+ /**
84
+ * Warns if a non-null assertion (`!`) is used.
85
+ * @remarks Generally, a non-null assertion should be replaced by a proper type guard or
86
+ * type-safe function, if possible. For example, `Set.prototype.has(x)` is not type-safe, and
87
+ * does not imply that `Set.prototype.get(x)` is not `undefined` (I do not know why this is, but
88
+ * I'm sure there's a good reason for it). In this case, a non-null assertion is appropriate.
89
+ * Often a simple `typeof x === 'y'` conditional is sufficient to narrow the type and avoid the
90
+ * non-null assertion.
91
+ */
92
+ '@typescript-eslint/no-non-null-assertion': 'warn',
93
+ '@typescript-eslint/no-require-imports': 'off',
94
+ /**
95
+ * Sometimes we want unused variables to be present in base class method declarations.
96
+ */
97
+ '@typescript-eslint/no-unused-vars': 'warn',
98
+ '@typescript-eslint/no-var-requires': 'off',
99
+
100
+ 'import/export': 2,
101
+ 'import/named': 'warn',
102
+ 'import/no-duplicates': 2,
103
+ 'import/no-unresolved': 2,
104
+
105
+ 'promise/catch-or-return': 1,
106
+ /**
107
+ * Allow native `Promise`s.
108
+ * @remarks Originally, this was so that we could use [bluebird](https://npm.im/bluebird)
109
+ * everywhere, but this is not strictly necessary.
110
+ */
111
+ 'promise/no-native': 'off',
112
+ 'promise/no-return-wrap': 1,
113
+ 'promise/prefer-await-to-callbacks': 1,
114
+ 'promise/prefer-await-to-then': 1,
115
+ 'promise/param-names': 1,
116
+
117
+ 'array-bracket-spacing': 2,
118
+ 'arrow-body-style': [1, 'as-needed'],
119
+ 'arrow-parens': [1, 'always'],
120
+ 'arrow-spacing': 2,
121
+ /**
122
+ * Disables the `brace-style` rule.
123
+ * @remarks Due to the way `prettier` sometimes formats extremely verbose types, sometimes it is necessary
124
+ * to indent in a way that is not allowed by the default `brace-style` rule.
125
+ */
126
+ 'brace-style': 'off',
127
+ 'comma-dangle': 0,
128
+ 'comma-spacing': [
129
+ 2,
130
+ {
131
+ before: false,
132
+ after: true,
133
+ },
134
+ ],
135
+ 'curly': [2, 'all'],
136
+ 'dot-notation': 2,
137
+ 'eqeqeq': [2, 'smart'],
138
+ 'key-spacing': [
139
+ 2,
140
+ {
141
+ mode: 'strict',
142
+ beforeColon: false,
143
+ afterColon: true,
144
+ },
145
+ ],
146
+ 'keyword-spacing': 2,
147
+ 'no-buffer-constructor': 1,
148
+ 'no-console': 2,
149
+ 'no-dupe-class-members': 'off',
150
+ 'no-empty': 0,
151
+ 'no-multi-spaces': 2,
152
+ 'no-prototype-builtins': 1,
153
+ 'no-redeclare': 'off',
154
+ 'no-trailing-spaces': 2,
155
+ 'no-var': 2,
156
+ 'no-whitespace-before-property': 2,
157
+ 'object-shorthand': 2,
158
+ 'quotes': [
159
+ 2,
160
+ 'single',
161
+ {
162
+ avoidEscape: true,
163
+ allowTemplateLiterals: true,
164
+ },
165
+ ],
166
+ 'radix': [2, 'always'],
167
+ 'require-atomic-updates': 0,
168
+ /**
169
+ * Allow `async` functions without `await`.
170
+ * @remarks Originally, this was to be more clear about the return value of a function, but with
171
+ * the addition of types, this is no longer necessary. Further, both `return somePromise` and
172
+ * `return await somePromise` have their own use-cases.
173
+ */
174
+ 'require-await': 'off',
175
+ 'semi': [2, 'always'],
176
+ 'space-before-blocks': [2, 'always'],
177
+ 'space-in-parens': [2, 'never'],
178
+ 'space-infix-ops': 2,
179
+ 'space-unary-ops': [
180
+ 2,
181
+ {
182
+ words: true,
183
+ nonwords: false,
184
+ },
185
+ ],
186
+ }
187
+ },
188
+
189
+ {
190
+ ...mochaPlugin.configs.flat.recommended,
191
+ name: 'Test Files',
192
+ files: ['**/test/**', '*.spec.*js', '-specs.*js', '*.spec.ts'],
193
+ rules: {
194
+ ...mochaPlugin.configs.flat.recommended.rules,
195
+ /**
196
+ * Both `@ts-expect-error` and `@ts-ignore` are allowed to be used with impunity in tests.
197
+ * @remarks We often test things which explicitly violate types.
198
+ */
199
+ '@typescript-eslint/ban-ts-comment': 'off',
200
+ /**
201
+ * Allow non-null assertions in tests; do not even warn.
202
+ * @remarks The idea is that the assertions themselves will be written in such a way that if
203
+ * the non-null assertion was invalid, the assertion would fail.
204
+ */
205
+ '@typescript-eslint/no-non-null-assertion': 'off',
206
+ '@typescript-eslint/no-unused-expressions': 'off',
207
+ 'import/no-named-as-default-member': 'off',
208
+ 'mocha/consistent-spacing-between-blocks': 'off',
209
+ 'mocha/max-top-level-suites': 'off',
210
+ 'mocha/no-exclusive-tests': 2,
211
+ 'mocha/no-exports': 'off',
212
+ 'mocha/no-mocha-arrows': 2,
213
+ 'mocha/no-setup-in-describe': 'off',
214
+ 'mocha/no-skipped-tests': 'off',
215
+ },
216
+ },
217
+
218
+ {
219
+ name: 'Ignores',
220
+ ignores: [
221
+ ...(fs.existsSync(gitignorePath) ? includeIgnoreFile(gitignorePath).ignores : []),
222
+ '**/.*',
223
+ '**/*-d.ts',
224
+ '**/*.min.js',
225
+ '**/build/**',
226
+ '**/coverage/**',
227
+ ],
228
+ }
229
+
230
+ ];
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@appium/eslint-config-appium-ts",
3
- "version": "0.3.2",
3
+ "type": "module",
4
+ "version": "1.0.1",
4
5
  "description": "Shared ESLint config for Appium projects (TypeScript version)",
5
6
  "keywords": [
6
7
  "eslint",
@@ -20,23 +21,24 @@
20
21
  },
21
22
  "license": "Apache-2.0",
22
23
  "author": "https://github.com/appium",
23
- "main": "index.js",
24
+ "exports": "./index.mjs",
24
25
  "files": [
25
- "index.js"
26
+ "index.mjs"
26
27
  ],
27
28
  "scripts": {
28
29
  "test:smoke": "exit 0"
29
30
  },
30
31
  "peerDependencies": {
31
- "@appium/eslint-config-appium": "^8.0.0",
32
- "@typescript-eslint/eslint-plugin": "^5.5.0 || ^6.0.0",
33
- "@typescript-eslint/parser": "^5.5.0 || ^6.0.0",
34
- "eslint": "^8.21.0",
35
- "eslint-config-prettier": "^8.5.0 || ^9.0.0",
32
+ "@eslint/compat": "^1.1.0",
33
+ "@eslint/js": "^9.0.0",
34
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
35
+ "@typescript-eslint/parser": "^8.0.0",
36
+ "eslint": "^9.0.0",
37
+ "eslint-config-prettier": "^9.0.0",
36
38
  "eslint-import-resolver-typescript": "^3.5.0",
37
- "eslint-plugin-import": "^2.26.0",
38
- "eslint-plugin-mocha": "^10.1.0",
39
- "eslint-plugin-promise": "^6.0.0"
39
+ "eslint-plugin-import": "^2.30.0",
40
+ "eslint-plugin-mocha": "^10.4.0",
41
+ "eslint-plugin-promise": "^7.0.0"
40
42
  },
41
43
  "engines": {
42
44
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
@@ -45,5 +47,5 @@
45
47
  "publishConfig": {
46
48
  "access": "public"
47
49
  },
48
- "gitHead": "475198e36b49c820786142ff6e9f5e799926c99b"
50
+ "gitHead": "8480a85ce2fa466360e0fb1a7f66628331907f02"
49
51
  }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "{}"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright OpenJS Foundation and other contributors, https://openjsf.org/
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
package/index.js DELETED
@@ -1,120 +0,0 @@
1
- /**
2
- * `@appium/eslint-config-appium-ts` is a configuration for ESLint which extends
3
- * `@appium/eslint-config-appium` and adds TypeScript support.
4
- *
5
- * It is **not** a _replacement for_ `@appium/eslint-config-appium`.
6
- *
7
- * It can be used _without any `.ts` sources_, as long as a `tsconfig.json` exists in the project
8
- * root. In that case, it will run on `.js` files which are enabled for checking; this includes the
9
- * `checkJs` setting and any `// @ts-check` directive in source files.
10
- */
11
-
12
- module.exports = {
13
- $schema: 'http://json.schemastore.org/eslintrc',
14
- parser: '@typescript-eslint/parser',
15
- extends: ['@appium/eslint-config-appium', 'plugin:@typescript-eslint/recommended'],
16
- rules: {
17
- /**
18
- * This rule is configured to warn if a `@ts-ignore` or `@ts-expect-error` directive is used
19
- * without explanation.
20
- * @remarks It's good practice to explain why things break!
21
- */
22
- '@typescript-eslint/ban-ts-comment': [
23
- 'warn',
24
- {
25
- 'ts-expect-error': 'allow-with-description',
26
- 'ts-ignore': 'allow-with-description',
27
- },
28
- ],
29
- /**
30
- * Empty functions are allowed.
31
- * @remarks This is disabled because I need someone to explain to me why empty functions are bad. I suppose they _could_ be bugs, but so could literally any line of code.
32
- */
33
- '@typescript-eslint/no-empty-function': 'off',
34
- /**
35
- * Empty interfaces are allowed.
36
- * @remarks This is because empty interfaces have a use case in declaration merging. Otherwise,
37
- * an empty interface can be a type alias, e.g., `type Foo = Bar` where `Bar` is an interface.
38
- */
39
- '@typescript-eslint/no-empty-interface': 'off',
40
- /**
41
- * Explicit `any` types are allowed.
42
- * @remarks Eventually this should be a warning, and finally an error, as we fully type the codebases.
43
- */
44
- '@typescript-eslint/no-explicit-any': 'off',
45
- /**
46
- * Warns if a non-null assertion (`!`) is used.
47
- * @remarks Generally, a non-null assertion should be replaced by a proper type guard or
48
- * type-safe function, if possible. For example, `Set.prototype.has(x)` is not type-safe, and
49
- * does not imply that `Set.prototype.get(x)` is not `undefined` (I do not know why this is, but
50
- * I'm sure there's a good reason for it). In this case, a non-null assertion is appropriate.
51
- * Often a simple `typeof x === 'y'` conditional is sufficient to narrow the type and avoid the
52
- * non-null assertion.
53
- */
54
- '@typescript-eslint/no-non-null-assertion': 'warn',
55
- /**
56
- * This disallows use of `require()`.
57
- * @remarks We _do_ use `require()` fairly often to load files on-the-fly; however, these may
58
- * want to be replaced with `import()` (I am not sure if there's a rule about that?). **If this check fails**, disable the rule for the particular line.
59
- */
60
- '@typescript-eslint/no-var-requires': 'error',
61
- /**
62
- * Sometimes we want unused variables to be present in base class method declarations.
63
- */
64
- '@typescript-eslint/no-unused-vars': 'warn',
65
- /**
66
- * Allow native `Promise`s. **This overrides `@appium/eslint-config-appium`.**
67
- * @remarks Originally, this was so that we could use [bluebird](https://npm.im/bluebird)
68
- * everywhere, but this is not strictly necessary.
69
- */
70
- 'promise/no-native': 'off',
71
- /**
72
- * Allow `async` functions without `await`. **This overrides `@appium/eslint-config-appium`.**
73
- * @remarks Originally, this was to be more clear about the return value of a function, but with
74
- * the addition of types, this is no longer necessary. Further, both `return somePromise` and
75
- * `return await somePromise` have their own use-cases.
76
- */
77
- 'require-await': 'off',
78
-
79
- /**
80
- * Disables the `brace-style` rule.
81
- * @remarks Due to the way `prettier` sometimes formats extremely verbose types, sometimes it is necessary
82
- * to indent in a way that is not allowed by the default `brace-style` rule.
83
- */
84
- 'brace-style': 'off',
85
- },
86
- /**
87
- * This stuff enables `eslint-plugin-import` to resolve TS modules.
88
- */
89
- settings: {
90
- 'import/parsers': {
91
- '@typescript-eslint/parser': ['.ts', '.tsx'],
92
- },
93
- 'import/resolver': {
94
- typescript: {
95
- project: ['tsconfig.json', './packages/*/tsconfig.json'],
96
- },
97
- },
98
- },
99
- overrides: [
100
- /**
101
- * Overrides for tests.
102
- */
103
- {
104
- files: ['**/test/**', '*.spec.js', '-specs.js', '*.spec.ts'],
105
- rules: {
106
- /**
107
- * Both `@ts-expect-error` and `@ts-ignore` are allowed to be used with impunity in tests.
108
- * @remarks We often test things which explicitly violate types.
109
- */
110
- '@typescript-eslint/ban-ts-comment': 'off',
111
- /**
112
- * Allow non-null assertions in tests; do not even warn.
113
- * @remarks The idea is that the assertions themselves will be written in such a way that if
114
- * the non-null assertion was invalid, the assertion would fail.
115
- */
116
- '@typescript-eslint/no-non-null-assertion': 'off',
117
- },
118
- },
119
- ],
120
- };