Commit graph

33 commits

Author SHA1 Message Date
WMDE-Fisch a3f3cf9e3f build: Update eslint 0.26.0 and apply fixes
Mainly auto fixes but also getting rid of some straight forward lint
warnings to reduce the wall of issues a bit when running the tests.

Also removing some rule exceptions that seem to got more relaxed
upstream.

Change-Id: Icb4d73374583675be74517e6df6508314d61e8c2
2024-01-12 13:50:19 -05:00
Ed Sanders bf3600f20a Convert nycrc from JSON to JS to allow comments
Change-Id: Ib3c3b8b2f5f87b5f00dcf8b718a0d1bf07948c56
2023-11-09 11:36:11 +00:00
Ed Sanders 461f949823 build: Update linters
Also restructure eslint config so that
* root files are linted with server rules
* src and tests share config

Change-Id: Ie4d0731ba9670af7f3e60cdfe3c4e331386b17c6
2023-11-09 11:36:08 +00:00
Jon Robson 580067b94e Discourage jQuery usage in Popups extension
Change-Id: Iff0c81e4c1d78cc52d1bd9d81e24d8fae228c9bc
2023-06-13 15:39:57 -07:00
Jon Robson f9b9feaff5 ES6: Prefer Object.assign and Promise to jQuery
Additional change:
* Lint dist folder as ES6 code now ES6 is everywhere

Change-Id: Ie77046f5c6fbdafa4679dbaf97f7bf6f16292b9c
2023-04-19 17:02:14 -07:00
Umherirrender 3573232c21 build: Updating npm dependencies
* eslint-config-wikimedia: 0.22.1 → 0.24.0
* @wikimedia/mw-node-qunit: 6.3.3 → 7.0.0

Change-Id: I348eb70bfc6c1d6c922c8290152926183712dee1
2023-04-03 23:14:47 +02:00
Ed Sanders 536470c01d build: Update eslint-config-wikimedia to 0.16.2
Change-Id: Icb65074fe64993314bbb28f690ce3ce0f89fb57c
2020-06-26 17:05:56 +01:00
Thiemo Kreuz 76e02fae98 Remove obsolete mediaWiki and jQuery aliases
Notice how this actually reduces the size of the final, compiled index.js.
It's not much, but still.

One issue I noticed is that the coverage reports for the JS code stopped
working. I have no idea why.

Bug: T208951
Change-Id: I2fe92579574b3b1ba4d2dd064899eee944045a96
2019-10-22 09:30:46 +02:00
Ed Sanders 4d885286a3 eslint: Enforce template-curly-spacing
Change-Id: I5640e86cba25f6100c7814c2ef8a845941f73497
2019-08-15 10:24:43 +02:00
Ed Sanders cfa0b100ad eslint: Enforce no-prototype-builtins
Change-Id: I4244f0576e48c233d24533b45a28c07b2531d6da
2019-08-15 08:00:35 +00:00
Ed Sanders 2687d12c52 eslint: Remove valid-jsdoc override
Change-Id: I6a9936743a74afb528713f21e016838947fa1914
2019-08-15 08:00:24 +00:00
Ed Sanders ac8ff96425 eslint: Use wikimedia/language/es6 and remove duplicate rules
Change-Id: I3c3e8dc763a2f2a8bed50c7d0d06dfde37a64f54
2019-08-15 07:58:28 +00:00
Stephen Niedzielski deffae141c Hygiene: improve ESLint globals readability
- Drop unused moment, Redux, and ReduxThunk globals.

- Instead of using a confusing and deprecated boolean, specify that
  globals are "readable" / "writable"
  https://eslint.org/docs/user-guide/configuring#specifying-globals

Change-Id: I711a4ea7c51c9a560f20fc28bc99bd932c7e1e25
2019-02-21 07:59:56 -07:00
Ed Sanders e1c4e94b23 build: Update eslint-config-wikimedia to 0.10.0
Also enable jquery ruleset.

Change-Id: Ie1f43d0335ea2aad1e2dd5d86b775316105c3d90
2019-01-31 11:05:33 +01:00
Nick Ray c64497e5df Upgrade elint-config-wikimedia (drop eslint-plugin-qunit)
The following upgrade was made:

