Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@intlify/eslint-plugin-vue-i18n

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intlify/eslint-plugin-vue-i18n - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

dist/rules/prefer-sfc-lang-attr.js

11

CHANGELOG.md
## v1.2.0 (2021-11-18)
#### :star: Features
* [#267](https://github.com/intlify/eslint-plugin-vue-i18n/pull/267) Add `prefer-sfc-lang-attr` rule ([@ota-meshi](https://github.com/ota-meshi))
* [#270](https://github.com/intlify/eslint-plugin-vue-i18n/pull/270) feat: support `localePattern` option for locale structured with directory ([@kazupon](https://github.com/kazupon))
#### Committers: 2
- Yosuke Ota ([@ota-meshi](https://github.com/ota-meshi))
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
## v1.1.0 (2021-11-16)

@@ -3,0 +14,0 @@

2

dist/rules.js

@@ -19,2 +19,3 @@ "use strict";

const prefer_linked_key_with_paren_1 = __importDefault(require("./rules/prefer-linked-key-with-paren"));
const prefer_sfc_lang_attr_1 = __importDefault(require("./rules/prefer-sfc-lang-attr"));
const valid_message_syntax_1 = __importDefault(require("./rules/valid-message-syntax"));

@@ -36,3 +37,4 @@ module.exports = {

'prefer-linked-key-with-paren': prefer_linked_key_with_paren_1.default,
'prefer-sfc-lang-attr': prefer_sfc_lang_attr_1.default,
'valid-message-syntax': valid_message_syntax_1.default
};

4

dist/rules/key-format-style.js

@@ -48,3 +48,3 @@ "use strict";

let keyStack = {
inLocale: targetLocaleMessage.localeKey === 'file'
inLocale: targetLocaleMessage.isResolvedLocaleByFileName()
};

@@ -77,3 +77,3 @@ return {

let keyStack = {
inLocale: targetLocaleMessage.localeKey === 'file'
inLocale: targetLocaleMessage.isResolvedLocaleByFileName()
};

@@ -80,0 +80,0 @@ function withinKey(node) {

@@ -23,3 +23,3 @@ "use strict";

function createInitPathStack(targetLocaleMessage, otherLocaleMessages) {
if (targetLocaleMessage.localeKey === 'file') {
if (targetLocaleMessage.isResolvedLocaleByFileName()) {
const locale = targetLocaleMessage.locales[0];

@@ -26,0 +26,0 @@ return createInitLocalePathStack(locale, otherLocaleMessages);

@@ -71,3 +71,3 @@ "use strict";

let keyStack;
if (targetLocaleMessage.localeKey === 'file') {
if (targetLocaleMessage.isResolvedLocaleByFileName()) {
const locale = targetLocaleMessage.locales[0];

@@ -74,0 +74,0 @@ keyStack = {

@@ -27,2 +27,3 @@ "use strict";

const defaultTimeouts = __importStar(require("./utils/default-timeouts"));
const getCwd = __importStar(require("./utils/get-cwd"));
const globSync = __importStar(require("./utils/glob-sync"));

@@ -44,2 +45,3 @@ const globUtils = __importStar(require("./utils/glob-utils"));

'default-timeouts': defaultTimeouts,
'get-cwd': getCwd,
'glob-sync': globSync,

@@ -46,0 +48,0 @@ 'glob-utils': globUtils,

@@ -73,3 +73,3 @@ "use strict";

const checkDupeMap = {};
for (const { files, localeKey } of localeFilesList) {
for (const { files, localeKey, localePattern } of localeFilesList) {
for (const file of files) {

@@ -82,3 +82,3 @@ const localeKeys = checkDupeMap[file] || (checkDupeMap[file] = []);

const fullpath = path_1.resolve(cwd, file);
results.push(new locale_messages_1.FileLocaleMessage({ fullpath, localeKey }));
results.push(new locale_messages_1.FileLocaleMessage({ fullpath, localeKey, localePattern }));
}

@@ -146,3 +146,4 @@ }

files: targetFilesLoader.get(localeDir.pattern, cwd),
localeKey: String((_a = localeDir.localeKey) !== null && _a !== void 0 ? _a : 'file')
localeKey: String((_a = localeDir.localeKey) !== null && _a !== void 0 ? _a : 'file'),
localePattern: localeDir.localePattern
};

@@ -149,0 +150,0 @@ }

@@ -14,9 +14,22 @@ "use strict";

const key_path_1 = require("./key-path");
const DEFAULT_LOCALE_PATTERN = '[A-Za-z0-9-_]+';
const DEFAULT_LOCALE_FIELNAME_REGEX = new RegExp(`(${DEFAULT_LOCALE_PATTERN})\.`, 'i');
const DEFAULT_LOCALE_CAPTURE_REGEX = new RegExp(`^.*\/(?<locale>${DEFAULT_LOCALE_PATTERN})\.(json5?|ya?ml)$`, 'i');
class LocaleMessage {
constructor({ fullpath, locales, localeKey }) {
constructor({ fullpath, locales, localeKey, localePattern }) {
this.fullpath = fullpath;
this.localeKey = localeKey;
this.file = fullpath.replace(/^.*(\\|\/|:)/, '');
this.localePattern = this.getLocalePatternWithRegex(localePattern);
this._locales = locales;
}
getLocalePatternWithRegex(localePattern) {
return localePattern != null
? typeof localePattern === 'string'
? new RegExp(localePattern, 'i')
: Object.prototype.toString.call(localePattern) === '[object RegExp]'
? localePattern
: DEFAULT_LOCALE_CAPTURE_REGEX
: DEFAULT_LOCALE_CAPTURE_REGEX;
}
get messages() {

@@ -26,2 +39,3 @@ return this.getMessagesInternal();

get locales() {
var _a;
if (this._locales) {

@@ -31,5 +45,11 @@ return this._locales;

if (this.localeKey === 'file') {
const matched = this.file.match(/([A-Za-z0-9-_]+)\./i);
const matched = this.file.match(DEFAULT_LOCALE_FIELNAME_REGEX);
return (this._locales = [(matched && matched[1]) || this.file]);
}
else if (this.localeKey === 'path') {
const matched = this.fullpath.match(this.localePattern);
return (this._locales = [
(matched && ((_a = matched.groups) === null || _a === void 0 ? void 0 : _a.locale)) || this.fullpath
]);
}
else if (this.localeKey === 'key') {

@@ -40,4 +60,7 @@ return (this._locales = Object.keys(this.messages));

}
isResolvedLocaleByFileName() {
return this.localeKey === 'file' || this.localeKey === 'path';
}
getMessagesFromLocale(locale) {
if (this.localeKey === 'file') {
if (this.isResolvedLocaleByFileName()) {
if (!this.locales.includes(locale)) {

@@ -85,7 +108,8 @@ return {};

class FileLocaleMessage extends LocaleMessage {
constructor({ fullpath, locales, localeKey }) {
constructor({ fullpath, locales, localeKey, localePattern }) {
super({
fullpath,
locales,
localeKey
localeKey,
localePattern
});

@@ -92,0 +116,0 @@ this._resource = new resource_loader_1.ResourceLoader(fullpath, fileName => {

{
"name": "@intlify/eslint-plugin-vue-i18n",
"description": "ESLint plugin for Vue I18n",
"version": "1.1.0",
"version": "1.2.0",
"author": {

@@ -44,3 +44,3 @@ "name": "kazuya kawaguchi",

"@types/debug": "^4.1.5",
"@types/eslint": "^7.2.0",
"@types/eslint": "^8.0.0",
"@types/eslint-scope": "^3.7.0",

@@ -47,0 +47,0 @@ "@types/eslint-visitor-keys": "^1.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc