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.
Files changed (49) hide show
  1. package/context-compat.d.ts +2 -2
  2. package/context-compat.js +5 -4
  3. package/index.d.ts +12 -11
  4. package/index.js +94 -136
  5. package/messages.d.ts +1 -1
  6. package/messages.js +1 -3
  7. package/package.json +5 -5
  8. package/rules/blocklist-elements.d.ts +12 -12
  9. package/rules/blocklist-elements.js +129 -140
  10. package/rules/enforce-default-message.d.ts +4 -4
  11. package/rules/enforce-default-message.js +56 -62
  12. package/rules/enforce-description.d.ts +4 -4
  13. package/rules/enforce-description.js +56 -62
  14. package/rules/enforce-id.d.ts +5 -5
  15. package/rules/enforce-id.js +137 -158
  16. package/rules/enforce-placeholders.d.ts +4 -4
  17. package/rules/enforce-placeholders.js +127 -142
  18. package/rules/enforce-plural-rules.d.ts +10 -12
  19. package/rules/enforce-plural-rules.js +107 -113
  20. package/rules/no-camel-case.d.ts +3 -3
  21. package/rules/no-camel-case.js +83 -85
  22. package/rules/no-complex-selectors.d.ts +4 -4
  23. package/rules/no-complex-selectors.js +110 -123
  24. package/rules/no-emoji.d.ts +3 -3
  25. package/rules/no-emoji.js +87 -93
  26. package/rules/no-id.d.ts +2 -2
  27. package/rules/no-id.js +47 -52
  28. package/rules/no-invalid-icu.d.ts +2 -2
  29. package/rules/no-invalid-icu.js +57 -56
  30. package/rules/no-literal-string-in-jsx.d.ts +6 -6
  31. package/rules/no-literal-string-in-jsx.js +153 -191
  32. package/rules/no-literal-string-in-object.d.ts +3 -3
  33. package/rules/no-literal-string-in-object.js +59 -84
  34. package/rules/no-missing-icu-plural-one-placeholders.d.ts +3 -3
  35. package/rules/no-missing-icu-plural-one-placeholders.js +93 -109
  36. package/rules/no-multiple-plurals.d.ts +3 -3
  37. package/rules/no-multiple-plurals.js +75 -80
  38. package/rules/no-multiple-whitespaces.d.ts +3 -3
  39. package/rules/no-multiple-whitespaces.js +123 -132
  40. package/rules/no-offset.d.ts +3 -3
  41. package/rules/no-offset.js +74 -79
  42. package/rules/no-useless-message.d.ts +3 -3
  43. package/rules/no-useless-message.js +68 -81
  44. package/rules/prefer-formatted-message.d.ts +2 -2
  45. package/rules/prefer-formatted-message.js +26 -31
  46. package/rules/prefer-pound-in-plural.d.ts +3 -3
  47. package/rules/prefer-pound-in-plural.js +162 -186
  48. package/util.d.ts +26 -23
  49. package/util.js +235 -258
@@ -1,3 +1,3 @@
1
- import type { ParserServicesWithoutTypeInformation, ParserServicesWithTypeInformation } from '@typescript-eslint/utils';
2
- import { RuleContext } from '@typescript-eslint/utils/ts-eslint';
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
- if (context.parserServices) {
3
- return context.parserServices;
4
- }
5
- return context.sourceCode.parserServices;
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 'eslint';
2
- import { ESLint } from 'eslint';
1
+ import type { Linter } from "eslint";
2
+ import type { ESLint } from "eslint";
3
3
  type Plugin = {
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
- };
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, } 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' };
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
- // @ts-expect-error
27
- [blocklistElementRuleName]: blocklistElements,
28
- // @ts-expect-error
29
- [enforceDefaultMessageName]: enforceDefaultMessage,
30
- // @ts-expect-error
31
- [enforceDescriptionName]: enforceDescription,
32
- // @ts-expect-error
33
- [enforceIdName]: enforceId,
34
- // @ts-expect-error
35
- [enforcePlaceholdersName]: enforcePlaceholders,
36
- // @ts-expect-error
37
- [enforcePluralRulesName]: enforcePluralRules,
38
- // @ts-expect-error
39
- [noCamelCaseName]: noCamelCase,
40
- // @ts-expect-error
41
- [noComplexSelectorsName]: noComplexSelectors,
42
- // @ts-expect-error
43
- [noEmojiName]: noEmoji,
44
- // @ts-expect-error
45
- [noIdName]: noId,
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
- meta: { name, version },
70
- rules,
71
- configs: {}, // will be populated later
49
+ meta: {
50
+ name,
51
+ version
52
+ },
53
+ rules,
54
+ configs: {}
72
55
  };
73
56
  // Configs
74
57
  const configs = {
75
- strict: {
76
- name: 'formatjs/strict',
77
- plugins: { formatjs: plugin },
78
- rules: {
79
- 'formatjs/no-offset': 'error',
80
- 'formatjs/enforce-default-message': ['error', 'literal'],
81
- 'formatjs/enforce-description': ['error', 'literal'],
82
- 'formatjs/enforce-placeholders': 'error',
83
- 'formatjs/no-emoji': 'error',
84
- 'formatjs/no-multiple-whitespaces': 'error',
85
- 'formatjs/no-multiple-plurals': 'error',
86
- 'formatjs/no-complex-selectors': ['error', { limit: 20 }],
87
- 'formatjs/no-useless-message': 'error',
88
- 'formatjs/prefer-pound-in-plural': 'error',
89
- 'formatjs/no-missing-icu-plural-one-placeholders': 'error',
90
- 'formatjs/enforce-id': [
91
- 'error',
92
- {
93
- idInterpolationPattern: '[sha512:contenthash:base64:10]',
94
- },
95
- ],
96
- 'formatjs/enforce-plural-rules': [
97
- 'error',
98
- {
99
- one: true,
100
- other: true,
101
- },
102
- ],
103
- 'formatjs/no-literal-string-in-jsx': [
104
- 'error',
105
- {
106
- props: {
107
- include: [['*', '{label,placeholder,title}']],
108
- },
109
- },
110
- ],
111
- 'formatjs/blocklist-elements': ['error', ['selectordinal']],
112
- },
113
- },
114
- recommended: {
115
- name: 'formatjs/recommended',
116
- plugins: { formatjs: plugin },
117
- rules: {
118
- 'formatjs/no-offset': 'error',
119
- 'formatjs/enforce-default-message': ['error', 'literal'],
120
- 'formatjs/enforce-description': ['error', 'literal'],
121
- 'formatjs/enforce-placeholders': 'error',
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 = 'parseError';
1
+ export type CoreMessageIds = "parseError";
2
2
  export declare const CORE_MESSAGES: Record<CoreMessageIds, string>;
package/messages.js CHANGED
@@ -1,3 +1 @@
1
- export const CORE_MESSAGES = {
2
- parseError: `Failed to parse message string {{error}}`,
3
- };
1
+ export const CORE_MESSAGES = { parseError: `Failed to parse message string {{error}}` };
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.8",
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/ts-transformer": "4.0.7",
18
- "@formatjs/icu-messageformat-parser": "3.2.0"
16
+ "@formatjs/icu-messageformat-parser": "3.3.0",
17
+ "@formatjs/ts-transformer": "4.2.0"
19
18
  },
20
19
  "peerDependencies": {
21
- "eslint": "^9.23.0"
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 '@typescript-eslint/utils';
2
- import { CoreMessageIds } from '../messages.js';
3
- type MessageIds = 'blocklist' | CoreMessageIds;
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
- 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"
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 {};