eslint-config-wikimedia | 0.8.1 | 0.9.0

The upgrade of eslint-config-wikimedia removes the need of
eslint-plugin-qunit as a peerDependency because it is now a hard
dependency [1] so it was removed in our package.json.

It appears the biggest change in the upgrade was the use of separate
profiles [2]. Given this, our root .eslintrc.json was updated to extend
from 'wikimedia/client'.

Several test files were flagged by the upgraded linter and were fixed in
this patch. Additionally, our build file was flagged for having too many
statements on one line. This rule was turned off in .eslintrc.es5.json

[1] https://github.com/wikimedia/eslint-config-wikimedia/blob/master/package.json#L48
[2] https://github.com/wikimedia/eslint-config-wikimedia/blob/master/CHANGELOG.md#090--2018-11-19

Bug: T209314
Change-Id: I29db72e77f04a327bc9c2b558c6d53849287bb80
2018-12-13 14:12:06 -07:00
Stephen Niedzielski d1ef4cbe88 Hygiene: limit ESLint inheritance
The project ESLint configuration unintentionally inherited unwanted
configuration from MediaWiki, which allows global jQuery usage. Cap the
project's ESLint hierarchy at the project root.

Change-Id: I5177d306feface7fcce0867c624bbcf9e74f19fc
2018-10-16 16:22:25 +00:00
Ed Sanders c74d2e5313 build: Update linters
Bug: T202739
Change-Id: Ie3f68977598f46f7e12b216f8381b2e9dc6d83ad
2018-09-11 10:26:35 -07:00
jdlrobson 69efbfc377 Enforce eslinting for jsdoc
Let's improve our documentation by linting it and ensuring it
is complete and matches guidelines

This fixes offenders

Change-Id: I7c829b375705e763085cf731e9a77cc14339af67
2018-07-17 08:21:01 -05:00
jdlrobson 10e6e25091 Upgrade eslint-config-wikimedia
* Force arrow-parens
* Disable no-prototype-builtins for time being
* Drop unnecessary maxlen rule

Change-Id: Iceb0fe47354a5753202d2c6ad9e1a9c76791f744
2018-07-13 07:42:12 -05:00
Mukunda Modell 2d6bd5f4b7 Remove comments from json file - won't pass scap's json lint
Comments in this json file preventing scap deploy

Change-Id: I71a3c29c0d0d6d125fff2803bb5d912536c1a4d0
2018-05-17 17:43:32 -05:00
Stephen Niedzielski 367b12a278 Hygiene: bump ESLint to ES6 and lint more files
- Bump the ESLint configuration ECMAScript 2015 given that we use Babel
  and have a safeguard to verify build products are ES5.

- Lint more files including all tests and the Webpack and Grunt configs.

Change-Id: I099cbe009eda2349ddc051976ace0d9f6c55fa30
2018-05-01 14:47:51 -05:00
jdlrobson 3245a2ac6e Hygiene: restrict use of $.each and fix offenders
Bug: T190142
Change-Id: I5da7a4a1ffe14647ec70b10b3a7ab9b935c5ca84
2018-03-21 14:24:22 -05:00
Stephen Niedzielski 007cc5ab7c Hygiene: favor string templates over concatenation
Update the ESLint config to favor ES6 strings where variables or string
concatenation is used and fix *all* offenders automatically via:

  eslint \
    --cache \
    --max-warnings 0 \
    --report-unused-disable-directives \
    --fix \
    src tests

Change-Id: I1a9345162348e5ded21d541e7a2ce251ea72ab5a
2018-03-21 08:05:55 -05:00
Stephen Niedzielski e284163014 Hygiene: use consistent ESLint severity syntax
Bug: T165036
Change-Id: I43a500fceb8179d30240dbec8ed56f8d4c7551e9
2018-03-21 10:45:09 +00:00
Stephen Niedzielski 57762e0417 Hygiene: favor const
Bug: T165036
Change-Id: I17d374eaac6627ca6a8ba178862b2a9cff2538c0
2018-03-21 10:44:24 +00:00
jenkins-bot 875789adf2 Merge "Hygiene: replace var with let and const" 2018-03-21 10:41:34 +00:00
Timo Tijhof 0f08ac9a9c Tooling: Remove some redundant max-len patterns
- `///` is not used in any linted files.
  It is/was used in webpack dist, but those are not and should not
  be passed through ESLint.
