Skip to content

JSHint to ESLint && modifying code (i.e. ES2015) #64

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

JSHint to ESLint && modifying code (i.e. ES2015) #64

wants to merge 1 commit into from

Conversation

segandiaye
Copy link

JSHint to ESLint && modifying code (i.e ES2015), for the migration see migrating-to-eslint

Why changed the code?

I changed the code to make it compatible with the ES2015 standard, and for that you used ESLint. And I removed everything related to JSHint whose configuration is no longer compatible with the new code.

Why Switching from JSHint to ESLint?

  • ESLint allows customizing rules for errors, best practices, variable declarations, ES6, style and JS running on Node. Additionally, custom rules can be applied.
  • ESLint is more suitable for projects in NodeJs that follow the recent Ecmascripts standard (ES> 2015)

ESlint integration and configuration

I start by installing the necessary by typing :

`$ npm install eslint --save-dev`
`$ npm install eslint-config-usecases --save-dev`
`$ npm install -g polyjuice`
`$ polyjuice --jshint .jshintrc> .eslintrc`

$ npm install -g polyjuice for more details of polyjuice Click here.

$ polyjuice --jshint .jshintrc> .eslintrc for automatic conversion from jshint to eslint and automatic creation of .eslintrc.

And then add extends: 'usecases/usecase/nodejs' in .eslintrc
Then go to package.json and add in the script:

`" eslint ":" eslint. ",`
`" eslint: fix ":" eslint --fix. "`

For the .eslintignore file create it manually and add the lines of the .jshintignore file:

node_modules/*
coverage/*
tmp/*
.git/*

Manual correct of errors

To fix some errors automatically I run $ npm run eslint:fix and there will be still some errors to fix manually.

To fix them or ignore them I follow ESLint rules.

If you choose to stay on JSHint you will need to add a configuration

An example of a minimal configuration :

"jshintConfig": {
  "esnext": true,
  "undef": true,
  "unused": true
}

and not forget to run $ npm install --save-dev jshint

 JSHint to ESLint && making code compatible to ES2015

JSHint to ESLint && modifying code (i.e ES2015)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant