Skip to content

Commit

Permalink
Merge pull request #10 from UNIwise/split-react-typescript-configs
Browse files Browse the repository at this point in the history
Split typescript and react configs
  • Loading branch information
arcuo authored Apr 19, 2023
2 parents 98f7e9a + dd07a53 commit 495823d
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 325 deletions.
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,46 @@ WISEflow's ESLint config for react.
## Installation

```sh
yarn add --dev @uniwise/eslint-config typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-import-resolver-typescript eslint-plugin-react eslint-plugin-import prettier eslint-config-prettier eslint-plugin-prettier
# Install eslint and required packages
yarn add -D @uniwise/eslint-config eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-import-resolver-typescript eslint-plugin-import prettier eslint-config-prettier eslint-plugin-prettier

# For React add react plugin
yarn add -D eslint-plugin-react
```

## Usage

After installing, update your project's `.eslintrc.json` file to import the rule sets you want:
After installing, update your project's `.eslintrc.(json|js)` or file to import the rule sets you want.

- React - `@uniwise/eslint-config` or specifically `@uniwise/eslint-config/react`
- Typescript (No react) - `@uniwise/eslint-config/typescript`

e.g in `./eslintrc.json`

```json
{
"extends" : [
"@uniwise/eslint-config"
]
"extends": ["@uniwise/eslint-config"],
"rules": {
"overriding_some_rule": "warn"
}
}
```

For VSCode add the config path to the workspace settings in the `.vscode/settings.json`
```json
{
...
"eslint.options": {
"configFile": "./.eslintrc.json"
or in `./eslintrc.js`

```js
module.exports = {
extends: ['@uniwise/eslint-config/typescript']
rules: {
"overriding_some_rule": "warn"
}
}
};
```

To run the linter:

```sh
yarn eslint src/
yarn eslint src/
```

---
Expand Down
37 changes: 1 addition & 36 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: "detect",
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
},
},
},
plugins: ["@typescript-eslint", "react", "import", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:prettier/recommended",
],
rules: {
"react/prop-types": "off",
'@typescript-eslint/explicit-module-boundary-types': ['off'],
},
};
module.exports = require('./react');
Loading

0 comments on commit 495823d

Please sign in to comment.