5 Commits

Author SHA1 Message Date
Juan Cruz Viotti
df8611df11 chore: add ESLint Lodash plugin (#1148)
This is one step towards enforcing the linter until we barely have to
check for style issues on code reviews.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-08 19:11:15 -04:00
Juan Cruz Viotti
6c8bc117ab chore: revise ESLint built-in configuration (#1149)
There are a lot of new rules since the last time I revised the ESLint
rules documentation.

I've updated the main `.eslintrc.yml` to include some newer additions,
plus I added another ESLint configuration file inside `tests`, so we can
add some stricted rules to the production code while relaxing them for
the test suite (due to the fact that Mocha is not very ES6 friendly and
Angular tests require a bit of dark magic to setup).

This is a summary of the most important changes:

- Disallow "magic numbers"

These should now be extracted to constants, which forces us to think of
a good name for them, and thus make the code more self-documenting (I
had to Google up the meaning of some existing magic numbers, so I guess
this will be great for readability purposes).

- Require consistent `return` statements

Some functions relied on JavaScript relaxed casting mechanism to work,
which now have explicit return values. This flag also helped me detect
some promises that were not being returned, and therefore risked not
being caught by the exception handlers in case of errors.

- Disallow redefining function arguments

Immutability makes functions easier to reason about.

- Enforce JavaScript string templates instead of string concatenation

We were heavily mixing boths across the codebase.

There are some extra rules that I tweaked, however most of codebase
changes in this commit are related to the rules mentioned above.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-07 23:46:44 -04:00
Juan Cruz Viotti
4172291a10 chore: improve JSDoc ESLint rules (#1147)
- Prefer `@returns` to `@return`
- Prefer `@param` to `@arg`
- Prefer capitalised types

See: https://github.com/resin-io/etcher/pull/1111#discussion_r103483879
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-01 14:26:47 -04:00
Juan Cruz Viotti
edc69170d9 chore: don't force a linebreak style in ESLint (#570)
We're currently forcing a UNIX linebreak style, which causes hundreds of
complaints from the linter when cloning the project in a Windows machine
with a default configuration.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-07-12 10:30:07 -04:00
Juan Cruz Viotti
ea1df5cc11 chore: make use of ESLint (#540)
JSCS has merged with ESLint. This is the perfect excuse to move to
ESLint and unify both JSHint and JSCS hints under ESLint.

This PR also deprecates `gulp lint` in favour of `npm run lint`.

See: https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.zbuwvxa5y
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-06-30 20:09:44 +05:30