# 我常用的 ESLint 自動排版配置 ## 初始化並選擇配置 ```bash= eslint --init ``` 可能需要手動安裝 `eslint-config-standard` ```bash= npm i -D eslint-config-standard ``` ###### .eslintrc.js ```javascript= module.exports = { extends: [ 'standard', ], } ``` ## 新增 `rules` > 我喜歡尾端維持逗號 🥸 ###### .eslintrc.js ```javascript= module.exports = { rules: { 'comma-dangle': ['error', { arrays: 'always-multiline', objects: 'always-multiline', imports: 'always-multiline', exports: 'always-multiline', functions: 'only-multiline', }], }, } ``` ## 設定 VSCode 存檔時自動 format ###### .vscode/settings.json ```json= { "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, } ``` ## For React TypeScript https://github.com/standard/eslint-config-standard-react 忽略 `no-use-before-define` https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use > https://github.com/typescript-cheatsheets/react
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up