Skip to content

Commit ff84f56

Browse files
Transition to eslint-config-airbnb-with-typescript
- Migrate to newer `eslint-config-airbnb-with-typescript` from `eslint-config-airbnb`. - Add also `rushstack/eslint-patch` as per instructed by `eslint-config-airbnb-with-typescript` docs. - Update codebase to align with new linting standards. - Add script to configure VS Code for effective linting for project developers, move it to `scripts` directory along with clean npm install script for better organization.
1 parent 4d0ce12 commit ff84f56

39 files changed

+2391
-693
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[*.{js,jsx,ts,tsx,vue}]
1+
[*.{js,jsx,ts,tsx,vue,sh}]
22
indent_style = space
33
indent_size = 2
44
end_of_line = lf

.eslintrc.js

Lines changed: 3 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices');
2-
const { rules: baseErrorsRules } = require('eslint-config-airbnb-base/rules/errors');
3-
const { rules: baseES6Rules } = require('eslint-config-airbnb-base/rules/es6');
4-
const { rules: baseImportsRules } = require('eslint-config-airbnb-base/rules/imports');
51
const { rules: baseStyleRules } = require('eslint-config-airbnb-base/rules/style');
6-
const { rules: baseVariablesRules } = require('eslint-config-airbnb-base/rules/variables');
72
const tsconfigJson = require('./tsconfig.json');
3+
require('@rushstack/eslint-patch/modern-module-resolution');
84