- `QUnit` was presumably added prematurely on the assumption
  that overly long test names should not be broken over multiple
  lines. However, being strings, they are already ignored.
- `// (?!eslint..)` was redundant. Ignoring warnings from max-len
  about an eslint-disable line has no influence on the actual
  parsing of those lines by ESLint.

Follows-up 807100b.

Bug: T185295
Change-Id: I2be2492848190b53d45240b38a08784b4a370819
2018-03-20 17:23:14 -07:00
Stephen Niedzielski 0bee0906d4 Hygiene: replace var with let and const
eslint \
    --cache \
    --max-warnings 0 \
    --report-unused-disable-directives \
    --fix \
    src tests

Change-Id: I051275126ae7fa9affd16c2504017c0584f2d9c7
2018-03-20 14:14:02 -05:00
joakin 807100bcca Limit line length to 80 characters
Enforce it with eslint.

Ignore:
* Comment lines with eslint disable directives
* QUnit test lines as they contain long subjects (QUnit.* (only, test,
  module, skip, etc)
* Strings, since long strings are used extensively in tests
  * Ignore template literals for similar reasons
* Regex literals as they may be too long, but can't be easily
  split in several lines
* Long urls

See bug for more general proposal for eslint-wikimedia-config.

Bug: T185295
Change-Id: I3aacaf46e61a4d96547c513073e179ef997deb09
2018-01-19 14:20:39 +01:00
joakin 4ed09011c2 Explicitly set ecmaVersion for eslint
Before, because of the use of sourceType: "module", ecmaVersion would be
assumed to be ES2015, but we write ES5 here at the moment.

This enables linting against ES2015 features like let and const.

See https://gerrit.wikimedia.org/r/#/c/374789/ for failing POC.

Change-Id: Id1d147866c37de3794213378a5e8a08af6f796a1
2017-08-30 13:47:49 +02:00
joakin e6081106f1 Use EcmaScript modules instead of common.js modules
Why: Because they are the approved standard by TC39 and Ecma for
JavaScript modules.

Changes:
  * Wrap mw-node-qunit in run.js to register babel to transpile modules
    for node v6
  * Change all sources in src/ to use ES modules
    * Change constants.js to be able to run without
      jQuery.bracketedDevicePixelRatio given ES modules are hoisted to
      the top by spec so we can't patch globals before importing it
  * Change all tests in tests/node-qunit/ to use ES modules
  * Drop usage of mock-require given ES modules are easy to stub with
    sinon

Additional changes:
  * Rename tests/node-qunit/renderer.js to renderer.test.js to follow
    the convention of all the other files
  * Make npm run test:node run only .test.js test files so that it
    doesn't run the stubs.js or run.js file.

Bug: T171951
Change-Id: I17a0b76041d5e2fd18e2d54950d9d7c0db99a941
2017-07-31 23:05:44 +00:00
jdlrobson 49df4b9572 Tooling: Begin to use webpack for JS code generation
Generate changeListeners via webpack
We now use a build folder to build the JavaScript for
our ResourceLoader modules. This is the first change
in a line of changes.
A source map is provided for debug support.

Bug: T156333
Change-Id: I771843d1ddb4b50adedc3fa53b30c2f1d8a76acb
2017-02-13 13:42:22 +01:00
joakin 4ca333e577 Remove jshint/jscs, add eslint and stylelint
...with the wikimedia presets.

For automatically fixing most of the JS lint problems run

      grunt eslint:fix

Some rules of stylelint were disabled given they cause problems with
existing popups code (like no id selectors for example).

Change-Id: I2153047c3ddbea50572dd329989088bb20787515
2016-12-16 13:35:34 +01:00