Skip to content

Commit efdd90e

Browse files
authored
prevent-abbreviations: Ignore i18n and l10n (#1445)
1 parent 4a14187 commit efdd90e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

rules/prevent-abbreviations.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const isShorthandPropertyValue = require('./utils/is-shorthand-property-value.js
88
const isShorthandImportLocal = require('./utils/is-shorthand-import-local.js');
99
const getVariableIdentifiers = require('./utils/get-variable-identifiers.js');
1010
const isStaticRequire = require('./utils/is-static-require.js');
11-
const {defaultReplacements, defaultAllowList} = require('./shared/abbreviations.js');
11+
const {defaultReplacements, defaultAllowList, defaultIgnore} = require('./shared/abbreviations.js');
1212
const {renameVariable} = require('./fix/index.js');
1313
const getScopes = require('./utils/get-scopes.js');
1414

@@ -41,6 +41,8 @@ const prepareOptions = ({
4141
defaultsDeep({}, allowList, defaultAllowList) :
4242
allowList;
4343

44+
ignore = [...defaultIgnore, ...ignore];
45+
4446
ignore = ignore.map(
4547
pattern => pattern instanceof RegExp ? pattern : new RegExp(pattern, 'u'),
4648
);

rules/shared/abbreviations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,10 @@ module.exports.defaultAllowList = {
239239
// https://jestjs.io/docs/en/configuration#setupfilesafterenv-array
240240
setupFilesAfterEnv: true,
241241
};
242+
243+
module.exports.defaultIgnore = [
244+
// Internationalization and localization
245+
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1188
246+
'i18n',
247+
'l10n',
248+
];

test/prevent-abbreviations.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ const tests = {
125125
'(class {})',
126126
'(class C {})',
127127
'class C {}',
128+
'const i18n = new I18n({ locales: ["en", "fr"] })',
129+
'const i18nData = {}',
130+
'const l10n = new L10n()',
128131
outdent`
129132
(class {
130133
error() {}

0 commit comments

Comments
 (0)