95
module.exports = {
106
root: true,
@@ -17,9 +13,7 @@ module.exports = {
1713
'plugin:vue/essential',
1814

1915
// Extends eslint-config-airbnb
20-
// Added by Vue CLI
21-
// Here until https://github.com/vuejs/eslint-config-airbnb/issues/23 is done
22-
'@vue/airbnb',
16+
'@vue/eslint-config-airbnb-with-typescript',
2317

2418
// Extends @typescript-eslint/recommended
2519
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
@@ -52,18 +46,6 @@ module.exports = {
5246
mocha: true,
5347
},
5448
},
55-
{
56-
files: ['**/*.ts?(x)', '**/*.d.ts'],
57-
parserOptions: {
58-
// Setting project is required for some rules such as @typescript-eslint/dot-notation,
59-
// @typescript-eslint/return-await and @typescript-eslint/no-throw-literal.
60-
// If this property is missing they fail due to missing parser.
61-
project: ['./tsconfig.json'],
62-
},
63-
rules: {
64-
...getTypeScriptOverrides(),
65-
},
66-
},
6749
{
6850
files: ['**/tests/**/*.{j,t}s?(x)'],
6951
rules: {
@@ -115,6 +97,7 @@ function getOpinionatedRuleOverrides() {
11597
return {
11698
// https://erkinekici.com/articles/linting-trap#no-use-before-define
11799
'no-use-before-define': 'off',
100+
'@typescript-eslint/no-use-before-define': 'off',
118101
// https://erkinekici.com/articles/linting-trap#arrow-body-style
119102
'arrow-body-style': 'off',
120103
// https://erkinekici.com/articles/linting-trap#no-plusplus
@@ -134,164 +117,6 @@ function getOpinionatedRuleOverrides() {
134117
};
135118
}
136119

137-
function getTypeScriptOverrides() {
138-
/*
139-
Here until Vue supports AirBnb Typescript overrides (vuejs/eslint-config-airbnb#23).
140-
Based on `eslint-config-airbnb-typescript`.
141-
Source: https://github.com/iamturns/eslint-config-airbnb-typescript/blob/v16.1.0/lib/shared.js
142-
It cannot be used directly due to compilation errors.
143-
*/
144-
return {
145-
'brace-style': 'off',
146-
'@typescript-eslint/brace-style': baseStyleRules['brace-style'],
147-
148-
camelcase: 'off',
149-
'@typescript-eslint/naming-convention': [
150-
'error',
151-
{ selector: 'variable', format: ['camelCase', 'PascalCase', 'UPPER_CASE'] },
152-
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
153-
{ selector: 'typeLike', format: ['PascalCase'] },
154-
],
155-
156-
'comma-dangle': 'off',
157-
'@typescript-eslint/comma-dangle': [
158-
baseStyleRules['comma-dangle'][0],
159-
{
160-
...baseStyleRules['comma-dangle'][1],
161-
enums: baseStyleRules['comma-dangle'][1].arrays,
162-
generics: baseStyleRules['comma-dangle'][1].arrays,
163-
tuples: baseStyleRules['comma-dangle'][1].arrays,
164-
},
165-
],
166-
167-
'comma-spacing': 'off',
168-
'@typescript-eslint/comma-spacing': baseStyleRules['comma-spacing'],
169-
170-
'default-param-last': 'off',
171-
'@typescript-eslint/default-param-last': baseBestPracticesRules['default-param-last'],
172-
173-
'dot-notation': 'off',
174-
'@typescript-eslint/dot-notation': baseBestPracticesRules['dot-notation'],
175-
176-
'func-call-spacing': 'off',
177-
'@typescript-eslint/func-call-spacing': baseStyleRules['func-call-spacing'],
178-
179-
// ❌ Broken for some cases, but still useful.
180-
// Here until Prettifier is used.
181-
indent: 'off',
182-
'@typescript-eslint/indent': baseStyleRules.indent,
183-
184-
'keyword-spacing': 'off',
185-
'@typescript-eslint/keyword-spacing': baseStyleRules['keyword-spacing'],
186-
187-
'lines-between-class-members': 'off',
188-
'@typescript-eslint/lines-between-class-members': baseStyleRules['lines-between-class-members'],
189-
190-
'no-array-constructor': 'off',
191-
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'],
192-
193-
'no-dupe-class-members': 'off',
194-
'@typescript-eslint/no-dupe-class-members': baseES6Rules['no-dupe-class-members'],
195-
196-
'no-empty-function': 'off',
197-
'@typescript-eslint/no-empty-function': baseBestPracticesRules['no-empty-function'],
198-
199-
'no-extra-parens': 'off',
200-
'@typescript-eslint/no-extra-parens': baseErrorsRules['no-extra-parens'],
201-
202-
'no-extra-semi': 'off',
203-
'@typescript-eslint/no-extra-semi': baseErrorsRules['no-extra-semi'],
204-
205-
// ❌ Fails due to missing parser
206-
// 'no-implied-eval': 'off',
207-
// 'no-new-func': 'off',
208-
// '@typescript-eslint/no-implied-eval': baseBestPracticesRules['no-implied-eval'],
209-
210-
'no-loss-of-precision': 'off',
211-
'@typescript-eslint/no-loss-of-precision': baseErrorsRules['no-loss-of-precision'],
212-
213-
'no-loop-func': 'off',
214-
'@typescript-eslint/no-loop-func': baseBestPracticesRules['no-loop-func'],
215-
216-
'no-magic-numbers': 'off',
217-
'@typescript-eslint/no-magic-numbers': baseBestPracticesRules['no-magic-numbers'],
218-
219-
'no-redeclare': 'off',
220-
'@typescript-eslint/no-redeclare': baseBestPracticesRules['no-redeclare'],
221-
222-
// ESLint variant does not work with TypeScript enums.
223-
'no-shadow': 'off',
224-
'@typescript-eslint/no-shadow': baseVariablesRules['no-shadow'],
225-
226-
'no-throw-literal': 'off',
227-
'@typescript-eslint/no-throw-literal': baseBestPracticesRules['no-throw-literal'],
228-
229-
'no-unused-expressions': 'off',
230-
'@typescript-eslint/no-unused-expressions': baseBestPracticesRules['no-unused-expressions'],
231-
232-
'no-unused-vars': 'off',
233-
'@typescript-eslint/no-unused-vars': baseVariablesRules['no-unused-vars'],
234-
235-
// https://erkinekici.com/articles/linting-trap#no-use-before-define
236-
// 'no-use-before-define': 'off',
237-
// '@typescript-eslint/no-use-before-define': baseVariablesRules['no-use-before-define'],
238-
239-
// ESLint variant does not understand TypeScript constructors.
240-
// eslint/eslint/#14118, typescript-eslint/typescript-eslint#873
241-
'no-useless-constructor': 'off',
242-
'@typescript-eslint/no-useless-constructor': baseES6Rules['no-useless-constructor'],
243-
244-
quotes: 'off',
245-
'@typescript-eslint/quotes': baseStyleRules.quotes,
246-
247-
semi: 'off',
248-
'@typescript-eslint/semi': baseStyleRules.semi,
249-
250-
'space-before-function-paren': 'off',
251-
'@typescript-eslint/space-before-function-paren': baseStyleRules['space-before-function-paren'],
252-
253-
'require-await': 'off',
254-
'@typescript-eslint/require-await': baseBestPracticesRules['require-await'],
255-
256-
'no-return-await': 'off',
257-
'@typescript-eslint/return-await': baseBestPracticesRules['no-return-await'],
258-
259-
'space-infix-ops': 'off',
260-
'@typescript-eslint/space-infix-ops': baseStyleRules['space-infix-ops'],
261-
262-
'object-curly-spacing': 'off',
263-
'@typescript-eslint/object-curly-spacing': baseStyleRules['object-curly-spacing'],
264-
265-
'import/extensions': [
266-
baseImportsRules['import/extensions'][0],
267-
baseImportsRules['import/extensions'][1],
268-
{
269-
...baseImportsRules['import/extensions'][2],
270-
ts: 'never',
271-
tsx: 'never',
272-
},
273-
],
274-
275-
// Changes required is not yet implemented:
276-
// 'import/no-extraneous-dependencies': [
277-
// baseImportsRules['import/no-extraneous-dependencies'][0],
278-
// {
279-
// ...baseImportsRules['import/no-extraneous-dependencies'][1],
280-
// devDependencies: baseImportsRules[
281-
// 'import/no-extraneous-dependencies'
282-
// ][1].devDependencies.reduce((result, devDep) => {
283-
// const toAppend = [devDep];
284-
// const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
285-
// if (devDepWithTs !== devDep) {
286-
// toAppend.push(devDepWithTs);
287-
// }
288-
// return [...result, ...toAppend];
289-
// }, []),
290-
// },
291-
// ],
292-
};
293-
}
294-
295120
function getAliasesFromTsConfig() {
296121
return Object.keys(tsconfigJson.compilerOptions.paths)
297122
.map((path) => `${path}*`);

docs/development.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ You could run other types of tests as well, but they may take longer time and ov
4747
- Build desktop application: `npm run electron:build`
4848
- (Re)create icons (see [documentation](../img/README.md)): `npm run create-icons`
4949

50+
### Utility Scripts
51+
52+
- Run fresh NPM install: [`./scripts/fresh-npm-install.sh`](../scripts/fresh-npm-install.sh)
53+
- This script provides a clean NPM install, removing existing node modules and optionally the package-lock.json (when run with -n), then installs dependencies and runs unit tests.
54+
- Configure VSCode: [`./scripts/configure-vscode.sh`](../scripts/configure-vscode.sh)
55+
- This script checks and sets the necessary configurations for VSCode in `settings.json` file.
56+
5057
## Recommended extensions
5158

5259
You should use EditorConfig to follow project style.

0 commit comments

Comments
 (0)