build: Replace jscs+jshint with eslint
Change-Id: I7f114267fbb4efd62a9162758445cff4fb3c0973
This commit is contained in:
16
.eslintrc.json
Normal file
16
.eslintrc.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "wikimedia",
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true,
|
||||||
|
"qunit": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"mediaWiki": false,
|
||||||
|
"OO": false
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"dot-notation": 0,
|
||||||
|
"wrap-iife": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"preserve_newlines": true,
|
|
||||||
"jslint_happy": true,
|
|
||||||
"keep_array_indentation": true,
|
|
||||||
"space_before_conditional": true,
|
|
||||||
"max_preserve_newlines": 10,
|
|
||||||
"brace_style": "collapse",
|
|
||||||
"keep_function_indentation": false,
|
|
||||||
"break_chained_methods": false,
|
|
||||||
"eval_code": false,
|
|
||||||
"unescape_strings": false,
|
|
||||||
"wrap_line_length": 0,
|
|
||||||
"space_in_paren": true,
|
|
||||||
"git_happy": true,
|
|
||||||
"indent_with_tabs": true,
|
|
||||||
"end_with_newline": true
|
|
||||||
}
|
|
||||||
21
.jscsrc
21
.jscsrc
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"preset": "wikimedia",
|
|
||||||
|
|
||||||
"jsDoc": {
|
|
||||||
"checkAnnotations": {
|
|
||||||
"preset": "jsduck5",
|
|
||||||
"extra": {
|
|
||||||
"this": true,
|
|
||||||
"source": true,
|
|
||||||
"see": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"checkTypes": "strictNativeCase",
|
|
||||||
"checkParamNames": true,
|
|
||||||
"checkRedundantAccess": true,
|
|
||||||
"checkRedundantReturns": true,
|
|
||||||
"requireNewlineAfterDescription": true,
|
|
||||||
"requireParamTypes": true,
|
|
||||||
"requireReturnTypes": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# upstream libs
|
|
||||||
lib/*
|
|
||||||
# Generated file that contains JSON. Would fail "Strings must use singlequote."
|
|
||||||
resources/js/ext.uls.webfonts.repository.js
|
|
||||||
vendor/*
|
|
||||||
26
.jshintrc
26
.jshintrc
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
// Enforcing
|
|
||||||
"bitwise": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"freeze": true,
|
|
||||||
"latedef": "nofunc",
|
|
||||||
"futurehostile": true,
|
|
||||||
"noarg": true,
|
|
||||||
"nonew": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
|
|
||||||
"strict": false,
|
|
||||||
|
|
||||||
// Relaxing
|
|
||||||
|
|
||||||
// Environment
|
|
||||||
"browser": true,
|
|
||||||
"jquery": true,
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"mediaWiki": false,
|
|
||||||
"OO": false,
|
|
||||||
"QUnit": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
19
Gruntfile.js
19
Gruntfile.js
@@ -1,19 +1,21 @@
|
|||||||
/*jshint node:true */
|
/* eslint-env node */
|
||||||
module.exports = function ( grunt ) {
|
module.exports = function ( grunt ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
grunt.loadNpmTasks( 'grunt-eslint' );
|
||||||
grunt.loadNpmTasks( 'grunt-jscs' );
|
|
||||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||||
grunt.loadNpmTasks( 'grunt-stylelint' );
|
grunt.loadNpmTasks( 'grunt-stylelint' );
|
||||||
|
|
||||||
grunt.initConfig( {
|
grunt.initConfig( {
|
||||||
jshint: {
|
eslint: {
|
||||||
|
fix: {
|
||||||
options: {
|
options: {
|
||||||
jshintrc: true
|
fix: true
|
||||||
},
|
},
|
||||||
all: [
|
src: '<%= eslint.main %>'
|
||||||
|
},
|
||||||
|
main: [
|
||||||
'**/*.js',
|
'**/*.js',
|
||||||
'!lib/**',
|
'!lib/**',
|
||||||
'!node_modules/**',
|
'!node_modules/**',
|
||||||
@@ -21,9 +23,6 @@ module.exports = function ( grunt ) {
|
|||||||
'!resources/js/ext.uls.webfonts.repository.js'
|
'!resources/js/ext.uls.webfonts.repository.js'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
jscs: {
|
|
||||||
src: '<%= jshint.all %>'
|
|
||||||
},
|
|
||||||
stylelint: {
|
stylelint: {
|
||||||
options: {
|
options: {
|
||||||
syntax: 'less'
|
syntax: 'less'
|
||||||
@@ -48,6 +47,6 @@ module.exports = function ( grunt ) {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
grunt.registerTask( 'test', [ 'jshint', 'jscs', 'stylelint', 'jsonlint', 'banana' ] );
|
grunt.registerTask( 'test', [ 'eslint:main', 'stylelint', 'jsonlint', 'banana' ] );
|
||||||
grunt.registerTask( 'default', 'test' );
|
grunt.registerTask( 'default', 'test' );
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
"test": "grunt test"
|
"test": "grunt test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"eslint-config-wikimedia": "0.2.0",
|
||||||
"grunt": "1.0.1",
|
"grunt": "1.0.1",
|
||||||
"grunt-banana-checker": "0.5.0",
|
"grunt-banana-checker": "0.5.0",
|
||||||
"grunt-contrib-jshint": "1.0.0",
|
"grunt-eslint": "19.0.0",
|
||||||
"grunt-jscs": "2.8.0",
|
"grunt-jsonlint": "1.1.0",
|
||||||
"grunt-jsonlint": "1.0.7",
|
|
||||||
"grunt-stylelint": "0.6.0",
|
"grunt-stylelint": "0.6.0",
|
||||||
"stylelint-config-wikimedia": "0.3.0"
|
"stylelint-config-wikimedia": "0.3.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,9 +132,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
mw.uls.getCountryCode = function () {
|
mw.uls.getCountryCode = function () {
|
||||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
||||||
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
||||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mw.uls.getAcceptLanguageList = function () {
|
mw.uls.getAcceptLanguageList = function () {
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
* @licence MIT License
|
* @licence MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable no-use-before-define */
|
||||||
|
|
||||||
( function ( $, mw ) {
|
( function ( $, mw ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -51,6 +53,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
|
* @constructor
|
||||||
|
* @param {string|jQuery} interlanguageList Selector for interlanguage list
|
||||||
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
function CompactInterlanguageList( interlanguageList, options ) {
|
function CompactInterlanguageList( interlanguageList, options ) {
|
||||||
this.$interlanguageList = $( interlanguageList );
|
this.$interlanguageList = $( interlanguageList );
|
||||||
@@ -289,7 +294,8 @@
|
|||||||
* Not all previous languages will be present in interlanguage links,
|
* Not all previous languages will be present in interlanguage links,
|
||||||
* so we are filtering them.
|
* so we are filtering them.
|
||||||
*
|
*
|
||||||
* @return {Array} List of language codes supported by the article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
function filterByPreviousLanguages( languages ) {
|
function filterByPreviousLanguages( languages ) {
|
||||||
var previousLanguages = mw.uls.getPreviousLanguages();
|
var previousLanguages = mw.uls.getPreviousLanguages();
|
||||||
@@ -302,7 +308,8 @@
|
|||||||
/**
|
/**
|
||||||
* Filter the language list by site picks.
|
* Filter the language list by site picks.
|
||||||
*
|
*
|
||||||
* @return {Array} List of language codes supported by the article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
function filterBySitePicks( languages ) {
|
function filterBySitePicks( languages ) {
|
||||||
var picks = mw.config.get( 'wgULSCompactLinksPrepend' ) || [];
|
var picks = mw.config.get( 'wgULSCompactLinksPrepend' ) || [];
|
||||||
@@ -316,7 +323,8 @@
|
|||||||
* Filter the language list by common languages.
|
* Filter the language list by common languages.
|
||||||
* Common languages are the most probable languages predicted by ULS.
|
* Common languages are the most probable languages predicted by ULS.
|
||||||
*
|
*
|
||||||
* @return {Array} List of language codes supported by the article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
function filterByCommonLanguages( languages ) {
|
function filterByCommonLanguages( languages ) {
|
||||||
var commonLanguages = mw.uls.getFrequentLanguageList();
|
var commonLanguages = mw.uls.getFrequentLanguageList();
|
||||||
@@ -330,12 +338,15 @@
|
|||||||
* Filter the language list by globally common languages, i.e.
|
* Filter the language list by globally common languages, i.e.
|
||||||
* this list is not user specific.
|
* this list is not user specific.
|
||||||
*
|
*
|
||||||
* @return {Array} List of language codes supported by the article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
function getExtraCommonLanguages( languages ) {
|
function getExtraCommonLanguages( languages ) {
|
||||||
var commonLanguages = [ 'zh', 'en', 'hi', 'ur', 'es', 'ar', 'ru', 'id', 'ms', 'pt',
|
var commonLanguages = [
|
||||||
|
'zh', 'en', 'hi', 'ur', 'es', 'ar', 'ru', 'id', 'ms', 'pt',
|
||||||
'fr', 'de', 'bn', 'ja', 'pnb', 'pa', 'jv', 'te', 'ta', 'ko', 'mr', 'tr', 'vi',
|
'fr', 'de', 'bn', 'ja', 'pnb', 'pa', 'jv', 'te', 'ta', 'ko', 'mr', 'tr', 'vi',
|
||||||
'it', 'fa', 'sv', 'nl', 'pl' ];
|
'it', 'fa', 'sv', 'nl', 'pl'
|
||||||
|
];
|
||||||
|
|
||||||
return $.grep( commonLanguages, function ( language ) {
|
return $.grep( commonLanguages, function ( language ) {
|
||||||
return $.inArray( language, languages ) >= 0;
|
return $.inArray( language, languages ) >= 0;
|
||||||
@@ -346,7 +357,8 @@
|
|||||||
* Filter the language list by Translate's assistant languages.
|
* Filter the language list by Translate's assistant languages.
|
||||||
* Where available, they're languages deemed useful by the user.
|
* Where available, they're languages deemed useful by the user.
|
||||||
*
|
*
|
||||||
* @return {Array} List of those language codes which are supported by article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
function filterByAssistantLanguages( languages ) {
|
function filterByAssistantLanguages( languages ) {
|
||||||
var assistantLanguages = mw.user.options.get( 'translate-editlangs' );
|
var assistantLanguages = mw.user.options.get( 'translate-editlangs' );
|
||||||
@@ -369,7 +381,8 @@
|
|||||||
* The reader doesn't necessarily know this language, but it
|
* The reader doesn't necessarily know this language, but it
|
||||||
* appears relevant to the page.
|
* appears relevant to the page.
|
||||||
*
|
*
|
||||||
* @return {Array} List of language codes supported by the article
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of language codes supported by the article
|
||||||
*/
|
*/
|
||||||
CompactInterlanguageList.prototype.filterByLangsInText = function ( languages ) {
|
CompactInterlanguageList.prototype.filterByLangsInText = function ( languages ) {
|
||||||
var languagesInText = [];
|
var languagesInText = [];
|
||||||
@@ -440,7 +453,8 @@
|
|||||||
/**
|
/**
|
||||||
* Get common languages - the most probable languages predicted by ULS.
|
* Get common languages - the most probable languages predicted by ULS.
|
||||||
*
|
*
|
||||||
* @param {Array} languages Array of all languages.
|
* @param {string[]} languages Language codes
|
||||||
|
* @return {string[]} List of all common language codes
|
||||||
*/
|
*/
|
||||||
CompactInterlanguageList.prototype.getCommonLanguages = function ( languages ) {
|
CompactInterlanguageList.prototype.getCommonLanguages = function ( languages ) {
|
||||||
if ( this.commonInterlanguageList === null ) {
|
if ( this.commonInterlanguageList === null ) {
|
||||||
|
|||||||
@@ -625,6 +625,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for save preferences
|
* Callback for save preferences
|
||||||
|
*
|
||||||
|
* @param {boolean} success
|
||||||
*/
|
*/
|
||||||
onSave: function ( success ) {
|
onSave: function ( success ) {
|
||||||
if ( success ) {
|
if ( success ) {
|
||||||
|
|||||||
@@ -498,6 +498,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for save preferences
|
* Callback for save preferences
|
||||||
|
*
|
||||||
|
* @param {boolean} success
|
||||||
*/
|
*/
|
||||||
onSave: function ( success ) {
|
onSave: function ( success ) {
|
||||||
if ( success ) {
|
if ( success ) {
|
||||||
|
|||||||
@@ -194,6 +194,9 @@
|
|||||||
/**
|
/**
|
||||||
* The tooltip to be shown when language changed using ULS.
|
* The tooltip to be shown when language changed using ULS.
|
||||||
* It also allows to undo the language selection.
|
* It also allows to undo the language selection.
|
||||||
|
*
|
||||||
|
* @param {string} previousLang
|
||||||
|
* @param {string} previousAutonym
|
||||||
*/
|
*/
|
||||||
function showUndoTooltip( previousLang, previousAutonym ) {
|
function showUndoTooltip( previousLang, previousAutonym ) {
|
||||||
var $ulsTrigger, ulsPopup,
|
var $ulsTrigger, ulsPopup,
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
/**
|
/**
|
||||||
* Wrapper for localStorage, falls back to cookie
|
* Wrapper for localStorage, falls back to cookie
|
||||||
* when localStorage not supported by browser.
|
* when localStorage not supported by browser.
|
||||||
|
*
|
||||||
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
function preferenceStore() {
|
function preferenceStore() {
|
||||||
|
|
||||||
@@ -110,6 +112,7 @@
|
|||||||
* Get a preference value for the given preference name
|
* Get a preference value for the given preference name
|
||||||
*
|
*
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
|
* @return {Mixed}
|
||||||
*/
|
*/
|
||||||
get: function ( key ) {
|
get: function ( key ) {
|
||||||
return this.preferences[ key ];
|
return this.preferences[ key ];
|
||||||
|
|||||||
@@ -139,7 +139,8 @@
|
|||||||
*
|
*
|
||||||
* @param {Object} repository
|
* @param {Object} repository
|
||||||
* @param {string} language
|
* @param {string} language
|
||||||
* @param {Array} classes
|
* @param {string[]} classes
|
||||||
|
* @return {string|null}
|
||||||
*/
|
*/
|
||||||
fontSelector: function ( repository, language, classes ) {
|
fontSelector: function ( repository, language, classes ) {
|
||||||
var font, autonym, defaultFont;
|
var font, autonym, defaultFont;
|
||||||
|
|||||||
Reference in New Issue
Block a user