Skip to content

Instantly share code, notes, and snippets.

@bhaidar
Forked from LucasMallmann/EslintNodeJS.md
Created August 10, 2020 06:42
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 bhaidar/6613d11ea32e3e0220e565b813f4cab4 to your computer and use it in GitHub Desktop.
Save bhaidar/6613d11ea32e3e0220e565b813f4cab4 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