eslint-config-neo

0.12.0 • Public • Published

eslint-config-neo

Official Neo Financial ESLint configuration

Available Configs

This package includes 4 different ESLint configs:

  • config-backend
  • config-frontend
  • config-backend-next
  • config-frontend-next

The next versions include some rules that are being considered for inclusion in future versions of the base config. The next configs also require you to specify the project setting in parserOptions for TypeScript projects. The will make ESLint run slower in TypeScript projects.

Relationships Between Configs

flowchart LR
    A[config-base]
    B[config-base-next]
    C[config-backend]
    D[config-frontend]
    E[config-backend-next]
    F[config-frontend-next]
    A --> C
    A --> D
    A --> B
    B --> E
    B --> F

The arrows from left to right illustrate which configs are extended by another config.

Installation

Install Package

npm install --save-dev eslint-config-neo

You can also install a specific version of the package by appending the version tag. For example, to install version 1.0.0

npm install --save-dev eslint-config-neo@1.0.0

Install Peer Dependencies

npm install -D eslint prettier lint-staged husky typescript

Make ESLint Config File

Add .eslintrc to project root

{
  "extends": "eslint-config-neo/config-backend"
}

Use eslint-config-neo/config-frontend for frontend projects

Optional: Configure parserOptions with next configs

If you're using one of the next configs you must set the project option to include all of your tsconfig.json files:

{
  "extends": "eslint-config-neo/config-backend",
  "parserOptions": {
    "project": ["tsconfig.json", "test/tsconfig.json"]
  }
}

Make Prettier Config File

Add .prettierrc to project root

{
  "printWidth": 120,
  "singleQuote": true
}

Optional: If there are any files you want to exclude from Prettier add .prettierignore to project root

Make Editorconfig File

Add .editorconfig to project root

# http://editorconfig.org
root = true

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

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[COMMIT_EDITMSG]
max_line_length = 0

Add Engines

Add the engines field to package.json

"engines": {
  "node": "^12.0.0"
}

Add Scripts

Add scripts for linting and formatting to package.json

"scripts": {
  "lint": "eslint .",
  "format": "prettier --write \"**/*.{ts,tsx,js,json,graphql,md}\"",
  "format:check": "prettier --debug-check \"**/*.{ts,tsx,js,json,graphql,md}\""
}

Add Precommit Hook

Add a precommit hook to package.json to automatically lint and format any files staged for commit

"husky": {
  "hooks": {
    "pre-commit": "lint-staged"
  }
},
"lint-staged": {
  "concurrent": false,
  "linters": {
    "*.{ts,tsx,js}": [
      "eslint --quiet",
      "git add"
    ],
    "*.{ts,tsx,js,json,graphql,md}": [
      "prettier --write",
      "git add"
    ]
  }
}

Format Code

If you've added Prettier to an existing project you will want to format all the code. The precommit hook only updates files that have been changed and staged for commit. To format the entire codebase run

npm run format

On Upgrading to version 7 or higher

  • requires eslint version 8.26.0 or higher
  • for backend services, you should delete the domain-specific eslintrc

FAQ

Should I override the rule X? I don't like it.

No. If you want to do this, you have to ask the team. If a rule really doesn't make sense then we should remove or disable it.

Can I disable the rule on one line in my code, I have a good reason.

Yes. That's ok. Use a single-line disable.

Publishing

For Release

  1. Update the version in package.json
  2. Create a CHANGELOG entry
  3. Commit your changes
  4. npm pack --dry-run to see what will be published
  5. npm publish
  6. Create a release on GitHub. Use the version as the tag and release name. For example for version 1.0.0 the tag and release name would be v1.0.0. Add the CHANGELOG details to the release.

For Development

  1. Update the version in package.json to be postfixed with -next.x where x is a number
  • for example your first test version might look like 0.7.1-next.0, second test version would have next.1, etc
  1. run npm publish --canary --exact --preid canary --tag=canary
  2. In the project you wish to test in, run npm i eslint-config-neo@canary

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-config-neo

