eslint-plugin-formatjs 6.0.8 → 6.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context-compat.d.ts +2 -2
- package/context-compat.js +5 -4
- package/index.d.ts +12 -11
- package/index.js +94 -136
- package/messages.d.ts +1 -1
- package/messages.js +1 -3
- package/package.json +5 -5
- package/rules/blocklist-elements.d.ts +12 -12
- package/rules/blocklist-elements.js +129 -140
- package/rules/enforce-default-message.d.ts +4 -4
- package/rules/enforce-default-message.js +56 -62
- package/rules/enforce-description.d.ts +4 -4
- package/rules/enforce-description.js +56 -62
- package/rules/enforce-id.d.ts +5 -5
- package/rules/enforce-id.js +137 -158
- package/rules/enforce-placeholders.d.ts +4 -4
- package/rules/enforce-placeholders.js +127 -142
- package/rules/enforce-plural-rules.d.ts +10 -12
- package/rules/enforce-plural-rules.js +107 -113
- package/rules/no-camel-case.d.ts +3 -3
- package/rules/no-camel-case.js +83 -85
- package/rules/no-complex-selectors.d.ts +4 -4
- package/rules/no-complex-selectors.js +110 -123
- package/rules/no-emoji.d.ts +3 -3
- package/rules/no-emoji.js +87 -93
- package/rules/no-id.d.ts +2 -2
- package/rules/no-id.js +47 -52
- package/rules/no-invalid-icu.d.ts +2 -2
- package/rules/no-invalid-icu.js +57 -56
- package/rules/no-literal-string-in-jsx.d.ts +6 -6
- package/rules/no-literal-string-in-jsx.js +153 -191
- package/rules/no-literal-string-in-object.d.ts +3 -3
- package/rules/no-literal-string-in-object.js +59 -84
- package/rules/no-missing-icu-plural-one-placeholders.d.ts +3 -3
- package/rules/no-missing-icu-plural-one-placeholders.js +93 -109
- package/rules/no-multiple-plurals.d.ts +3 -3
- package/rules/no-multiple-plurals.js +75 -80
- package/rules/no-multiple-whitespaces.d.ts +3 -3
- package/rules/no-multiple-whitespaces.js +123 -132
- package/rules/no-offset.d.ts +3 -3
- package/rules/no-offset.js +74 -79
- package/rules/no-useless-message.d.ts +3 -3
- package/rules/no-useless-message.js +68 -81
- package/rules/prefer-formatted-message.d.ts +2 -2
- package/rules/prefer-formatted-message.js +26 -31
- package/rules/prefer-pound-in-plural.d.ts +3 -3
- package/rules/prefer-pound-in-plural.js +162 -186
- package/util.d.ts +26 -23
- package/util.js +235 -258
package/context-compat.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ParserServicesWithoutTypeInformation, ParserServicesWithTypeInformation } from
|
|
2
|
-
import { RuleContext } from
|
|
1
|
+
import type { ParserServicesWithoutTypeInformation, ParserServicesWithTypeInformation } from "@typescript-eslint/utils";
|
|
2
|
+
import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
export declare const getParserServices: <TRuleContext extends RuleContext<string, unknown[]>>(context: TRuleContext) => Partial<ParserServicesWithoutTypeInformation> | Partial<ParserServicesWithTypeInformation> | undefined;
|
package/context-compat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import "@typescript-eslint/utils/ts-eslint";
|
|
1
2
|
export const getParserServices = (context) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
if (context.parserServices) {
|
|
4
|
+
return context.parserServices;
|
|
5
|
+
}
|
|
6
|
+
return context.sourceCode.parserServices;
|
|
6
7
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { Linter } from
|
|
2
|
-
import { ESLint } from
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import type { ESLint } from "eslint";
|
|
3
3
|
type Plugin = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
meta: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
rules: ESLint.Plugin["rules"];
|
|
9
|
+
configs: {
|
|
10
|
+
strict: Linter.Config;
|
|
11
|
+
recommended: Linter.Config;
|
|
12
|
+
};
|
|
13
13
|
};
|
|
14
|
+
// Base plugin
|
|
14
15
|
declare const plugin: Plugin;
|
|
15
16
|
export default plugin;
|
package/index.js
CHANGED
|
@@ -1,149 +1,107 @@
|
|
|
1
|
-
import { name as blocklistElementRuleName, rule as blocklistElements
|
|
2
|
-
import { rule as enforceDefaultMessage, name as enforceDefaultMessageName
|
|
3
|
-
import { rule as enforceDescription, name as enforceDescriptionName
|
|
4
|
-
import { rule as enforceId, name as enforceIdName } from
|
|
5
|
-
import { rule as enforcePlaceholders, name as enforcePlaceholdersName
|
|
6
|
-
import { rule as enforcePluralRules, name as enforcePluralRulesName
|
|
7
|
-
import { rule as noCamelCase, name as noCamelCaseName
|
|
8
|
-
import { rule as noComplexSelectors, name as noComplexSelectorsName
|
|
9
|
-
import { rule as noEmoji, name as noEmojiName } from
|
|
10
|
-
import { rule as noId, name as noIdName } from
|
|
11
|
-
import { rule as noInvalidICU, name as noInvalidICUName
|
|
12
|
-
import { rule as noLiteralStringInJsx, name as noLiteralStringInJsxName
|
|
13
|
-
import { rule as noMissingIcuPluralOnePlaceholders, name as noMissingIcuPluralOnePlaceholdersName
|
|
14
|
-
import { rule as noMultiplePlurals, name as noMultiplePluralsName
|
|
15
|
-
import { rule as noMultipleWhitespaces, name as noMultipleWhitespacesName
|
|
16
|
-
import { rule as noOffset, name as noOffsetName } from
|
|
17
|
-
import { rule as noUselessMessage, name as noUselessMessageName
|
|
18
|
-
import { rule as preferFormattedMessage, name as preferFormattedMessageName
|
|
19
|
-
import { rule as preferPoundInPlural, name as preferPoundInPluralName
|
|
20
|
-
import { rule as noLiteralStringInObject, name as noLiteralStringInObjectName
|
|
21
|
-
import * as packageJsonNs from
|
|
1
|
+
import { name as blocklistElementRuleName, rule as blocklistElements } from "./rules/blocklist-elements.js";
|
|
2
|
+
import { rule as enforceDefaultMessage, name as enforceDefaultMessageName } from "./rules/enforce-default-message.js";
|
|
3
|
+
import { rule as enforceDescription, name as enforceDescriptionName } from "./rules/enforce-description.js";
|
|
4
|
+
import { rule as enforceId, name as enforceIdName } from "./rules/enforce-id.js";
|
|
5
|
+
import { rule as enforcePlaceholders, name as enforcePlaceholdersName } from "./rules/enforce-placeholders.js";
|
|
6
|
+
import { rule as enforcePluralRules, name as enforcePluralRulesName } from "./rules/enforce-plural-rules.js";
|
|
7
|
+
import { rule as noCamelCase, name as noCamelCaseName } from "./rules/no-camel-case.js";
|
|
8
|
+
import { rule as noComplexSelectors, name as noComplexSelectorsName } from "./rules/no-complex-selectors.js";
|
|
9
|
+
import { rule as noEmoji, name as noEmojiName } from "./rules/no-emoji.js";
|
|
10
|
+
import { rule as noId, name as noIdName } from "./rules/no-id.js";
|
|
11
|
+
import { rule as noInvalidICU, name as noInvalidICUName } from "./rules/no-invalid-icu.js";
|
|
12
|
+
import { rule as noLiteralStringInJsx, name as noLiteralStringInJsxName } from "./rules/no-literal-string-in-jsx.js";
|
|
13
|
+
import { rule as noMissingIcuPluralOnePlaceholders, name as noMissingIcuPluralOnePlaceholdersName } from "./rules/no-missing-icu-plural-one-placeholders.js";
|
|
14
|
+
import { rule as noMultiplePlurals, name as noMultiplePluralsName } from "./rules/no-multiple-plurals.js";
|
|
15
|
+
import { rule as noMultipleWhitespaces, name as noMultipleWhitespacesName } from "./rules/no-multiple-whitespaces.js";
|
|
16
|
+
import { rule as noOffset, name as noOffsetName } from "./rules/no-offset.js";
|
|
17
|
+
import { rule as noUselessMessage, name as noUselessMessageName } from "./rules/no-useless-message.js";
|
|
18
|
+
import { rule as preferFormattedMessage, name as preferFormattedMessageName } from "./rules/prefer-formatted-message.js";
|
|
19
|
+
import { rule as preferPoundInPlural, name as preferPoundInPluralName } from "./rules/prefer-pound-in-plural.js";
|
|
20
|
+
import { rule as noLiteralStringInObject, name as noLiteralStringInObjectName } from "./rules/no-literal-string-in-object.js";
|
|
21
|
+
import * as packageJsonNs from "./package.json" with { type: "json" };
|
|
22
22
|
const packageJson = packageJsonNs.default ?? packageJsonNs;
|
|
23
23
|
const { name, version } = packageJson;
|
|
24
24
|
// All rules
|
|
25
25
|
const rules = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
[noInvalidICUName]: noInvalidICU,
|
|
48
|
-
// @ts-expect-error
|
|
49
|
-
[noLiteralStringInJsxName]: noLiteralStringInJsx,
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
[noMultiplePluralsName]: noMultiplePlurals,
|
|
52
|
-
// @ts-expect-error
|
|
53
|
-
[noMultipleWhitespacesName]: noMultipleWhitespaces,
|
|
54
|
-
// @ts-expect-error
|
|
55
|
-
[noOffsetName]: noOffset,
|
|
56
|
-
// @ts-expect-error
|
|
57
|
-
[noUselessMessageName]: noUselessMessage,
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
[preferFormattedMessageName]: preferFormattedMessage,
|
|
60
|
-
// @ts-expect-error
|
|
61
|
-
[preferPoundInPluralName]: preferPoundInPlural,
|
|
62
|
-
// @ts-expect-error
|
|
63
|
-
[noMissingIcuPluralOnePlaceholdersName]: noMissingIcuPluralOnePlaceholders,
|
|
64
|
-
// @ts-expect-error
|
|
65
|
-
[noLiteralStringInObjectName]: noLiteralStringInObject,
|
|
26
|
+
[blocklistElementRuleName]: blocklistElements,
|
|
27
|
+
[enforceDefaultMessageName]: enforceDefaultMessage,
|
|
28
|
+
[enforceDescriptionName]: enforceDescription,
|
|
29
|
+
[enforceIdName]: enforceId,
|
|
30
|
+
[enforcePlaceholdersName]: enforcePlaceholders,
|
|
31
|
+
[enforcePluralRulesName]: enforcePluralRules,
|
|
32
|
+
[noCamelCaseName]: noCamelCase,
|
|
33
|
+
[noComplexSelectorsName]: noComplexSelectors,
|
|
34
|
+
[noEmojiName]: noEmoji,
|
|
35
|
+
[noIdName]: noId,
|
|
36
|
+
[noInvalidICUName]: noInvalidICU,
|
|
37
|
+
[noLiteralStringInJsxName]: noLiteralStringInJsx,
|
|
38
|
+
[noMultiplePluralsName]: noMultiplePlurals,
|
|
39
|
+
[noMultipleWhitespacesName]: noMultipleWhitespaces,
|
|
40
|
+
[noOffsetName]: noOffset,
|
|
41
|
+
[noUselessMessageName]: noUselessMessage,
|
|
42
|
+
[preferFormattedMessageName]: preferFormattedMessage,
|
|
43
|
+
[preferPoundInPluralName]: preferPoundInPlural,
|
|
44
|
+
[noMissingIcuPluralOnePlaceholdersName]: noMissingIcuPluralOnePlaceholders,
|
|
45
|
+
[noLiteralStringInObjectName]: noLiteralStringInObject
|
|
66
46
|
};
|
|
67
47
|
// Base plugin
|
|
68
48
|
const plugin = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
meta: {
|
|
50
|
+
name,
|
|
51
|
+
version
|
|
52
|
+
},
|
|
53
|
+
rules,
|
|
54
|
+
configs: {}
|
|
72
55
|
};
|
|
73
56
|
// Configs
|
|
74
57
|
const configs = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'formatjs/no-emoji': 'error',
|
|
123
|
-
'formatjs/no-multiple-whitespaces': 'error',
|
|
124
|
-
'formatjs/no-multiple-plurals': 'error',
|
|
125
|
-
'formatjs/no-complex-selectors': ['error', { limit: 20 }],
|
|
126
|
-
'formatjs/no-useless-message': 'error',
|
|
127
|
-
'formatjs/prefer-pound-in-plural': 'error',
|
|
128
|
-
'formatjs/no-missing-icu-plural-one-placeholders': 'error',
|
|
129
|
-
'formatjs/enforce-plural-rules': [
|
|
130
|
-
'error',
|
|
131
|
-
{
|
|
132
|
-
one: true,
|
|
133
|
-
other: true,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
'formatjs/no-literal-string-in-jsx': [
|
|
137
|
-
'warn',
|
|
138
|
-
{
|
|
139
|
-
props: {
|
|
140
|
-
include: [['*', '{label,placeholder,title}']],
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
'formatjs/blocklist-elements': ['error', ['selectordinal']],
|
|
145
|
-
},
|
|
146
|
-
},
|
|
58
|
+
strict: {
|
|
59
|
+
name: "formatjs/strict",
|
|
60
|
+
plugins: { formatjs: plugin },
|
|
61
|
+
rules: {
|
|
62
|
+
"formatjs/no-offset": "error",
|
|
63
|
+
"formatjs/enforce-default-message": ["error", "literal"],
|
|
64
|
+
"formatjs/enforce-description": ["error", "literal"],
|
|
65
|
+
"formatjs/enforce-placeholders": "error",
|
|
66
|
+
"formatjs/no-emoji": "error",
|
|
67
|
+
"formatjs/no-multiple-whitespaces": "error",
|
|
68
|
+
"formatjs/no-multiple-plurals": "error",
|
|
69
|
+
"formatjs/no-complex-selectors": ["error", { limit: 20 }],
|
|
70
|
+
"formatjs/no-useless-message": "error",
|
|
71
|
+
"formatjs/prefer-pound-in-plural": "error",
|
|
72
|
+
"formatjs/no-missing-icu-plural-one-placeholders": "error",
|
|
73
|
+
"formatjs/enforce-id": ["error", { idInterpolationPattern: "[sha512:contenthash:base64:10]" }],
|
|
74
|
+
"formatjs/enforce-plural-rules": ["error", {
|
|
75
|
+
one: true,
|
|
76
|
+
other: true
|
|
77
|
+
}],
|
|
78
|
+
"formatjs/no-literal-string-in-jsx": ["error", { props: { include: [["*", "{label,placeholder,title}"]] } }],
|
|
79
|
+
"formatjs/blocklist-elements": ["error", ["selectordinal"]]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
recommended: {
|
|
83
|
+
name: "formatjs/recommended",
|
|
84
|
+
plugins: { formatjs: plugin },
|
|
85
|
+
rules: {
|
|
86
|
+
"formatjs/no-offset": "error",
|
|
87
|
+
"formatjs/enforce-default-message": ["error", "literal"],
|
|
88
|
+
"formatjs/enforce-description": ["error", "literal"],
|
|
89
|
+
"formatjs/enforce-placeholders": "error",
|
|
90
|
+
"formatjs/no-emoji": "error",
|
|
91
|
+
"formatjs/no-multiple-whitespaces": "error",
|
|
92
|
+
"formatjs/no-multiple-plurals": "error",
|
|
93
|
+
"formatjs/no-complex-selectors": ["error", { limit: 20 }],
|
|
94
|
+
"formatjs/no-useless-message": "error",
|
|
95
|
+
"formatjs/prefer-pound-in-plural": "error",
|
|
96
|
+
"formatjs/no-missing-icu-plural-one-placeholders": "error",
|
|
97
|
+
"formatjs/enforce-plural-rules": ["error", {
|
|
98
|
+
one: true,
|
|
99
|
+
other: true
|
|
100
|
+
}],
|
|
101
|
+
"formatjs/no-literal-string-in-jsx": ["warn", { props: { include: [["*", "{label,placeholder,title}"]] } }],
|
|
102
|
+
"formatjs/blocklist-elements": ["error", ["selectordinal"]]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
147
105
|
};
|
|
148
106
|
plugin.configs = configs;
|
|
149
107
|
export default plugin;
|
package/messages.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type CoreMessageIds =
|
|
1
|
+
export type CoreMessageIds = "parseError";
|
|
2
2
|
export declare const CORE_MESSAGES: Record<CoreMessageIds, string>;
|
package/messages.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-formatjs",
|
|
3
3
|
"description": "ESLint plugin for formatjs",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@types/eslint": "^9.6.1",
|
|
11
10
|
"@types/picomatch": "^4.0.0",
|
|
12
11
|
"@typescript-eslint/utils": "^8.27.0",
|
|
13
12
|
"magic-string": "^0.30.0",
|
|
14
13
|
"picomatch": "2 || 3 || 4",
|
|
15
14
|
"tslib": "^2.8.0",
|
|
16
15
|
"unicode-emoji-utils": "^1.2.0",
|
|
17
|
-
"@formatjs/
|
|
18
|
-
"@formatjs/
|
|
16
|
+
"@formatjs/icu-messageformat-parser": "3.3.0",
|
|
17
|
+
"@formatjs/ts-transformer": "4.2.0"
|
|
19
18
|
},
|
|
20
19
|
"peerDependencies": {
|
|
21
|
-
"eslint": "
|
|
20
|
+
"@types/eslint": "9",
|
|
21
|
+
"eslint": "9"
|
|
22
22
|
},
|
|
23
23
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
24
24
|
"homepage": "https://github.com/formatjs/formatjs#readme",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ESLintUtils } from
|
|
2
|
-
import { CoreMessageIds } from
|
|
3
|
-
type MessageIds =
|
|
1
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
import { type CoreMessageIds } from "../messages.js";
|
|
3
|
+
type MessageIds = "blocklist" | CoreMessageIds;
|
|
4
4
|
export declare const name = "blocklist-elements";
|
|
5
5
|
export declare enum Element {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
literal = "literal",
|
|
7
|
+
argument = "argument",
|
|
8
|
+
number = "number",
|
|
9
|
+
date = "date",
|
|
10
|
+
time = "time",
|
|
11
|
+
select = "select",
|
|
12
|
+
selectordinal = "selectordinal",
|
|
13
|
+
plural = "plural",
|
|
14
|
+
tag = "tag"
|
|
15
15
|
}
|
|
16
16
|
export declare const rule: ESLintUtils.RuleModule<MessageIds, Element[][], unknown, ESLintUtils.RuleListener>;
|
|
17
17
|
export {};
|