Skip to content

Instantly share code, notes, and snippets.

@datnguyen199
Forked from LucasMallmann/EslintNodeJS.md
Created December 8, 2021 10:04
Show Gist options
  • Save datnguyen199/bf612e34b85bc03a14dc881ca470f5ed to your computer and use it in GitHub Desktop.
Save datnguyen199/bf612e34b85bc03a14dc881ca470f5ed to your computer and use it in GitHub Desktop.
Eslint and Prettier configuration for NodeJS and Express projects

Eslint and prettier config for nodejs and express projects

Eslint and Libs

You need to install eslint and some other config libs.

yarn add eslint prettier eslint-config-prettier eslint-plugin-prettier -D

yarn eslint --init

.eslintrc.js

module.exports = {
  env: {
    es6: true,
    node: true
  },
  extends: ['airbnb-base', 'prettier'],
  plugins: ['prettier'],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  rules: {
    'prettier/prettier': 'error',
    'class-methods-use-this': 'off',
    'no-param-reassign': 'off',
    camelcase: 'off',
    'no-unused-vars': ['error', { argsIgnorePattern: 'next' }]
  }
};

.prettierrc

{
  "singleQuote": true,
  "trailingComma": "es5"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment