Skip to content

Commit 21b09fa

Browse files
committed
feat: add react:ts eslint config
1 parent 0932125 commit 21b09fa

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

__tests__/states/categories.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ describe('jsCategoryState', () => {
44
test('should be initialized', () => {
55
expect(jsCategoryState).toBeDefined();
66
expect(jsCategoryState.name).toBe('js');
7-
expect(jsCategoryState.configTypes).toEqual(['default', 'node:ts']);
7+
expect(jsCategoryState.configTypes).toEqual(['default', 'node:ts', 'react:ts']);
88
});
99
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { jestMutation, prettierMutation } from '../eslint.utils';
2+
import { Config } from './config.interface';
3+
4+
export const reactTsConfig: Config = {
5+
dependencies: [
6+
'@typescript-eslint/eslint-plugin',
7+
'@typescript-eslint/parser',
8+
'eslint-plugin-beautiful-sort',
9+
'eslint-config-airbnb',
10+
'eslint-config-airbnb-typescript',
11+
],
12+
eslintConfig: {
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
project: 'tsconfig.json',
16+
sourceType: 'module',
17+
},
18+
plugins: ['@typescript-eslint/eslint-plugin', 'beautiful-sort'],
19+
extends: ['plugin:@typescript-eslint/recommended', 'airbnb', 'airbnb-typescript'],
20+
root: true,
21+
env: {
22+
es6: true,
23+
browser: true,
24+
node: true,
25+
},
26+
ignorePatterns: ['.eslintrc.js'],
27+
rules: {
28+
'@typescript-eslint/interface-name-prefix': 'off',
29+
'@typescript-eslint/explicit-function-return-type': 'off',
30+
'@typescript-eslint/explicit-module-boundary-types': 'off',
31+
'@typescript-eslint/no-explicit-any': 'warn',
32+
'@typescript-eslint/no-floating-promises': 'warn',
33+
'@typescript-eslint/no-empty-interface': 'warn',
34+
'no-param-reassign': 'warn',
35+
'@typescript-eslint/ban-types': 'warn',
36+
'max-classes-per-file': ['error', 2],
37+
38+
'react/react-in-jsx-scope': 'off',
39+
'react/jsx-props-no-spreading': 'off',
40+
'react/function-component-definition': 'off',
41+
'react/no-invalid-html-attribute': 'warn',
42+
'react/display-name': 'warn',
43+
'import/prefer-default-export': 'off',
44+
'react/require-default-props': 'off',
45+
'react/no-array-index-key': 'warn',
46+
47+
'beautiful-sort/import': [
48+
'error',
49+
{
50+
special: ['react'],
51+
order: ['special', 'namespace', 'default', 'defaultObj', 'obj', 'none'],
52+
},
53+
],
54+
},
55+
},
56+
scripts: [
57+
{ name: 'lint', script: 'eslint "src/**/*.{ts,tsx}"' },
58+
{ name: 'lint:fix', script: 'eslint "src/**/*.{ts,tsx}" --fix' },
59+
],
60+
mutations: [prettierMutation, jestMutation],
61+
};
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { jsCategoryState } from 'src/states/categories';
22
import { defaultConfig } from './config/default.config';
33
import { nodeTsConfig } from './config/node:ts.config';
4+
import { reactTsConfig } from './config/react:ts.config';
45

56
export const [getConfig] = jsCategoryState.useConfigState({
67
default: defaultConfig,
78
'node:ts': nodeTsConfig,
9+
'react:ts': reactTsConfig,
810
});

src/states/categories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { createCategoryState } from '../utils/state';
22

3-
export const jsCategoryState = createCategoryState('js', ['node:ts']);
3+
export const jsCategoryState = createCategoryState('js', ['node:ts', 'react:ts']);

0 commit comments

Comments
 (0)