Merge "build: Replace jscs+jshint with eslint"
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 ) {
|
||||
'use strict';
|
||||
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||
grunt.loadNpmTasks( 'grunt-jscs' );
|
||||
grunt.loadNpmTasks( 'grunt-eslint' );
|
||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||
grunt.loadNpmTasks( 'grunt-stylelint' );
|
||||
|
||||
grunt.initConfig( {
|
||||
jshint: {
|
||||
eslint: {
|
||||
fix: {
|
||||
options: {
|
||||
jshintrc: true
|
||||
fix: true
|
||||
},
|
||||
all: [
|
||||
src: '<%= eslint.main %>'
|
||||
},
|
||||
main: [
|
||||
'**/*.js',
|
||||
'!lib/**',
|
||||
'!node_modules/**',
|
||||
@@ -21,9 +23,6 @@ module.exports = function ( grunt ) {
|
||||
'!resources/js/ext.uls.webfonts.repository.js'
|
||||
]
|
||||
},
|
||||
jscs: {
|
||||
src: '<%= jshint.all %>'
|
||||
},
|
||||
stylelint: {
|
||||
options: {
|
||||
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' );
|
||||
};
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-wikimedia": "0.2.0",
|
||||
"grunt": "1.0.1",
|
||||
"grunt-banana-checker": "0.5.0",
|
||||
"grunt-contrib-jshint": "1.0.0",
|
||||
"grunt-jscs": "2.8.0",
|
||||
"grunt-jsonlint": "1.0.7",
|
||||
"grunt-eslint": "19.0.0",
|
||||
"grunt-jsonlint": "1.1.0",
|
||||
"grunt-stylelint": "0.6.0",
|
||||
"stylelint-config-wikimedia": "0.3.0"
|
||||
}
|
||||
|
||||
@@ -132,9 +132,7 @@
|
||||
};
|
||||
|
||||
mw.uls.getCountryCode = function () {
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
};
|
||||
|
||||
mw.uls.getAcceptLanguageList = function () {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -51,6 +53,9 @@
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @constructor
|
||||
* @param {string|jQuery} interlanguageList Selector for interlanguage list
|
||||
* @param {Object} options
|
||||
*/
|
||||
function CompactInterlanguageList( interlanguageList, options ) {
|
||||
this.$interlanguageList = $( interlanguageList );
|
||||
@@ -289,7 +294,8 @@
|
||||
* Not all previous languages will be present in interlanguage links,
|
||||
* 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 ) {
|
||||
var previousLanguages = mw.uls.getPreviousLanguages();
|
||||
@@ -302,7 +308,8 @@
|
||||
/**
|
||||
* 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 ) {
|
||||
var picks = mw.config.get( 'wgULSCompactLinksPrepend' ) || [];
|
||||
@@ -316,7 +323,8 @@
|
||||
* Filter the language list by common languages.
|
||||
* 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 ) {
|
||||
var commonLanguages = mw.uls.getFrequentLanguageList();
|
||||
@@ -330,12 +338,15 @@
|
||||
* Filter the language list by globally common languages, i.e.
|
||||
* 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 ) {
|
||||
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',
|
||||
'it', 'fa', 'sv', 'nl', 'pl' ];
|
||||
'it', 'fa', 'sv', 'nl', 'pl'
|
||||
];
|
||||
|
||||
return $.grep( commonLanguages, function ( language ) {
|
||||
return $.inArray( language, languages ) >= 0;
|
||||
@@ -346,7 +357,8 @@
|
||||
* Filter the language list by Translate's assistant languages.
|
||||
* 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 ) {
|
||||
var assistantLanguages = mw.user.options.get( 'translate-editlangs' );
|
||||
@@ -369,7 +381,8 @@
|
||||
* The reader doesn't necessarily know this language, but it
|
||||
* 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 ) {
|
||||
var languagesInText = [];
|
||||
@@ -440,7 +453,8 @@
|
||||
/**
|
||||
* 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 ) {
|
||||
if ( this.commonInterlanguageList === null ) {
|
||||
|
||||
@@ -625,6 +625,8 @@
|
||||
|
||||
/**
|
||||
* Callback for save preferences
|
||||
*
|
||||
* @param {boolean} success
|
||||
*/
|
||||
onSave: function ( success ) {
|
||||
if ( success ) {
|
||||
|
||||
@@ -502,6 +502,8 @@
|
||||
|
||||
/**
|
||||
* Callback for save preferences
|
||||
*
|
||||
* @param {boolean} success
|
||||
*/
|
||||
onSave: function ( success ) {
|
||||
if ( success ) {
|
||||
|
||||
@@ -194,6 +194,9 @@
|
||||
/**
|
||||
* The tooltip to be shown when language changed using ULS.
|
||||
* It also allows to undo the language selection.
|
||||
*
|
||||
* @param {string} previousLang
|
||||
* @param {string} previousAutonym
|
||||
*/
|
||||
function showUndoTooltip( previousLang, previousAutonym ) {
|
||||
var $ulsTrigger, ulsPopup,
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
/**
|
||||
* Wrapper for localStorage, falls back to cookie
|
||||
* when localStorage not supported by browser.
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function preferenceStore() {
|
||||
|
||||
@@ -110,6 +112,7 @@
|
||||
* Get a preference value for the given preference name
|
||||
*
|
||||
* @param {string} key
|
||||
* @return {Mixed}
|
||||
*/
|
||||
get: function ( key ) {
|
||||
return this.preferences[ key ];
|
||||
|
||||
@@ -139,7 +139,8 @@
|
||||
*
|
||||
* @param {Object} repository
|
||||
* @param {string} language
|
||||
* @param {Array} classes
|
||||
* @param {string[]} classes
|
||||
* @return {string|null}
|
||||
*/
|
||||
fontSelector: function ( repository, language, classes ) {
|
||||
var font, autonym, defaultFont;
|
||||
|
||||
Reference in New Issue
Block a user