-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicola Racco
committed
Apr 15, 2020
1 parent
573164f
commit 95103c1
Showing
5 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin'], | ||
extends: [ | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
bracketSpacing: true, | ||
jsxBracketSameLine: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Typescript configuration | ||
|
||
Typescript projects configuration is done via eslint and prettier, following their recommended configuration. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install -D eslint eslint-config-prettier eslint-plugin-prettier prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser | ||
$ curl -o .eslintrc.js https://github.com/mikamai/dress-code/raw/master/typescript/.eslintrc.js | ||
$ curl -o .prettierrc.js https://github.com/mikamai/dress-code/raw/master/typescript/.prettierrc.js | ||
$ curl -O https://github.com/mikamai/dress-code/raw/master/eslint/.eslintignore | ||
``` | ||
|
||
You also need to specify the path pattern to eslint command. Add a `lint` script in your package.json to run `eslint . --ext .ts` | ||
|
||
## Customization | ||
|
||
Remember to add an env property detailing your target env, so that eslint will not raise unexistent errors. For example, for a browser library, you would add: | ||
|
||
```json | ||
"env": { | ||
"browser": true | ||
} | ||
``` | ||
|
||
## Tests | ||
|
||
Tests may follow different rules, and usually it would be enough to just add some overrides. There are some cases (like with mocha and jest) when you also need to set a specific env (which cannot be set in overrides). In this case, define a new `.eslintrc.js` file in your `tests` folder. It will inherit the file in the root folder by default. For example: | ||
|
||
```json | ||
"env": { | ||
"jest": true | ||
} | ||
``` |