FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.44k stars 637 forks source link

Switch from JSHint to ESLint #1360

Closed Hirse closed 4 years ago

Hirse commented 4 years ago
campersau commented 4 years ago

When I run npm run build I get this message:

Running "browserify-components" task
>> ./components/.eslintrc.json/.eslintrc.json.js does not exist. If this component is obsolete, please remove that directory or perform a clean build.

You can also see it in the CI builds.

This is because we use readdir and assume that inside the components folder are only other folders and no files. So we need to change the logic a little bit.

https://github.com/FredrikNoren/ungit/blob/2a09c95dbc2eab0f726b5f61bcc1d9255827df5c/Gruntfile.js#L154-L163


Before we did run jshint as part of build now we have to manually run npm run lint. So we should either:


Also we now have two options to fix formatting errors:

Do we need both? If yes should be change format to run eslint . bin/* --fix instead? Should we rename it to e.g. lint-fix?


This will be the output when there are linting errors:

PS P:\ungit> npm run lint

> ungit@1.5.7 lint P:\ungit
> eslint . bin/*

P:\ungit\Gruntfile.js
  350:5  error  Insert `;`  prettier/prettier

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ungit@1.5.7 lint: `eslint . bin/*`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ungit@1.5.7 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Hirse commented 4 years ago

@campersau thanks for the detailed review.

I had removed the linting from the build step to speed up build time and to not stop the build when there are formatting issues. The linting is only really required before commit. During development linting or formatting issues should not stop the build.

We could consider adding the linting as pre-commit hook or adding it to the build in a non-blocking way (i.e. only issue warnings).