forked from mirrors/gecko-dev
Bug 1613139 - Enable ESLint for intl/locale and intl/strres (manual changes). r=zbraniecki
Depends on D61580 Differential Revision: https://phabricator.services.mozilla.com/D61581 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c4d713de2b
commit
0007396a1a
6 changed files with 19 additions and 25 deletions
|
|
@ -131,8 +131,6 @@ dom/workers/test/invalid.js
|
|||
dom/workers/test/threadErrors_worker1.js
|
||||
|
||||
# intl/ exclusions
|
||||
intl/locale/
|
||||
intl/strres/
|
||||
intl/uconv/
|
||||
# Bug 1527075: This directory is linted in github repository
|
||||
intl/l10n/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["PluralForm"];
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/**
|
||||
* This module provides the PluralForm object which contains a method to figure
|
||||
* out which plural form of a word to use for a given number based on the
|
||||
|
|
@ -36,6 +38,7 @@ const kIntlProperties = "chrome://global/locale/intl.properties";
|
|||
// These are the available plural functions that give the appropriate index
|
||||
// based on the plural rule number specified. The first element is the number
|
||||
// of plural forms and the second is the function to figure out the index.
|
||||
/* eslint-disable no-nested-ternary */
|
||||
var gFunctions = [
|
||||
// 0: Chinese
|
||||
[1, n => 0],
|
||||
|
|
@ -184,6 +187,7 @@ var gFunctions = [
|
|||
: 2,
|
||||
],
|
||||
];
|
||||
/* eslint-enable no-nested-ternary */
|
||||
|
||||
var PluralForm = {
|
||||
/**
|
||||
|
|
@ -290,8 +294,7 @@ var PluralForm = {
|
|||
*/
|
||||
get ruleNum() {
|
||||
return Number(
|
||||
Cc["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Ci.nsIStringBundleService)
|
||||
Services.strings
|
||||
.createBundle(kIntlProperties)
|
||||
.GetStringFromName("pluralRule")
|
||||
);
|
||||
|
|
@ -306,8 +309,6 @@ var PluralForm = {
|
|||
*/
|
||||
function log(aMsg) {
|
||||
let msg = "PluralForm.jsm: " + (aMsg.join ? aMsg.join("") : aMsg);
|
||||
Cc["@mozilla.org/consoleservice;1"]
|
||||
.getService(Ci.nsIConsoleService)
|
||||
.logStringMessage(msg);
|
||||
Services.console.logStringMessage(msg);
|
||||
dump(msg + "\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ const osPrefs = Cc["@mozilla.org/intl/ospreferences;1"].getService(
|
|||
Ci.mozIOSPreferences
|
||||
);
|
||||
|
||||
const localeService = Cc["@mozilla.org/intl/localeservice;1"].getService(
|
||||
Ci.mozILocaleService
|
||||
);
|
||||
const localeService = Services.locale;
|
||||
|
||||
/**
|
||||
* Make sure the locale service can be instantiated.
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const localeService = Cc["@mozilla.org/intl/localeservice;1"].getService(
|
||||
Ci.mozILocaleService
|
||||
);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const localeService = Services.locale;
|
||||
|
||||
const data = {
|
||||
filtering: {
|
||||
|
|
@ -148,10 +147,10 @@ function run_test() {
|
|||
const requested = test[0];
|
||||
const available = test[1];
|
||||
const defaultLocale = test.length > 3 ? test[2] : undefined;
|
||||
const strategy = test.length > 4 ? test[3] : undefined;
|
||||
const strategyInner = test.length > 4 ? test[3] : undefined;
|
||||
const supported = test[test.length - 1];
|
||||
|
||||
const result = nl(test[0], test[1], defaultLocale, strategy);
|
||||
const result = nl(test[0], test[1], defaultLocale, strategyInner);
|
||||
deepEqual(
|
||||
result,
|
||||
supported,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* Tests getting properties from string bundles
|
||||
*/
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const name_file = "file";
|
||||
const value_file = "File";
|
||||
|
||||
|
|
@ -27,11 +29,8 @@ const var_hello = "World";
|
|||
const value_hello = "Hello World"; // tests formatStringFromName with parameter
|
||||
|
||||
function run_test() {
|
||||
var StringBundle = Cc["@mozilla.org/intl/stringbundle;1"].getService(
|
||||
Ci.nsIStringBundleService
|
||||
);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var bundleURI = ios.newFileURI(do_get_file("strres.properties"));
|
||||
var StringBundle = Services.strings;
|
||||
var bundleURI = Services.io.newFileURI(do_get_file("strres.properties"));
|
||||
|
||||
var bundle = StringBundle.createBundle(bundleURI.spec);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* all GetStringFromName calls should fail.
|
||||
*/
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const name_ascii = "asciiProperty";
|
||||
const value_ascii = "";
|
||||
|
||||
|
|
@ -14,11 +16,8 @@ const name_latin1 = "latin1";
|
|||
const value_latin1 = "";
|
||||
|
||||
function run_test() {
|
||||
var StringBundle = Cc["@mozilla.org/intl/stringbundle;1"].getService(
|
||||
Ci.nsIStringBundleService
|
||||
);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var bundleURI = ios.newFileURI(do_get_file("397093.properties"));
|
||||
var StringBundle = Services.strings;
|
||||
var bundleURI = Services.io.newFileURI(do_get_file("397093.properties"));
|
||||
|
||||
var bundle = StringBundle.createBundle(bundleURI.spec);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue