Skip to content

Instantly share code, notes, and snippets.

@wpyoga
Last active June 22, 2023 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpyoga/802ae1f1a5a3305e07f79ee2d7f1ed09 to your computer and use it in GitHub Desktop.
Save wpyoga/802ae1f1a5a3305e07f79ee2d7f1ed09 to your computer and use it in GitHub Desktop.
basic vscode code formatting and linting

editorconfig

.editorconfig

root = true

[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 2
max_line_length = 80

prettier

$ npm install --save-dev --save-exact prettier

.prettierrc.json

{
  "singleQuote": true
}

.prettierignore

$ cp .gitignore .prettierignore
$ echo '!.eslintrc.js' >> .prettierignore

in the future, hopefully we can skip .prettierignore altogether: prettier/prettier#3460

eslint

npm install --save-dev eslint eslint-gitignore eslint-plugin-import @typescript-eslint/parser @typescript-eslint/eslint-plugin

.eslintrc.js

/* eslint-disable @typescript-eslint/no-var-requires */
module.exports = {
  env: { node: true },
  ignorePatterns: [
    ...require('eslint-gitignore').readGitignoreFiles({ cwd: __dirname }),
    '!.eslintrc.js',
  ],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier',
  ],
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  root: true,
};

vscode extensions

.vscode/extensions.json

{
  "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment