-
Notifications
You must be signed in to change notification settings - Fork 691
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
Fix linting issues and update some of the rules #36
Conversation
…g and passing options to it. Added request module to jsdom collector (using the headers options). Clean up some of the todos and homogeneized code
.eslintrc.json
Outdated
@@ -10,7 +10,8 @@ | |||
}, | |||
"parser": "typescript-eslint-parser", | |||
"plugins": [ | |||
"import" | |||
"import", | |||
"typescript" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@molant You also need to add eslint-plugin-typescript
to the package.json
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, good catch 🐟
.eslintrc.json
Outdated
"yoda": ["error", "never"] | ||
"yoda": ["error", "never"], | ||
|
||
"typescript/type-annotation-spacing": "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add: typescript/no-unused-vars
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that rule in the supported ones. Where is it coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it's not yet in any published npm
version.
src/lib/sonar.ts
Outdated
@@ -8,13 +8,12 @@ | |||
// ------------------------------------------------------------------------------ | |||
|
|||
import { EventEmitter2 as EventEmitter } from 'eventemitter2'; | |||
import * as _ from 'lodash'; | |||
// import * as _ from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just remove it until we actually use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely forgot about this one
src/bin/sonar.ts
Outdated
@@ -15,7 +15,9 @@ const debug = (process.argv.includes('--debug')); | |||
|
|||
// must do this initialization *before* other requires in order to work | |||
if (debug) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, for the cases where there is just one line, it's overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we need to enable it in the entrance point for other to work as the comment says. Are you referring to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to something else?
Sorry for the confusion. I was referring to the empty lines. When there is just a single line (i.e.: require('debug').enable('sonar:*,-sonar:code-path');
), it's overkill to add empty lines around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the rule. Don't think we can configure it at that level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed that rule and increase the number of max empty lines to 2 so the code can breath a bit more for you.
src/lib/collectors/jsdom.ts
Outdated
@@ -46,45 +45,56 @@ const defaultOptions = { | |||
}; | |||
|
|||
const builder: CollectorBuilder = (server: Sonar, config): Collector => { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are groups, like here, it makes sense to have the empty line. ✨
src/lib/types.ts
Outdated
* @fileoverview Interfaces and enums used in different files in Sonar that do not belong in an specific place. | ||
* @author Anton Molleda (@molant) | ||
*/ | ||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use --alwaysStrict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this file shouldn't even be in the final compile. It is used only to check that the types are OK. I added the alwaysStrict
to the compiler options and set to never the strict
rule in eslint.
@alrra you can take another look and merge if it is OK. |
Change made so that the process of opening the `LICENSE` file is easier for non-technical people.
Also, changed folder structure and add dependencies.
From https://docs.npmjs.com/files/package.json#private: " If you set `"private": true` in your `package.json`, then `npm` will refuse to publish it. This is a way to prevent accidental publication of private repositories. "
* Remove reference to `.travis.yml` as that file is not included. * Add link to the site instead of explaining every line, and add comments only for when the information cannot be found on the site. * Add `trim_trailing_whitespace` property.
Most people will expect `.sonarrc` to work as in general `.<name>rc` files seem to be the preferred way for people to store CLI specific configurations.
For the time being we decided to keep things simple and only support JSON, as supporting multiple formats can complicate things and even create some problems. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ref: eslint/eslint#4406 (comment)
* Added the TypeScript plugin to ESLint * Tweaked the rules to be more compatible with our style and TS * Refactored the code to require less `imports` so less `no-unused-vars` errors * Fixed all other linting issues
* Add ESLint TypeScript plugin. * Tweak rules to be more compatible with the current style and TypeScript. * Refactor code to require less `imports`, thus, generate less `no-unused-vars` errors. * Fix other linting issues. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Close #36
* Add ESLint TypeScript plugin. * Tweak rules to be more compatible with the current style and TypeScript. * Refactor code to require less `imports`, thus, generate less `no-unused-vars` errors. * Fix other linting issues. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Close #36
import
for types and thus avoiding triggering theno-unused-variables
This one supersedes pull #18