Skip to content

Instantly share code, notes, and snippets.

@AlexGalhardo
Forked from LucasMallmann/EslintNodeJS.md
Created August 28, 2021 14:26
Show Gist options
  • Save AlexGalhardo/8479825349446b48bf5b963b6c62a399 to your computer and use it in GitHub Desktop.
Save AlexGalhardo/8479825349446b48bf5b963b6c62a399 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