Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Upgrade linters to ESLint with stricter code style #1111

Merged
merged 15 commits into from
May 17, 2017
Merged

Upgrade linters to ESLint with stricter code style #1111

merged 15 commits into from
May 17, 2017

Conversation

matthewlane
Copy link
Collaborator

@matthewlane matthewlane commented Apr 7, 2017

Type of change

  • Build related changes

Description of change

  • Updates the quality/linting system from (JSHint && JSCS) to ESLint
  • Updates linting system to use a stricter code style

Other information

This PR is currently configured to use JavaScript Standard Style with semicolons. Compare this to other common linting configurations with number of linting problems found against the 0.21.0 release, and the number after running eslint --fix src:

config # of problems # after --fix
eslint:recommended 121 errors, 0 warnings 121 errors, 0 warnings
Standard (with semicolons) 2254 errors, 0 warnings 321 errors, 0 warnings
Airbnb 7214 errors, 376 warnings 1897 errors, 257 warnings

Other configs, such as Canonical mentioned in #776, or a custom rule set are possible.

Compare rule sets with https://sqren.github.io/eslint-compare/

Requesting feedback from the community and @prebid/core on which code style Prebid.js should use.

* Remove jshint and jscs
* Install gulp-eslint
* Replace 'quality' task with 'lint'
* Format lint errors with stylish
* Use JavaScript Standard Style with semicolons
@mkendall07
Copy link
Member

Hey @snapwich , @protonate thoughts on this?

Copy link
Collaborator

@protonate protonate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks @matthewlane

@dbemiller
Copy link
Contributor

Changes look great. ESLint is a really nice tool.

My only real concern is not having it in the CI process anywhere. If I check out your branch and run gulp lint, it prints out the 2254 errors like you mentioned. But... it looks like the CI builds are still passing.

If there's nothing automation preventing these errors, then I don't think people will respect them. It's unrealistic to say "please don't add any more errors," because someone won't notice the difference between 2254 and 2256.

Do you think it's worth fixing these now? Or do you want to run eslint --fix locally (to get it down to ~300) and then open another issue about it?

@mkendall07
Copy link
Member

I agree with @dbemiller on this. Can we commit the eslint --fix changes, add exceptions for the ~300 existing errors and enforce strict checking in travis (add the lint gulp task into run-tests which travis invokes). ?

@protonate
Copy link
Collaborator

@dbemiller looks like Travis CI failed on ES lint errors. Would you update the PR to pass CI and then we can merge. Thanks!

@protonate protonate assigned dbemiller and unassigned matthewlane Apr 28, 2017
@dbemiller
Copy link
Contributor

@protonate Yeah, that failure is on purpose. The weird behavior seems to stem from the parallelized gulp tasks stepping on each other's toes.

I think I straightened them out... but want to re-run the Travis build 4-5 times to make sure it fails reliably. Then I'll fix them and run it 4-5 times to make sure it passes reliably.

@dbemiller
Copy link
Contributor

Looks to be good now ^^. Someone might want to sanity check the gulpfile before merging, though, since I declared some task dependencies that don't necessarily make a ton of sense.

I don't think they'll hurt anything (besides performance)... but it'd be good to have another set of eyes on them.

@mkendall07 mkendall07 requested a review from snapwich May 10, 2017 13:54
@dbemiller
Copy link
Contributor

hey @snapwich, do you think you'll be able to get around to this sometime soon? Nearly every PR which gets merged has style issues in it, and keeping this branch up to date is getting tedious (if I don't fix them, Travis will fail all the PRs until they are fixed) Once this gets into master, CI will take care of it for us.

All the changes to actual JS code were generated by eslint --fix. When merging from master, I used git checkout --theirs and then ran eslint --fix again. Any errors which eslint couldn't fix automatically were dealt with by adding exceptions to the .eslintrc (which can be fixed in later PRs) to keep the changeset as safe as possible.

gulpfile.js Outdated
});

