Skip to content

Commit

Permalink
prevent-abbreviations: Ignore i18n and l10n (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Jul 31, 2021
1 parent 4a14187 commit efdd90e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rules/prevent-abbreviations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const isShorthandPropertyValue = require('./utils/is-shorthand-property-value.js
const isShorthandImportLocal = require('./utils/is-shorthand-import-local.js');
const getVariableIdentifiers = require('./utils/get-variable-identifiers.js');
const isStaticRequire = require('./utils/is-static-require.js');
const {defaultReplacements, defaultAllowList} = require('./shared/abbreviations.js');
const {defaultReplacements, defaultAllowList, defaultIgnore} = require('./shared/abbreviations.js');
const {renameVariable} = require('./fix/index.js');
const getScopes = require('./utils/get-scopes.js');

Expand Down Expand Up @@ -41,6 +41,8 @@ const prepareOptions = ({
defaultsDeep({}, allowList, defaultAllowList) :
allowList;

ignore = [...defaultIgnore, ...ignore];

ignore = ignore.map(
pattern => pattern instanceof RegExp ? pattern : new RegExp(pattern, 'u'),
);
Expand Down
7 changes: 7 additions & 0 deletions rules/shared/abbreviations.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,10 @@ module.exports.defaultAllowList = {
// https://jestjs.io/docs/en/configuration#setupfilesafterenv-array
setupFilesAfterEnv: true,
};

module.exports.defaultIgnore = [
// Internationalization and localization
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1188
'i18n',
'l10n',
];
3 changes: 3 additions & 0 deletions test/prevent-abbreviations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ const tests = {
'(class {})',
'(class C {})',
'class C {}',
'const i18n = new I18n({ locales: ["en", "fr"] })',
'const i18nData = {}',
'const l10n = new L10n()',
outdent`
(class {
error() {}
Expand Down

0 comments on commit efdd90e

Please sign in to comment.