Weekly Downloads

1,393

Version

0.12.0

License

MIT

Unpacked Size

20 kB

Total Files

11

Last publish

Collaborators

  • divanshu
  • maiko.trindade
  • neo-ahmed-jama
  • neo-eason-chang
  • mganzneo
  • neo-colin-hanlon-dearman
  • neo-edimar-cardoso
  • neo-chris-noble
  • neo-ife-ojikutu
  • neo-will-parker
  • neo-paula-grangeiro
  • gaulford
  • danielafekhume-neo
  • neo-lior-ben-shahar
  • neo-diego-nunes
  • tim-neo2
  • antonio.canabrava
  • neo.eduardoyuidy
  • neo-oleksandr-yanchenko
  • neo-barry-li
  • desmond-maloney
  • neo-elgiz-abbasov
  • nikita-syrotenko
  • neo-bclausi
  • dustinn1235
  • neo-peter-spangler
  • neo-rivan-mota
  • neo-daniel-brennan
  • neo-matt-felice
  • neo-rameez-virji
  • matt-armstrong
  • rajanatneo
  • neo-zhaoquan-zhang
  • alejandrogarbi
  • ronellgarcia
  • edward.nazarov
  • annakumova
  • leah-is-offline
  • neo-shruti-goyal
  • felipe.minetto
  • tunde-neo
  • neo-shubham-patel
  • biancaballena
  • jadonduby
  • msalama
  • ishmeet.rayat
  • neo-bryce-brandford
  • neo-ricardo-gomez
  • neobot1
  • neo-dakota-chatt
  • lucasjohannson
  • neo-travis-friesen
  • mike.himbeault-neo
  • raul.ribeiro
  • anhtranneo
  • lucachamecki
  • amievishwa
  • neo-matias-wengiel
  • neo-ahmed-seifelnasr
  • rhullyam
  • das-boss
  • kennethcolina
  • marvindeleon
  • neo-miguel-castro
  • neo-dione-silva
  • hanna.tkachenko
  • nico-connor
  • roman.mnatsakanian
  • riley-pickerl
  • briancruz
  • amjad-mahfoud-neo
  • neoauderesantos
  • nitin.madan
  • mohpor
  • punit.patel
  • brayden_sc_neo
  • anna_benemanskaia
  • hrishikeshkale
  • kyle-elyk-neo
  • michelepiperni
  • neo-youre_pena
  • neo-michal-kowal
  • niconeiman
  • neodiegobeltran
  • stburke
  • marcelo.matos
  • matheusicaro
  • maiahneo
  • rjberry
  • mohamedalhammoud
  • neo-hasanpreetsingh
  • jcavalcanti
  • stephanie-wang-neo
  • kaelanneofinancial
  • vinicius-barcelos
  • benx-neo
  • mhowitt-neo
  • malcolm-neo
  • neo-seol-kim
  • brentcam
  • teena_
  • deankim
  • herculesjr
  • matthew.belford
  • rishbar
  • neo-baonguyen
  • caio.andrade
  • luan.le
  • dennisbarthel
  • lavanya.mohan
  • dhruvang
  • neo-rodrigoraval
  • joeljwood
  • nahom-neo
  • stefan.amyotte
  • timothy.couch.neofinancial
  • scottkayeneo
  • omolara
  • ar-ies
  • cjnewman
  • vidalrmrz
  • rnetto46
  • iansu
  • darrenpicard25
  • maxgoo
  • stschmaltz
  • usernameseb
  • eric.zaporzan.neo
  • lucasparreira
  • lewishorwood
  • craigsiemens
  • diegobmy
  • joelsimpson
  • jooh-lee
  • kasrababaei
  • mattlabarre
  • u2v22
  • johnclendvoy
  • demaestro
  • sudeep.sidhu
  • daylan.law
  • neo-stephen
  • neogibson
  • beraki
  • vrochamaaia
  • d_fenniak
  • adamtranquilla
  • nehasingh1801
  • lucaslongarini
  • erozonachi
  • faddoul
  • npoltz-neo