Skip to content

Instantly share code, notes, and snippets.

@charrismatic
Forked from LucasMallmann/EslintNodeJS.md
Created April 10, 2021 20:16
Show Gist options
  • Save charrismatic/85b063f76824fae1ac2d6cd1568904a9 to your computer and use it in GitHub Desktop.
Save charrismatic/85b063f76824fae1ac2d6cd1568904a9 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