npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eduzz/eslint-config-houston

v1.9.8

Published

Eduzz Houston Eslint Config

Downloads

1,189

Readme


name: ESLint

menu:

ESLint Config

Para configurar no padrão do Houston, primerio você deve adicionar as dependências, pois o eslint exige que plugins devem, ser adicionados no projeto principal:

React

yarn add --dev eslint @eduzz/eslint-config-houston eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-eslint-plugin eslint-plugin-import eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-unused-imports eslint-plugin-sonarjs prettier
// .eslintrc
{
  "extends": ["@eduzz/eslint-config-houston"]
}

// .prettierrc.js
module.exports = {
  ...require('@eduzz/eslint-config-houston/.prettierrc')
};

React Native:

yarn add --dev eslint @eduzz/eslint-config-houston eslint eslint-plugin-react-native @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-eslint-plugin eslint-plugin-import eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-unused-imports eslint-plugin-sonarjs prettier
// .eslintrc
{
  "extends": ["@eduzz/eslint-config-houston/native"]
}

// .prettierrc.js
module.exports = {
  ...require('@eduzz/eslint-config-houston/.prettierrc')
};

Node

yarn add --dev eslint @eduzz/eslint-config-houston eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-eslint-plugin eslint-plugin-import eslint-plugin-prettier eslint-plugin-unused-imports eslint-plugin-sonarjs prettier
// .eslintrc
{
  "extends": ["@eduzz/eslint-config-houston/node"]
}

// .prettierrc.js
module.exports = {
  ...require('@eduzz/eslint-config-houston/.prettierrc')
};

Configurações Extras

VSCode

  • Adicione a extensão do ESLint. SUGERIMOS DESISTALAR OU DESATIVAR A EXTENSÃO DO PRETTIER POIS O ESLINT QUE APLICARÁ O PRETTIER.

  • Crie/Adicione no .vscode/settings.json (não na suas configurações, pois assim ficará no projeto e o time já terá acesso):

{
  //... suas configurações
  "editor.codeActionsOnSave": {
    "source.organizeImports": false,
    "source.fixAll.eslint": true
  },
  "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
  "editor.formatOnPaste": false,
  "editor.formatOnSave": false,
  "editor.formatOnType": false,
  "editor.tabSize": 2
}

React Hooks

Para que o eslint verifique e aplica a regra correta do react-hooks/exhaustive-deps é preciso adicionar seus custom hooks nas regras do .eslintrc, para facilitar esse processo criamos um generator. Já adicionados todos os hooks do Houston, mas caso queria adicionar os do seu proejeto:

// .eslintrc.js <~precisa ser .js
const generator = require('@eduzz/eslint-config-houston/configs/generator');

module.exports = {
  extends: ['@eduzz/eslint-config-houston'],
  rules: {
    'react-hooks/exhaustive-deps': generator.exhaustiveDeps('warn', ['useMyCustomHook'], true)
  }
};

| Método | Params | | -------------- | ---------------------------------------------------------------------------------------------------------------------------- | | exhaustiveDeps | 1. 'warn' | 'error'2. Array com seus hooks 3. boolean se deve ou não adicionar os hooks do @eduzz/houston-hooks |

⚠️ Vale ressaltar que os custom hooks devem seguir o padrão de que o segundo parametro seja a deps

React 17 e JSX

Para utilizar a nova versão do React com jsx-runtime basta seguir o tutorial do blog, mas resumidamente é:

# Removendo Imports React não Utilizadas
npx react-codemod update-react-imports

tsconfig.json

{
  //... suas configurações
  "compilerOptions": {
    "jsx": "react-jsx" //Troque esse configuração
  }
}

.eslintrc

{
  "extends": ["@eduzz/eslint-config-houston"],
  "rules": {
    //Adicione essas rules
    "react/jsx-uses-react": "off",
    "react/react-in-jsx-scope": "off"
  }
}