Skip to content

Commit 61b5085

Browse files
committed
Merge branch 'eslint/update-config' into develop
2 parents dcfc2f3 + 964100a commit 61b5085

File tree

13 files changed

+543
-441
lines changed

13 files changed

+543
-441
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ dist
33
coverage
44
out
55
public
6-
jest.config.js
7-
webpack.config.js

.eslintrc

Lines changed: 0 additions & 72 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
const baseConfig = {
2+
env: { node: true },
3+
plugins: ['import'],
4+
parser: '@typescript-eslint/parser',
5+
parserOptions: {
6+
project: ['./tsconfig.eslint.json'],
7+
},
8+
extends: [
9+
'airbnb',
10+
'airbnb/hooks',
11+
'plugin:import/recommended',
12+
],
13+
rules: {
14+
'max-len': [
15+
'warn',
16+
{
17+
code: 80,
18+
tabWidth: 2,
19+
ignoreComments: true,
20+
},
21+
],
22+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
23+
'import/order': [
24+
'error',
25+
{ alphabetize: { order: 'asc' } },
26+
],
27+
},
28+
};
29+
30+
const tsConfig = {
31+
files: ['*.ts', '*.tsx'],
32+
excludedFiles: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'],
33+
plugins: [
34+
...baseConfig.plugins,
35+
'@typescript-eslint',
36+
],
37+
extends: [
38+
...baseConfig.extends,
39+
'airbnb-typescript',
40+
'plugin:import/typescript',
41+
'plugin:@typescript-eslint/recommended',
42+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
43+
],
44+
rules: {
45+
...baseConfig.rules,
46+
// disable rules covered by TypesScript compiler
47+
'import/default': 'off',
48+
'import/named': 'off',
49+
'import/namespace': 'off',
50+
'import/no-named-as-default-member': 'off',
51+
// disable rules for better local performance
52+
'import/no-cycle': 'off',
53+
'import/no-deprecated': 'off',
54+
'import/no-named-as-default': 'off',
55+
'import/no-unused-modules': 'off',
56+
},
57+
settings: {
58+
'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'] },
59+
'import/resolver': {
60+
typescript: {
61+
alwaysTryTypes: true,
62+
project: ['./tsconfig.eslint.json'],
63+
},
64+
},
65+
},
66+
};
67+
68+
const jestConfig = {
69+
files: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'],
70+
env: { node: true, 'jest/globals': true },
71+
plugins: [
72+
...tsConfig.plugins,
73+
'jest',
74+
],
75+
extends: [
76+
...tsConfig.extends,
77+
'plugin:jest/recommended',
78+
'plugin:jest/style',
79+
],
80+
rules: {
81+
...tsConfig.rules,
82+
'@typescript-eslint/no-non-null-assertion': 'off',
83+
},
84+
settings: tsConfig.settings,
85+
};
86+
87+
const specialConfig = {
88+
files: ['**/*.config.js', '**/*.config.*.js'],
89+
rules: {
90+
...baseConfig.rules,
91+
'import/no-extraneous-dependencies': 'off',
92+
},
93+
};
94+
95+
module.exports = {
96+
root: true,
97+
...baseConfig,
98+
overrides: [
99+
tsConfig,
100+
jestConfig,
101+
specialConfig,
102+
],
103+
};

CHANGELOG_V4+.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- `tsconfig.eslint.json` to avoid ESLint complains for file not being included
10+
in project provided.
11+
12+
### Changed
13+
- Migrated from deprecated `.eslintrc` (ESLint config with no file extension) to
14+
`CommonJS` file - `.eslintrc.cjs`, with the following changes on the
15+
configurations:
16+
- Different rules and plugins are now applied based on file types, allowing
17+
JavaScript files to be linted properly and only using plugins & rules needed
18+
on the targeted files.
19+
- Separated config to 4 objects - naming as `baseConfig`, `tsConfig`,
20+
`jestConfig`, and `specialConfig` respectively to maintain the readability
21+
on the pervious `.eslintrc`.
22+
- `eslint-plugin-import` is now properly configured for both JavaScript and
23+
TypeScript files.
24+
- `jest.config.js` & `webpack.config.js` are no longer ignored by ESLint.
25+
26+
### Fixed
27+
- Module import order warnings in most modules.
28+
- ESLint warnings & errors on `jest.config.js` & `webpack.config.js`.
29+
30+
### Updates on package dependencies
31+
### Added
32+
- `eslint-import-resolver-typescript` *- Better TypeScript support for ESLint
33+
`import` plugin*
34+
35+
### Removed
36+
- `eslint-import-resolver-webpack` *- Not being used in any part of the
37+
boilerplate*
838

939
## [v4.0.0] - 2022-07-22
1040
### Added

jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const { pathsToModuleNameMapper } = require('ts-jest')
2-
const { compilerOptions } = require('./tsconfig.json')
1+
const { pathsToModuleNameMapper } = require('ts-jest');
2+
const { compilerOptions } = require('./tsconfig.json');
33

44
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
5-
module.exports = config = {
5+
module.exports = {
66
testEnvironment: 'node',
77
globals: {
88
'ts-jest': {

0 commit comments

Comments
 (0)