gulp.task('jscs', function () {
gulp.task('lint', () => {
return gulp.src('src/**/*.js')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to lint the test folder as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed & done.

"faker": "^3.1.0",
"fs.extra": "^1.3.2",
"gulp": "^3.8.7",
"gulp-babel": "^6.1.2",
"gulp-clean": "^0.3.1",
"gulp-clean": "^0.3.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're updating dependencies, the yarn.lock file should probably be updated as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch ^^. Done.

…keep the newly required exceptions to as small of a scope as possible.
@dbemiller dbemiller merged commit 0799a64 into master May 17, 2017
@dbemiller dbemiller deleted the eslint branch May 17, 2017 01:32
bfmdeploy pushed a commit to bfmdeploy/Prebid.js that referenced this pull request May 19, 2017
* Upgraded to ESLint with stricter code style, for both sources and tests
* Updated some dependencies and the yarn.lock file
mkendall07 pushed a commit that referenced this pull request May 19, 2017
* Added ad unit size to bid request

* Fixed lint errors

* Added ad unit size to bid request

* Prebid 0.23.1 Release

* Add trafficSourceCode + test (#1184)

* pre release version bump

* inclusion of popular Nordic ad sizes to default size list (#1168)

inclusion of popularNordic ad sizes to default size list

Removed redundant 104 size and added size 32 instead

Fixed trailing comma

* Add PubWise Analytics (#1151)

* PubWise Analytics

* Updates based on Feedback

* add new rp_secure param to rubicon adapter (#1190)

* Add type conversion into PrebidServer to handle inconsistent types. (#1195)

* Add type conversion into prebxdserver to handle inconsistent types.

* Only check for params that exist.

* adding test

* fix string conversion and add unit tests

* fix for code review

* add debug output

* remove accidental commit

* newline

* Add dynamic bidfloor parameter to Smart Adserver Adapter (#1194)

* Smart AdServer adapter

Add Smart AdServer adapter with tests

* fix not supported method

Replace startsWith which is not supported in all browser version by
lastIndexOf.

* Issue with optional parameter

Fix issue when no targeting is specified and remove "undefined" value
passed in url

* Add dynamic bidfloor option in the SmartAdServer prebid call.

* Bug fix: bids served by secure creatives does not get pushed into _winningBids (#1192)

* Upgrade linters to ESLint with stricter code style (#1111)

* Upgraded to ESLint with stricter code style, for both sources and tests
* Updated some dependencies and the yarn.lock file

* Add Support for DigiTrust in Rubicon Adapter (#1201)

* Add support for DigiTrust

* Add rubicon tests covering digitrust failures

* Remove whitespace in Rubicon adapter

* HIRO Media: Remove batching mechanism and use AJAX instead of JSONP (#1133)

* Remove batching mechanism and use AJAX instead of JSONP

* Fix `undefined` value checks

* Rename secureCreatives file and lint (#1203)

* Rename secureCreatives file and lint

* Updated package script for linting

* Use 'gulp run-tests' in package script for testing

* updated tag (#1212)

* Common user-sync (#1144)

* Changed “bidRequest” to “bid” for clarity
@dbemiller dbemiller mentioned this pull request May 23, 2017
9 tasks
outoftime pushed a commit to Genius/Prebid.js that referenced this pull request May 24, 2017
…built

* 'master' of https://github.com/prebid/Prebid.js: (23 commits)
  Increment pre version
  Probed 0.24.0 Release
  Beachfront adapter - add ad unit size (prebid#1183)
  Thoughtleadr adapter - fix postMessage (prebid#1207)
  When prebid server issues a no-bid response, call addBidResponse for every adUnit requested (prebid#1204)
  Improvement/timeout xhr (prebid#1172)
  Add native support (prebid#1072)
  Improvement/alias queue (prebid#1156)
  Updated documentaion (prebid#1160)
  Improvement/prebid iframes amp pages (prebid#1119)
  Fixes prebid#1114 possible xss issue (prebid#1186)
  Allowed setTargetingForGPTAsync() to target specific ad unit codes. (prebid#1158)
  updated tag (prebid#1212)
  Common user-sync (prebid#1144)
  Rename secureCreatives file and lint (prebid#1203)
  HIRO Media: Remove batching mechanism and use AJAX instead of JSONP (prebid#1133)
  Add Support for DigiTrust in Rubicon Adapter (prebid#1201)
  Upgrade linters to ESLint with stricter code style (prebid#1111)
  Add dynamic bidfloor parameter to Smart Adserver Adapter (prebid#1194)
  Bug fix: bids served by secure creatives does not get pushed into _winningBids (prebid#1192)
  ...
This was referenced Jun 7, 2017
jbAdyoulike pushed a commit to jbAdyoulike/Prebid.js that referenced this pull request Sep 21, 2017
* Added ad unit size to bid request

* Fixed lint errors

* Added ad unit size to bid request

* Prebid 0.23.1 Release

* Add trafficSourceCode + test (prebid#1184)

* pre release version bump

* inclusion of popular Nordic ad sizes to default size list (prebid#1168)

inclusion of popularNordic ad sizes to default size list

Removed redundant 104 size and added size 32 instead

Fixed trailing comma

* Add PubWise Analytics (prebid#1151)

* PubWise Analytics

* Updates based on Feedback

* add new rp_secure param to rubicon adapter (prebid#1190)

* Add type conversion into PrebidServer to handle inconsistent types. (prebid#1195)

* Add type conversion into prebxdserver to handle inconsistent types.

* Only check for params that exist.

* adding test

* fix string conversion and add unit tests

* fix for code review

* add debug output

* remove accidental commit

* newline

* Add dynamic bidfloor parameter to Smart Adserver Adapter (prebid#1194)

* Smart AdServer adapter

Add Smart AdServer adapter with tests

* fix not supported method

Replace startsWith which is not supported in all browser version by
lastIndexOf.

* Issue with optional parameter

Fix issue when no targeting is specified and remove "undefined" value
passed in url

* Add dynamic bidfloor option in the SmartAdServer prebid call.

* Bug fix: bids served by secure creatives does not get pushed into _winningBids (prebid#1192)

* Upgrade linters to ESLint with stricter code style (prebid#1111)

* Upgraded to ESLint with stricter code style, for both sources and tests
* Updated some dependencies and the yarn.lock file

* Add Support for DigiTrust in Rubicon Adapter (prebid#1201)

* Add support for DigiTrust

* Add rubicon tests covering digitrust failures

* Remove whitespace in Rubicon adapter

* HIRO Media: Remove batching mechanism and use AJAX instead of JSONP (prebid#1133)

* Remove batching mechanism and use AJAX instead of JSONP

* Fix `undefined` value checks

* Rename secureCreatives file and lint (prebid#1203)

* Rename secureCreatives file and lint

* Updated package script for linting

* Use 'gulp run-tests' in package script for testing

* updated tag (prebid#1212)

* Common user-sync (prebid#1144)

* Changed “bidRequest” to “bid” for clarity
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* Upgraded to ESLint with stricter code style, for both sources and tests
* Updated some dependencies and the yarn.lock file
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* Added ad unit size to bid request

* Fixed lint errors

* Added ad unit size to bid request

* Prebid 0.23.1 Release

* Add trafficSourceCode + test (prebid#1184)

* pre release version bump

* inclusion of popular Nordic ad sizes to default size list (prebid#1168)

inclusion of popularNordic ad sizes to default size list

Removed redundant 104 size and added size 32 instead

Fixed trailing comma

* Add PubWise Analytics (prebid#1151)

* PubWise Analytics

* Updates based on Feedback

* add new rp_secure param to rubicon adapter (prebid#1190)

* Add type conversion into PrebidServer to handle inconsistent types. (prebid#1195)

* Add type conversion into prebxdserver to handle inconsistent types.

* Only check for params that exist.

* adding test

* fix string conversion and add unit tests

* fix for code review

* add debug output

* remove accidental commit

* newline

* Add dynamic bidfloor parameter to Smart Adserver Adapter (prebid#1194)

* Smart AdServer adapter

Add Smart AdServer adapter with tests

* fix not supported method

Replace startsWith which is not supported in all browser version by
lastIndexOf.

* Issue with optional parameter

Fix issue when no targeting is specified and remove "undefined" value
passed in url

* Add dynamic bidfloor option in the SmartAdServer prebid call.

* Bug fix: bids served by secure creatives does not get pushed into _winningBids (prebid#1192)

* Upgrade linters to ESLint with stricter code style (prebid#1111)

* Upgraded to ESLint with stricter code style, for both sources and tests
* Updated some dependencies and the yarn.lock file

* Add Support for DigiTrust in Rubicon Adapter (prebid#1201)

* Add support for DigiTrust

* Add rubicon tests covering digitrust failures

* Remove whitespace in Rubicon adapter

* HIRO Media: Remove batching mechanism and use AJAX instead of JSONP (prebid#1133)

* Remove batching mechanism and use AJAX instead of JSONP

* Fix `undefined` value checks

* Rename secureCreatives file and lint (prebid#1203)

* Rename secureCreatives file and lint

* Updated package script for linting

* Use 'gulp run-tests' in package script for testing

* updated tag (prebid#1212)

* Common user-sync (prebid#1144)

* Changed “bidRequest” to “bid” for clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants