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:
Ed S
2021-05-14 10:48:37 +01:00
committed by GitHub
parent ab929b81d8
commit 7a6e559fe5
17 changed files with 10287 additions and 12114 deletions

View File

@@ -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
View 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"
}
}

View File

@@ -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 ) {
@@ -26,7 +26,7 @@
}
$language.prop( 'href', '//' + languageCode + '.wikipedia.org' );
},
quickList: ['en', 'hi', 'he', 'ml', 'ta', 'fr'] //FIXME
quickList: [ 'en', 'hi', 'he', 'ml', 'ta', 'fr' ] // FIXME
} );
} );
</script>

View File

@@ -19,16 +19,16 @@
<script src="../src/jquery.uls.core.js"></script>
<script src="resources/jquery.i18n.min.js"></script>
<script>
$( document ).ready( function() {
var i18n = $.i18n( );
$( function () {
var i18n = $.i18n();
// Use default locale "en"
i18n.locale = 'en';
i18n.load( '../i18n/en.json', 'en' );
$( '.uls-trigger' ).uls( {
onReady: function ( ) {
onReady: function () {
this.i18n();
},
onSelect: function( language ) {
onSelect: function ( language ) {
var languageName = $.uls.data.getAutonym( language );
$( '.uls-trigger' ).text( languageName );
i18n.locale = language;
@@ -40,7 +40,7 @@
this.i18n();
$( '.navbar' ).i18n();
},
quickList: ['en', 'hi', 'he', 'ml', 'ta', 'fr']
quickList: [ 'en', 'hi', 'he', 'ml', 'ta', 'fr' ]
} );
} );
</script>

View File

@@ -29,20 +29,21 @@
<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 ) {
onSelect: function ( language ) {
var languageName = $.uls.data.getAutonym( language );
$( '.uls-trigger' ).text( languageName );
},
quickList: ['en', 'hi', 'he', 'ml', 'ta', 'fr'] //FIXME
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%' );
});
} );
} );
</script>
</head>

View File

@@ -18,23 +18,23 @@
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script>
$( document ).ready( function () {
$( '.uls-trigger' ).uls( {
languages: {
ca: 'català',
es: 'español',
he: 'עברית',
ml: 'മലയാളം',
ru: 'русский'
},
onSelect: function ( language ) {
var languageName = $.uls.data.getAutonym( language );
$( '.uls-trigger' ).text( languageName );
},
menuWidth: 'narrow',
compact: true
$( function () {
$( '.uls-trigger' ).uls( {
languages: {
ca: 'català',
es: 'español',
he: 'עברית',
ml: 'മലയാളം',
ru: 'русский'
},
onSelect: function ( language ) {
var languageName = $.uls.data.getAutonym( language );
$( '.uls-trigger' ).text( languageName );
},
menuWidth: 'narrow',
compact: true
} );
} );
} );
</script>
</head>

View File

@@ -28,13 +28,13 @@
<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 ) {
onSelect: function ( language ) {
var languageName = $.uls.data.getAutonym( language );
$( '.uls-trigger' ).text( languageName );
},
quickList: ['en', 'hi', 'he', 'ml', 'ta', 'fr'] //FIXME
quickList: [ 'en', 'hi', 'he', 'ml', 'ta', 'fr' ] // FIXME
} );
} );
</script>

View File

@@ -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 ) {
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
// 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'
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'
}
} );
} );

View File

@@ -1,3 +1,3 @@
{
"uls-example-title": "Universal Language Selector"
"uls-example-title": "Universal Language Selector"
}

View File

@@ -1,3 +1,3 @@
{
"uls-example-title": "ആഗോള ഭാഷാ സഹായി"
"uls-example-title": "ആഗോള ഭാഷാ സഹായി"
}

View File

@@ -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 ) {
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>' )
noResultsTemplate: function ( query ) {
return $( '<div>No article exists in the language ' + query + '</div>' );
}
} );
} );

22129
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,51 +1,53 @@
{
"name": "jquery.uls",
"version": "0.1.0",
"description": "Universal Language Selector",
"homepage": "https://github.com/wikimedia/jquery.uls",
"keywords": [
"internationalization",
"localization",
"uls",
"jquery",
"l10n"
],
"author": {
"name": "Santhosh Thottingal",
"email": "santhosh.thottingal@gmail.com"
},
"contributors": [
"Alolita Sharma",
"Amir Aharoni",
"Arun Ganesh",
"Brandon Harris",
"Niklas Laxström",
"Pau Giner",
"Santhosh Thottingal",
"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",
"stylelint-config-wikimedia": "0.10.3"
},
"repository": {
"type": "git",
"url": "git://github.com/wikimedia/jquery.uls.git"
},
"bugs": {
"url": "https://github.com/wikimedia/jquery.uls/issues"
},
"engine": {
"node": ">=6.11.1"
},
"license": "(MIT OR GPL-2.0+)",
"scripts": {
"test": "grunt test --verbose",
"lint": "grunt lint --verbose",
"qunit": "grunt qunit --verbose"
}
"name": "jquery.uls",
"version": "0.1.0",
"description": "Universal Language Selector",
"homepage": "https://github.com/wikimedia/jquery.uls",
"keywords": [
"internationalization",
"localization",
"uls",
"jquery",
"l10n"
],
"author": {
"name": "Santhosh Thottingal",
"email": "santhosh.thottingal@gmail.com"
},
"contributors": [
"Alolita Sharma",
"Amir Aharoni",
"Arun Ganesh",
"Brandon Harris",
"Niklas Laxström",
"Pau Giner",
"Santhosh Thottingal",
"Siebrand Mazeland"
],
"devDependencies": {
"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": {
"type": "git",
"url": "git://github.com/wikimedia/jquery.uls.git"
},
"bugs": {
"url": "https://github.com/wikimedia/jquery.uls/issues"
},
"engine": {
"node": ">=6.11.1"
},
"license": "(MIT OR GPL-2.0+)",
"scripts": {
"test": "grunt test --verbose",
"lint": "grunt lint --verbose",
"qunit": "grunt qunit --verbose"
}
}

View File

@@ -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 () {

View File

@@ -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
*/

View File

@@ -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}

View File

@@ -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
*/