mediawiki-skins-MinervaNeue/.eslintrc.js
Nicholas Ray 46ab5b9c36 Prevent our 'no-restricted-properties' from clobbering eslint-config-wikimedia
Our eslintrc extends from 'wikimedia/client' which includes a
'no-restricted-properties' ruleset from the 'not-es5.js' file [1].

However, we were also including our own 'no-restricted-properties'
rules.

ESLint handle this duplication by clobbering instead of merging
so eslint-config-wikimedia's no-restricted-properties where not taking
effect and we were losing out on some guards against using es6.

This commit corrects that and makes both no-restricted-properties
rulesets merge instead of clobber as already done in MobileFrontend [2]

[1] 07320f16ae/language/not-es5.js (L5)
[2] https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/.eslintshared.js

Bug: T239269
Change-Id: Ibc2c144be51719d71a4c1d5828486253a5d4bf5d
2020-02-11 17:04:14 -07:00

55 lines
1.7 KiB
JavaScript

// "no-restricted-properties" rules are not properly merged when just using "extends".
// Therefore we have to have this file which calls a custom merge function.
// The merge function calls Object.assign with special handling for configuration such as
// `no-restricted-properties` and `no-restricted-syntax` which are array based - ensuring the two
// values being merged are concatenated.
const merge = require( 'eslint-config-wikimedia/language/merge.js' );
const config = {
"root": true,
"extends": [
"wikimedia/client",
"wikimedia/jquery",
"wikimedia/mediawiki"
],
"env": {
"commonjs": true
},
"globals": {
"OO": "readonly",
"require": "readonly"
},
"rules": {
"no-restricted-properties": [
"error",
{
"property": "mobileFrontend",
"message": "Minerva should only make use of core code. Any code using mobileFrontend should be placed inside the MobileFrontend extension"
},
{
"property": "define",
"message": "The method `define` if used with mw.mobileFrontend is deprecated. Please use `module.exports`."
},
{
"property": "done",
"message": "The method `done` if used with Deferred objects is incompatible with ES6 Promises. Please use `then`."
},
{
"property": "fail",
"message": "The method `fail` if used with Deferred objects is incompatible with ES6 Promises. Please use `then`."
},
{
"property": "always",
"message": "The method `always` if used with Deferred objects is incompatible with ES6 Promises. Please use `then`."
}
],
"object-property-newline": "error",
"no-use-before-define": "off",
"no-underscore-dangle": "off"
}
};
module.exports = Object.assign(
config,
merge( config, require( 'eslint-config-wikimedia/language/not-es5.js' ) )
);