Jforrester has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/344673 )
Change subject: build: Replace jshint and jscs with eslint
......................................................................
build: Replace jshint and jscs with eslint
Bug: T161142
Change-Id: I9c785a74d8b10304622c6242da2aacbf435aecdf
---
A .eslintrc.json
D .jscsrc
D .jshintignore
D .jshintrc
M Gruntfile.js
M package.json
M resources/infrastructure/ext.centralNotice.adminUi.campaignPager.js
M resources/subscribing/ext.centralNotice.bannerHistoryLogger.js
M resources/subscribing/ext.centralNotice.display.chooser.js
M resources/subscribing/ext.centralNotice.display.js
M resources/subscribing/ext.centralNotice.display.state.js
M resources/subscribing/ext.centralNotice.freegeoipLookup.js
M resources/subscribing/ext.centralNotice.largeBannerLimit.js
A tests/.eslintrc.json
M tests/qunit/subscribing/ext.centralNotice.display.chooser.tests.js
M tests/qunit/subscribing/ext.centralNotice.display.tests.js
16 files changed, 52 insertions(+), 53 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/73/344673/1
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..f42e620
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,26 @@
+{
+ "extends": "wikimedia",
+ "parserOptions": {
+ "ecmaVersion": 3
+ },
+ "env": {
+ "browser": true,
+ "jquery": true
+ },
+ "globals": {
+ "mediaWiki": false
+ },
+ "rules": {
+ "eqeqeq": 0,
+ "no-multi-spaces": 0,
+ "no-undef": 0,
+ "no-unneeded-ternary": 0,
+ "no-use-before-define": 0,
+ "no-whitespace-before-property": 0,
+ "operator-linebreak": 0,
+ "semi-spacing": 0,
+ "spaced-comment": 0,
+ "valid-jsdoc": 0,
+ "wrap-iife": 0
+ }
+}
diff --git a/.jscsrc b/.jscsrc
deleted file mode 100644
index 387415f..0000000
--- a/.jscsrc
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "preset": "wikimedia",
- "jsDoc": {
- "checkAnnotations": {
- "preset": "jsdoc3"
- },
- "checkTypes": "strictNativeCase"
- }
-}
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index 58875fd..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/node_modules
-/vendor
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index d07cf26..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "predef": [
- "jQuery",
- "mediaWiki",
- "QUnit",
- "JSON",
- "module",
- "require"
- ],
-
- "undef": true,
- "unused": true,
- "trailing": true,
-
- "laxbreak": true,
-
- "browser": true,
-
- "es3": true
-}
diff --git a/Gruntfile.js b/Gruntfile.js
index 588f118..cedd106 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,24 +1,18 @@
-/*jshint node:true */
+/* eslint-env node */
module.exports = function ( grunt ) {
- grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
- grunt.loadNpmTasks( 'grunt-jscs' );
grunt.initConfig( {
- jshint: {
- options: {
- jshintrc: true
- },
+ eslint: {
all: [
+ '*.js',
'**/*.js',
'!node_modules/**',
'!vendor/**',
'!resources/vendor/**'
]
- },
- jscs: {
- all: { src: '<%= jshint.all %>' }
},
banana: {
all: 'i18n/'
@@ -33,6 +27,6 @@
}
} );
- grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana', 'jscs' ]
);
+ grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};
diff --git a/package.json b/package.json
index 952c638..68e3058 100644
--- a/package.json
+++ b/package.json
@@ -4,10 +4,10 @@
"test": "grunt test"
},
"devDependencies": {
+ "eslint-config-wikimedia": "0.3.0",
"grunt": "1.0.1",
- "grunt-contrib-jshint": "1.0.0",
"grunt-banana-checker": "0.5.0",
- "grunt-jsonlint": "1.0.7",
- "grunt-jscs": "2.8.0"
+ "grunt-eslint": "19.0.0",
+ "grunt-jsonlint": "1.0.7"
}
}
diff --git
a/resources/infrastructure/ext.centralNotice.adminUi.campaignPager.js
b/resources/infrastructure/ext.centralNotice.adminUi.campaignPager.js
index 3e0afc9..92a5ad5 100644
--- a/resources/infrastructure/ext.centralNotice.adminUi.campaignPager.js
+++ b/resources/infrastructure/ext.centralNotice.adminUi.campaignPager.js
@@ -1,6 +1,7 @@
/**
* CentralNotice Administrative UI - Campaign pager
*/
+/* eslint-disable no-unused-vars */
( function ( mw, $ ) {
var changes = {};
diff --git a/resources/subscribing/ext.centralNotice.bannerHistoryLogger.js
b/resources/subscribing/ext.centralNotice.bannerHistoryLogger.js
index b8c39dd..5f3c9ae 100644
--- a/resources/subscribing/ext.centralNotice.bannerHistoryLogger.js
+++ b/resources/subscribing/ext.centralNotice.bannerHistoryLogger.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-unused-vars */
/*
* Banner history logger mixin. Records an event every time this campaign is
* selected for the user (even if the banner is hidden). The log is kept in
diff --git a/resources/subscribing/ext.centralNotice.display.chooser.js
b/resources/subscribing/ext.centralNotice.display.chooser.js
index 500e0cc..4c8c517 100644
--- a/resources/subscribing/ext.centralNotice.display.chooser.js
+++ b/resources/subscribing/ext.centralNotice.display.chooser.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-unused-vars */
/**
* Logic for selecting a campaign and a banner (or not). Provides
* cn.internal.chooser.
@@ -62,10 +63,11 @@
banner = campaign.banners[ j ];
// Logged-in status
- // jscs:disable
requireCamelCaseOrUpperCaseIdentifiers
+ // eslint-disable-next-line camelcase
if ( anon && !banner.display_anon ) {
continue;
}
+ // eslint-disable-next-line camelcase
if ( !anon && !banner.display_account ) {
continue;
}
diff --git a/resources/subscribing/ext.centralNotice.display.js
b/resources/subscribing/ext.centralNotice.display.js
index 088ef04..98ca610 100644
--- a/resources/subscribing/ext.centralNotice.display.js
+++ b/resources/subscribing/ext.centralNotice.display.js
@@ -405,7 +405,7 @@
);
}
- // jscs:disable
requireCamelCaseOrUpperCaseIdentifiers
+ // eslint-disable-next-line camelcase
if ( tmpData.banner_count ) {
state.setBannerCount(
tmpData.banner_count );
}
diff --git a/resources/subscribing/ext.centralNotice.display.state.js
b/resources/subscribing/ext.centralNotice.display.state.js
index 2d18e1f..9471406 100644
--- a/resources/subscribing/ext.centralNotice.display.state.js
+++ b/resources/subscribing/ext.centralNotice.display.state.js
@@ -355,7 +355,7 @@
* Sets banner_count, a legacy field for
Special:RecordImpression
*/
setBannerCount: function ( bannerCount ) {
- // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+ // eslint-disable-next-line camelcase
state.data.banner_count = bannerCount;
},
diff --git a/resources/subscribing/ext.centralNotice.freegeoipLookup.js
b/resources/subscribing/ext.centralNotice.freegeoipLookup.js
index 5c1553d..6a199b9 100644
--- a/resources/subscribing/ext.centralNotice.freegeoipLookup.js
+++ b/resources/subscribing/ext.centralNotice.freegeoipLookup.js
@@ -16,10 +16,10 @@
} ).then( function ( data ) {
var geo = {
- // jscs:disable
requireCamelCaseOrUpperCaseIdentifiers
+ // eslint-disable-next-line camelcase
country: data.country_code,
+ // eslint-disable-next-line camelcase
region: data.region_code,
- // jscs:enable
requireCamelCaseOrUpperCaseIdentifiers
city: data.city,
lat: data.latitude,
lon: data.longitude
diff --git a/resources/subscribing/ext.centralNotice.largeBannerLimit.js
b/resources/subscribing/ext.centralNotice.largeBannerLimit.js
index 4bbd3e6..75ee0cf 100644
--- a/resources/subscribing/ext.centralNotice.largeBannerLimit.js
+++ b/resources/subscribing/ext.centralNotice.largeBannerLimit.js
@@ -9,7 +9,7 @@
*
https://meta.wikimedia.org/wiki/MediaWiki:FR2014/Resources/ShowHideCheckFullscreen.js
*
https://meta.wikimedia.org/wiki/MediaWiki:FR2014/Resources/ChangeBucket-AtoC-BtoD.js
*/
-// jshint unused:false
+/* eslint-disable no-unused-vars */
( function ( mw ) {
'use strict';
diff --git a/tests/.eslintrc.json b/tests/.eslintrc.json
new file mode 100644
index 0000000..23aed6f
--- /dev/null
+++ b/tests/.eslintrc.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../.eslintrc.json",
+ "env": {
+ "qunit": true
+ }
+}
diff --git a/tests/qunit/subscribing/ext.centralNotice.display.chooser.tests.js
b/tests/qunit/subscribing/ext.centralNotice.display.chooser.tests.js
index bc8d3e2..777ae96 100644
--- a/tests/qunit/subscribing/ext.centralNotice.display.chooser.tests.js
+++ b/tests/qunit/subscribing/ext.centralNotice.display.chooser.tests.js
@@ -1,4 +1,4 @@
-// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+/* eslint-disable camelcase */
( function ( mw, $ ) {
'use strict';
diff --git a/tests/qunit/subscribing/ext.centralNotice.display.tests.js
b/tests/qunit/subscribing/ext.centralNotice.display.tests.js
index 08ba6b7..e748733 100644
--- a/tests/qunit/subscribing/ext.centralNotice.display.tests.js
+++ b/tests/qunit/subscribing/ext.centralNotice.display.tests.js
@@ -1,4 +1,4 @@
-// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+/* eslint-disable camelcase */
( function ( mw, $ ) {
'use strict';
--
To view, visit https://gerrit.wikimedia.org/r/344673
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c785a74d8b10304622c6242da2aacbf435aecdf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits