-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add prettier and update eslint
- Loading branch information
Showing
25 changed files
with
573 additions
and
423 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,106 @@ | ||
module.exports = { | ||
plugins: ['@typescript-eslint'], | ||
extends: ['airbnb', 'airbnb-typescript'], | ||
parser: '@typescript-eslint/parser', | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'airbnb', 'airbnb-typescript', 'prettier'], | ||
plugins: ['@typescript-eslint', 'import', 'simple-import-sort', 'no-relative-import-paths'], | ||
ignorePatterns: ['.eslintrc.js'], | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
ecmaVersion: 13, | ||
ecmaVersion: 14, | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
node: true, | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'react/function-component-definition': 'off', | ||
'import/no-extraneous-dependencies': 'off', | ||
'react/jsx-props-no-spreading': 'off', | ||
'react/require-default-props': 'off', | ||
'import/prefer-default-export': 'off', | ||
'object-curly-newline': 'off', | ||
'no-console': 'off', | ||
|
||
'no-relative-import-paths/no-relative-import-paths': [ | ||
'warn', | ||
{ | ||
allowSameFolder: true, | ||
allowedDepth: 1, | ||
rootDir: './src', | ||
prefix: '', | ||
}, | ||
], | ||
|
||
// Too strict | ||
'no-param-reassign': 'off', | ||
'max-classes-per-file': 'off', | ||
'no-underscore-dangle': 'off', | ||
'class-methods-use-this': 'off', | ||
'no-plusplus': 'off', | ||
'max-len': ['warn', { | ||
code: 120, | ||
ignoreStrings: true, | ||
ignoreUrls: true, | ||
}], | ||
|
||
'global-require': 'off', | ||
|
||
// https://stackoverflow.com/a/64024916/286387 | ||
'no-use-before-define': 'off', | ||
// Allow for..of syntax | ||
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], | ||
// https://basarat.gitbook.io/typescript/main-1/defaultisbad | ||
'import/prefer-default-export': 'off', | ||
'import/no-default-export': 'off', | ||
'import/no-anonymous-default-export': 'off', | ||
// It's not accurate in the monorepo style | ||
'import/no-extraneous-dependencies': 'off', | ||
'import/extensions': 'off', | ||
'import/first': 'error', | ||
'import/newline-after-import': 'error', | ||
'import/no-duplicates': 'error', | ||
'simple-import-sort/imports': 'error', | ||
'simple-import-sort/exports': 'error', | ||
|
||
// Allow most functions to rely on type inference. | ||
// If the function is exported, then `@typescript-eslint/explicit-module-boundary-types` will ensure it's typed. | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ | ||
functions: false, | ||
classes: true, | ||
variables: true, | ||
typedefs: true, | ||
}, | ||
], | ||
|
||
'@typescript-eslint/no-explicit-any': 'error', | ||
|
||
// Enable some rules for async JS | ||
'no-promise-executor-return': 'error', | ||
'max-nested-callbacks': 'error', | ||
'no-return-await': 'error', | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.js', '*.ts'], | ||
rules: { | ||
'simple-import-sort/imports': [ | ||
'error', | ||
{ | ||
groups: [ | ||
// Third-party libraries and frameworks | ||
['^@?\\w'], | ||
// Internal app modules | ||
['^helpers', '^installers', '^utils', '^routes'], | ||
// App config file | ||
['^config'], | ||
// Internal packages | ||
['^types', '^app.constants'], | ||
// Relative imports | ||
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], | ||
// Side effect imports. | ||
['^\\u0000'], | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['**/types.ts'], | ||
rules: { | ||
'no-restricted-imports': '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,31 @@ | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/dist | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# lock file | ||
pnpm-lock.yaml | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
.prettierignore |
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,4 @@ | ||
{ | ||
"printWidth": 120, | ||
"singleQuote": true | ||
} |
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
Oops, something went wrong.