Skip to content
This repository was archived by the owner on Jul 28, 2024. It is now read-only.

Commit 4985d28

Browse files
committed
Divide TS configs to base and react versions
1 parent 11358b7 commit 4985d28

File tree

8 files changed

+90
-52
lines changed

8 files changed

+90
-52
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: require.resolve('./ts/eslint.js'),
2+
extends: require.resolve('./ts/eslint/base'),
33
};

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,26 @@ Following config examples can be further extended and customized according to pr
7272

7373
```javascript
7474
module.exports = {
75-
presets: ['@wavevision/coding-standard/ts/babel'],
75+
presets: ['@wavevision/coding-standard/ts/babel/base'],
7676
};
7777
```
7878

79+
> **React version:** `@wavevision/coding-standard/ts/babel/react`.
80+
7981
#### `.eslintrc.js`
8082

8183
```javascript
8284
module.exports = {
83-
extends: require.resolve('@wavevision/coding-standard/ts/eslint'),
85+
extends: require.resolve('@wavevision/coding-standard/ts/eslint/base'),
86+
parserOptions: {
87+
project: '**/tsconfig.json',
88+
tsconfigRootDir: '.',
89+
},
8490
};
8591
```
8692

93+
> **React version:** `@wavevision/coding-standard/ts/eslint/react`.
94+
8795
#### `postcss.config.js`
8896

8997
```javascript

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wavevision/coding-standard",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "The Wavevision SCSS and TypeScript coding standard.",
55
"repository": {
66
"type": "git",

ts/babel/base.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const presets = [
2+
['@babel/preset-env', { corejs: 3, useBuiltIns: 'usage' }],
3+
'@babel/preset-typescript',
4+
];
5+
const plugins = [
6+
'@babel/plugin-proposal-class-properties',
7+
'@babel/plugin-proposal-object-rest-spread',
8+
];
9+
10+
exports.presets = presets;
11+
exports.plugins = plugins;
12+
13+
module.exports = () => ({
14+
presets,
15+
plugins,
16+
});
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
const presets = [
2-
['@babel/preset-env', { corejs: 3, useBuiltIns: 'usage' }],
3-
'@babel/preset-typescript',
4-
'@babel/preset-react',
5-
];
6-
const plugins = [
7-
'@babel/plugin-proposal-class-properties',
8-
'@babel/plugin-proposal-object-rest-spread',
9-
];
1+
/* eslint @typescript-eslint/no-var-requires: 'off' */
2+
const { presets, plugins } = require('./base');
103

114
if (process.env.NODE_ENV === 'production') {
125
plugins.concat([
@@ -19,6 +12,6 @@ if (process.env.NODE_ENV === 'production') {
1912
}
2013

2114
module.exports = () => ({
22-
presets,
15+
presets: presets.concat('@babel/preset-react'),
2316
plugins,
2417
});
Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint @typescript-eslint/no-var-requires: 'off' */
2+
const configs = require('./configs');
3+
14
const productionError =
25
process.env.NODE_ENV === 'production' ? 'error' : 'warn';
36

@@ -7,16 +10,7 @@ module.exports = {
710
node: true,
811
'jest/globals': true,
912
},
10-
extends: [
11-
'airbnb',
12-
'plugin:@typescript-eslint/recommended',
13-
'plugin:import/typescript',
14-
'plugin:jest/recommended',
15-
'plugin:prettier/recommended',
16-
'prettier',
17-
'prettier/@typescript-eslint',
18-
'prettier/react',
19-
],
13+
extends: configs.concat('airbnb-base'),
2014
parser: '@typescript-eslint/parser',
2115
parserOptions: {
2216
ecmaVersion: 2018,
@@ -25,9 +19,8 @@ module.exports = {
2519
jsx: true,
2620
modules: true,
2721
},
28-
project: './tsconfig.json',
2922
},
30-
plugins: ['@typescript-eslint', 'import', 'jest', 'react-hooks'],
23+
plugins: ['@typescript-eslint', 'import', 'jest'],
3124
globals: {
3225
window: true,
3326
document: true,
@@ -62,45 +55,24 @@ module.exports = {
6255
},
6356
],
6457
'import/prefer-default-export': 'off',
65-
'jsx-a11y/interactive-supports-focus': 'off',
66-
'jsx-a11y/click-events-have-key-events': 'off',
67-
'jsx-a11y/label-has-associated-control': 'off',
68-
'jsx-a11y/label-has-for': [
69-
'error',
70-
{
71-
required: {
72-
every: ['id'],
73-
},
74-
},
75-
],
7658
'no-nested-ternary': 'off',
7759
'no-param-reassign': 'off',
7860
'no-plusplus': 'off',
7961
'no-restricted-syntax': 'off',
8062
'no-shadow': 'off',
8163
'no-underscore-dangle': 'off',
8264
'spaced-comment': 'off',
83-
'react/destructuring-assignment': 'off',
84-
'react/jsx-boolean-value': 'off',
85-
'react/jsx-curly-brace-presence': [
86-
'error',
87-
{ props: 'never', children: 'never' },
88-
],
89-
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
90-
'react/jsx-uses-vars': 'error',
91-
'react/no-danger': 'off',
92-
'react/no-unused-prop-types': 'off',
93-
'react/prop-types': 'off',
94-
'react/require-default-props': 'off',
9565
'no-console': productionError,
9666
'no-debugger': productionError,
67+
'operator-linebreak': [
68+
'error',
69+
'after',
70+
{ overrides: { '?': 'before', ':': 'before' } },
71+
],
9772
},
9873
settings: {
9974
'import/resolver': {
10075
typescript: {},
10176
},
102-
react: {
103-
version: 'detect',
104-
},
10577
},
10678
};

ts/eslint/configs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = [
2+
'plugin:@typescript-eslint/recommended',
3+
'plugin:import/typescript',
4+
'plugin:jest/recommended',
5+
'plugin:prettier/recommended',
6+
'prettier',
7+
'prettier/@typescript-eslint',
8+
];

ts/eslint/react.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* eslint @typescript-eslint/no-var-requires: 'off' */
2+
const base = require('./base');
3+
const configs = require('./configs');
4+
5+
module.exports = {
6+
...base,
7+
extends: configs.concat('airbnb', 'prettier/react'),
8+
plugins: base.plugins.concat('react-hooks'),
9+
rules: {
10+
...base.rules,
11+
'jsx-a11y/interactive-supports-focus': 'off',
12+
'jsx-a11y/click-events-have-key-events': 'off',
13+
'jsx-a11y/label-has-associated-control': 'off',
14+
'jsx-a11y/label-has-for': [
15+
'error',
16+
{
17+
required: {
18+
every: ['id'],
19+
},
20+
},
21+
],
22+
'react/destructuring-assignment': 'off',
23+
'react/jsx-boolean-value': 'off',
24+
'react/jsx-curly-brace-presence': [
25+
'error',
26+
{ props: 'never', children: 'never' },
27+
],
28+
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
29+
'react/jsx-uses-vars': 'error',
30+
'react/no-danger': 'off',
31+
'react/no-unused-prop-types': 'off',
32+
'react/prop-types': 'off',
33+
'react/require-default-props': 'off',
34+
},
35+
settings: {
36+
...base.settings,
37+
react: {
38+
version: 'detect',
39+
},
40+
},
41+
};

0 commit comments

Comments
 (0)