Update eslint and other devDependencies (#391)
* Update eslint and other devDependencies * Lint JS in examples/ using eslint-plugin-html (#392)
This commit is contained in:
@@ -10,14 +10,13 @@ module.exports = function ( grunt ) {
|
||||
grunt.initConfig( {
|
||||
eslint: {
|
||||
options: {
|
||||
extensions: [ '.js', '.json' ],
|
||||
cache: true
|
||||
},
|
||||
all: [
|
||||
'**/*.{js,json}',
|
||||
'**/*.{js,json,html}',
|
||||
'!src/jquery.uls.data.js',
|
||||
'!scripts/jquery.uls.data.template.js',
|
||||
'!examples/**',
|
||||
'!examples/resources/*.min.js',
|
||||
'!node_modules/**',
|
||||
'!vendor/**'
|
||||
]
|
||||
|
||||
17
examples/.eslintrc.json
Normal file
17
examples/.eslintrc.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"wikimedia/client",
|
||||
"wikimedia/jquery"
|
||||
],
|
||||
"rules": {
|
||||
"no-jquery/no-global-selector": "off"
|
||||
},
|
||||
"plugins": [
|
||||
"html"
|
||||
],
|
||||
"settings": {
|
||||
"html/indent": "+tab",
|
||||
"html/report-bad-indent": "error"
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function () {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
languageDecorator: function ( $language, languageCode ) {
|
||||
if ( languageCode.indexOf( 'm' ) >= 0 ) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script src="resources/jquery.i18n.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function() {
|
||||
$( function () {
|
||||
var i18n = $.i18n();
|
||||
// Use default locale "en"
|
||||
i18n.locale = 'en';
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function () {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
onSelect: function ( language ) {
|
||||
var languageName = $.uls.data.getAutonym( language );
|
||||
@@ -37,8 +37,9 @@
|
||||
},
|
||||
quickList: [ 'en', 'hi', 'he', 'ml', 'ta', 'fr' ] // FIXME
|
||||
} );
|
||||
$( '.uls-trigger' ).click( function () {
|
||||
//Hacks I need to make afterwards. ULS API should be probably modified to allow optional classes and not force position:
|
||||
$( '.uls-trigger' ).on( 'click', function () {
|
||||
// Hacks I need to make afterwards. ULS API should be probably modified
|
||||
// to allow optional classes and not force position:
|
||||
$( '.uls-menu' )
|
||||
.addClass( 'uls-mobile' )
|
||||
.css( 'left', '2.5%' );
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function () {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
languages: {
|
||||
ca: 'català',
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function() {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
onSelect: function ( language ) {
|
||||
var languageName = $.uls.data.getAutonym( language );
|
||||
|
||||
@@ -21,21 +21,22 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function() {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
onSelect: function ( language ) {
|
||||
var languageName = $.uls.data.getAutonym( language );
|
||||
$( '.uls-trigger' ).text( languageName );
|
||||
},
|
||||
lazyload: false, // For small language list no lazy load required.
|
||||
languages: { // Languages are listed using its autonym. these language names
|
||||
lazyload: false, // For small language list no lazy loading required.
|
||||
languages: {
|
||||
// Languages are listed using their autonyms. These language names
|
||||
// in English (language names in current UI language) will also be used for search.
|
||||
'en': 'English',
|
||||
'hi': 'Hindi',
|
||||
'he': 'Hebrew',
|
||||
'ml': 'Malayalam',
|
||||
'ta': 'Tamil',
|
||||
'fr': 'French'
|
||||
en: 'English',
|
||||
hi: 'Hindi',
|
||||
he: 'Hebrew',
|
||||
ml: 'Malayalam',
|
||||
ta: 'Tamil',
|
||||
fr: 'French'
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function() {
|
||||
$( function () {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
onSelect: function ( language ) {
|
||||
var languageName = $.uls.data.getAutonym( language );
|
||||
$( '.uls-trigger' ).text( languageName );
|
||||
},
|
||||
noResultsTemplate: function ( query ) {
|
||||
return $( '<div>No article exists in the language ' + query + '</div>' )
|
||||
return $( '<div>No article exists in the language ' + query + '</div>' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
9115
package-lock.json
generated
9115
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -25,11 +25,13 @@
|
||||
"Siebrand Mazeland"
|
||||
],
|
||||
"devDependencies": {
|
||||
"eslint-config-wikimedia": "0.15.0",
|
||||
"grunt": "1.3",
|
||||
"grunt-contrib-qunit": "3.1.0",
|
||||
"grunt-eslint": "22.0.0",
|
||||
"grunt-stylelint": "0.13.0",
|
||||
"eslint-config-wikimedia": "0.20.0",
|
||||
"eslint-plugin-html": "6.1.2",
|
||||
"grunt": "1.4",
|
||||
"grunt-contrib-qunit": "4.0.0",
|
||||
"grunt-eslint": "23.0.0",
|
||||
"grunt-stylelint": "0.16.0",
|
||||
"stylelint": "13.13.1",
|
||||
"stylelint-config-wikimedia": "0.10.3"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
* @license GNU General Public Licence 2.0 or later
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
@@ -47,6 +46,7 @@
|
||||
|
||||
/**
|
||||
* ULS Public class definition
|
||||
*
|
||||
* @param {Element} element
|
||||
* @param {Object} options
|
||||
*/
|
||||
@@ -112,6 +112,7 @@
|
||||
/**
|
||||
* Calculate the position of ULS
|
||||
* Returns an object with top and left properties.
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
position: function () {
|
||||
@@ -292,6 +293,7 @@
|
||||
|
||||
/**
|
||||
* On select handler for search results
|
||||
*
|
||||
* @param {string} langCode
|
||||
* @param {Object} event The jQuery click event
|
||||
*/
|
||||
@@ -304,6 +306,7 @@
|
||||
|
||||
/**
|
||||
* On cancel handler for the uls menu
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
cancel: function ( e ) {
|
||||
@@ -337,6 +340,7 @@
|
||||
|
||||
/**
|
||||
* Get the panel menu width parameter
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getMenuWidth: function () {
|
||||
|
||||
@@ -12,9 +12,8 @@
|
||||
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
* @license GNU General Public Licence 2.0 or later
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
@@ -22,6 +21,7 @@
|
||||
|
||||
/**
|
||||
* Is this language a redirect to another language?
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string|boolean} Target language code if it's a redirect or false if it's not
|
||||
*/
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
/**
|
||||
* Returns the script of the language.
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string}
|
||||
*/
|
||||
@@ -53,6 +54,7 @@
|
||||
|
||||
/**
|
||||
* Returns the regions in which a language is spoken.
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string|string[]}
|
||||
*/
|
||||
@@ -68,6 +70,7 @@
|
||||
|
||||
/**
|
||||
* Returns the autonym of the language.
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string}
|
||||
*/
|
||||
@@ -84,6 +87,7 @@
|
||||
|
||||
/**
|
||||
* Returns all language codes and corresponding autonyms
|
||||
*
|
||||
* @return {string[]}
|
||||
*/
|
||||
$.uls.data.getAutonyms = function () {
|
||||
@@ -103,6 +107,7 @@
|
||||
|
||||
/**
|
||||
* Returns all languages written in script.
|
||||
*
|
||||
* @param {string} script string
|
||||
* @return {string[]} languages codes
|
||||
*/
|
||||
@@ -112,6 +117,7 @@
|
||||
|
||||
/**
|
||||
* Returns all languages written in the given scripts.
|
||||
*
|
||||
* @param {string[]} scripts
|
||||
* @return {string[]} languages codes
|
||||
*/
|
||||
@@ -138,6 +144,7 @@
|
||||
/**
|
||||
* Returns an associative array of languages in a region,
|
||||
* grouped by script group.
|
||||
*
|
||||
* @param {string} region Region code
|
||||
* @return {Object}
|
||||
*/
|
||||
@@ -147,6 +154,7 @@
|
||||
|
||||
/**
|
||||
* Get the given list of languages grouped by script.
|
||||
*
|
||||
* @param {string[]} languages Array of language codes to group
|
||||
* @return {string[]} Array of language codes
|
||||
*/
|
||||
@@ -169,6 +177,7 @@
|
||||
/**
|
||||
* Returns an associative array of languages in several regions,
|
||||
* grouped by script group.
|
||||
*
|
||||
* @param {string[]} regions region codes
|
||||
* @return {Object}
|
||||
*/
|
||||
@@ -201,6 +210,7 @@
|
||||
/**
|
||||
* Returns the script group of a script or 'Other' if it doesn't
|
||||
* belong to any group.
|
||||
*
|
||||
* @param {string} script Script code
|
||||
* @return {string} script group name
|
||||
*/
|
||||
@@ -218,6 +228,7 @@
|
||||
|
||||
/**
|
||||
* Returns the script group of a language.
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string} script group name
|
||||
*/
|
||||
@@ -227,6 +238,7 @@
|
||||
|
||||
/**
|
||||
* Return the list of languages sorted by script groups.
|
||||
*
|
||||
* @param {string[]} languages Array of language codes to sort
|
||||
* @return {string[]} Array of language codes
|
||||
*/
|
||||
@@ -247,6 +259,7 @@
|
||||
/**
|
||||
* A callback for sorting languages by autonym.
|
||||
* Can be used as an argument to a sort function.
|
||||
*
|
||||
* @param {string} a Language code
|
||||
* @param {string} b Language code
|
||||
* @return {number}
|
||||
@@ -260,6 +273,7 @@
|
||||
|
||||
/**
|
||||
* Check if a language is right-to-left.
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {boolean}
|
||||
*/
|
||||
@@ -269,6 +283,7 @@
|
||||
|
||||
/**
|
||||
* Return the direction of the language
|
||||
*
|
||||
* @param {string} language Language code
|
||||
* @return {string}
|
||||
*/
|
||||
@@ -278,6 +293,7 @@
|
||||
|
||||
/**
|
||||
* Returns the languages spoken in a territory.
|
||||
*
|
||||
* @param {string} territory Territory code
|
||||
* @return {string[]} list of language codes
|
||||
*/
|
||||
|
||||
@@ -12,9 +12,8 @@
|
||||
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
* @license GNU General Public Licence 2.0 or later
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -224,6 +223,7 @@
|
||||
/**
|
||||
* Handler method to be called once search is over.
|
||||
* Based on search result triggers resultsfound or noresults events
|
||||
*
|
||||
* @param {string} query
|
||||
* @param {string[]} results
|
||||
* @param {string} [autofillLabel]
|
||||
@@ -306,6 +306,7 @@
|
||||
* b) Language autonym 'starts with' search string.
|
||||
* c) ISO 639 code match with search string.
|
||||
* d) ISO 15924 code for the script match the search string.
|
||||
*
|
||||
* @param {string} langCode
|
||||
* @param {string} searchTerm
|
||||
* @return {boolean}
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
* @license GNU General Public Licence 2.0 or later
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
@@ -32,6 +31,7 @@
|
||||
|
||||
/**
|
||||
* Language category display
|
||||
*
|
||||
* @param {Element} element The container element to which the languages to be displayed
|
||||
* @param {Object} [options] Configuration object
|
||||
* @cfg {Object} [languages] Selectable languages. Keyed by language code, values are autonyms.
|
||||
@@ -69,6 +69,7 @@
|
||||
|
||||
/**
|
||||
* Adds language to the language list.
|
||||
*
|
||||
* @param {string} langCode
|
||||
* @param {string} [regionCode]
|
||||
* @return {boolean} Whether the language was known and accepted
|
||||
@@ -112,6 +113,7 @@
|
||||
|
||||
/**
|
||||
* Whether we should render languages grouped to geographic regions.
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
isGroupingByRegionEnabled: function () {
|
||||
@@ -219,6 +221,7 @@
|
||||
|
||||
/**
|
||||
* Adds given languages sorted into rows and columns into given element.
|
||||
*
|
||||
* @param {jQuery} $region Element to add language list.
|
||||
* @param {Array} languages List of language codes.
|
||||
* @param {number} itemsPerColumn How many languages fit in a column.
|
||||
@@ -286,6 +289,7 @@
|
||||
|
||||
/**
|
||||
* Creates dom node representing one item in language list.
|
||||
*
|
||||
* @param {string} code Language code
|
||||
* @return {Element}
|
||||
*/
|
||||
@@ -387,6 +391,7 @@
|
||||
|
||||
/**
|
||||
* No-results event handler
|
||||
*
|
||||
* @param {Event} event
|
||||
* @param {Object} data Information about the failed search query
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user