Skip to content

Instantly share code, notes, and snippets.

@fnoquiq
Last active February 11, 2020 23:02
Show Gist options
  • Save fnoquiq/a4900c58a049684d8ef4db50d43d2f5a to your computer and use it in GitHub Desktop.
Save fnoquiq/a4900c58a049684d8ef4db50d43d2f5a to your computer and use it in GitHub Desktop.
Node API configuration

Configurando projeto nodeJS

Configurado para o padrão Airbnb em conjunto ao Prettier

Não se esqueça de adicionar as seguintes dependências de desenvolvimento:

yarn add eslint eslint-config-airbnb-base eslint-config-prettier eslint-plugin-import -D

yarn add nodemon sucrase prettier eslint-plugin-prettier -D

Com isso, crie os arquivos nodemon.json, .editorconfig .prettierrc e .eslintrc.js no diretório root do projeto e neles colem o seguinte código:

nodemon.json

{
  "execMap": {
    "js": "sucrase-node"
  }
}

.editorconfig

root = true

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

.prettierrc

{
  "singleQuote": true,
  "trailingComma": "es5"
}

.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" }],
    "no-console": 0
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment