@alexlit/lint-kit 167.3.0 → 167.4.0

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 (142) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/LICENSE +21 -0
  3. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/README.md +54 -0
  4. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/base.d.ts +23 -0
  5. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/base.js +25 -0
  6. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/flat/base.d.ts +35 -0
  7. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/flat/base.js +35 -0
  8. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/flat/recommended.d.ts +1194 -0
  9. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/flat/recommended.js +39 -0
  10. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/recommended.d.ts +29 -0
  11. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/configs/recommended.js +29 -0
  12. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/index.d.ts +2532 -0
  13. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/index.js +62 -0
  14. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/key-format-style.d.ts +2 -0
  15. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/key-format-style.js +247 -0
  16. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-component.d.ts +2 -0
  17. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-component.js +85 -0
  18. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-place-attr.d.ts +2 -0
  19. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-place-attr.js +41 -0
  20. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-places-prop.d.ts +2 -0
  21. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-i18n-places-prop.js +36 -0
  22. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-modulo-syntax.d.ts +2 -0
  23. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-modulo-syntax.js +94 -0
  24. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-tc.d.ts +2 -0
  25. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-tc.js +42 -0
  26. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-v-t.d.ts +2 -0
  27. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-deprecated-v-t.js +33 -0
  28. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-duplicate-keys-in-locale.d.ts +2 -0
  29. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-duplicate-keys-in-locale.js +271 -0
  30. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-dynamic-keys.d.ts +2 -0
  31. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-dynamic-keys.js +105 -0
  32. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-html-messages.d.ts +2 -0
  33. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-html-messages.js +137 -0
  34. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-i18n-t-path-prop.d.ts +2 -0
  35. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-i18n-t-path-prop.js +44 -0
  36. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-missing-keys-in-other-locales.d.ts +2 -0
  37. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-missing-keys-in-other-locales.js +264 -0
  38. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-missing-keys.d.ts +2 -0
  39. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-missing-keys.js +111 -0
  40. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-raw-text.d.ts +2 -0
  41. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-raw-text.js +575 -0
  42. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-unknown-locale.d.ts +2 -0
  43. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-unknown-locale.js +198 -0
  44. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-unused-keys.d.ts +2 -0
  45. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-unused-keys.js +456 -0
  46. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-v-html.d.ts +2 -0
  47. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/no-v-html.js +50 -0
  48. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/prefer-linked-key-with-paren.d.ts +2 -0
  49. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/prefer-linked-key-with-paren.js +108 -0
  50. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/prefer-sfc-lang-attr.d.ts +2 -0
  51. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/prefer-sfc-lang-attr.js +58 -0
  52. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/sfc-locale-attr.d.ts +2 -0
  53. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/sfc-locale-attr.js +65 -0
  54. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/valid-message-syntax.d.ts +2 -0
  55. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/rules/valid-message-syntax.js +186 -0
  56. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/eslint.d.ts +216 -0
  57. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/eslint.js +2 -0
  58. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/i18n.d.ts +5 -0
  59. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/i18n.js +2 -0
  60. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/index.d.ts +6 -0
  61. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/index.js +22 -0
  62. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/nodes.d.ts +7 -0
  63. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/nodes.js +2 -0
  64. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/settings.d.ts +8 -0
  65. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/settings.js +2 -0
  66. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/types.d.ts +38 -0
  67. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/types.js +2 -0
  68. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/vue-parser-services.d.ts +32 -0
  69. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/types/vue-parser-services.js +2 -0
  70. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/cache-function.d.ts +2 -0
  71. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/cache-function.js +11 -0
  72. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/cache-loader.d.ts +10 -0
  73. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/cache-loader.js +27 -0
  74. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/casing.d.ts +10 -0
  75. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/casing.js +101 -0
  76. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/collect-keys.d.ts +13 -0
  77. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/collect-keys.js +160 -0
  78. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/collect-linked-keys.d.ts +2 -0
  79. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/collect-linked-keys.js +49 -0
  80. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/compat.d.ts +3 -0
  81. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/compat.js +35 -0
  82. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/default-timeouts.d.ts +6 -0
  83. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/default-timeouts.js +10 -0
  84. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/get-cwd.d.ts +2 -0
  85. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/get-cwd.js +9 -0
  86. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/glob-utils.d.ts +15 -0
  87. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/glob-utils.js +154 -0
  88. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/ignored-paths.d.ts +43 -0
  89. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/ignored-paths.js +234 -0
  90. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/index.d.ts +25 -0
  91. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/index.js +446 -0
  92. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/key-path.d.ts +2 -0
  93. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/key-path.js +27 -0
  94. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/locale-messages.d.ts +54 -0
  95. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/locale-messages.js +187 -0
  96. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/parser-v9.d.ts +8 -0
  97. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/parser-v9.js +40 -0
  98. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/parser.d.ts +5 -0
  99. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/parser.js +18 -0
  100. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/traverser.d.ts +6 -0
  101. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/traverser.js +31 -0
  102. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/utils.d.ts +28 -0
  103. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/message-compiler/utils.js +279 -0
  104. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/build-parser-using-flat-config.d.ts +2 -0
  105. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/build-parser-using-flat-config.js +11 -0
  106. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/build-parser-using-legacy-config.d.ts +2 -0
  107. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/build-parser-using-legacy-config.js +46 -0
  108. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/index.d.ts +4 -0
  109. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/index.js +18 -0
  110. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/parse-by-parser.d.ts +3 -0
  111. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/parse-by-parser.js +42 -0
  112. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/should-use-flat-config.d.ts +2 -0
  113. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/should-use-flat-config.js +54 -0
  114. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/worker.d.ts +1 -0
  115. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parser-config-resolver/worker.js +32 -0
  116. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parsers/index.d.ts +4 -0
  117. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/parsers/index.js +32 -0
  118. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/path-utils.d.ts +2 -0
  119. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/path-utils.js +21 -0
  120. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/regexp.d.ts +1 -0
  121. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/regexp.js +16 -0
  122. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/resource-loader.d.ts +10 -0
  123. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/resource-loader.js +32 -0
  124. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/rule.d.ts +9 -0
  125. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/dist/utils/rule.js +75 -0
  126. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/globals.json +3345 -0
  127. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/index.d.ts +3452 -0
  128. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/index.js +2 -0
  129. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/license +9 -0
  130. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/package.json +117 -0
  131. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/node_modules/globals/readme.md +42 -0
  132. package/packages/config-eslint/node_modules/@intlify/eslint-plugin-vue-i18n/package.json +147 -0
  133. package/packages/config-eslint/node_modules/vue-eslint-parser/LICENSE +21 -0
  134. package/packages/config-eslint/node_modules/vue-eslint-parser/README.md +332 -0
  135. package/packages/config-eslint/node_modules/vue-eslint-parser/index.d.ts +667 -0
  136. package/packages/config-eslint/node_modules/vue-eslint-parser/index.js +6642 -0
  137. package/packages/config-eslint/node_modules/vue-eslint-parser/index.js.map +1 -0
  138. package/packages/config-eslint/node_modules/vue-eslint-parser/package.json +100 -0
  139. package/packages/config-eslint/package.json +5 -5
  140. package/packages/config-eslint/plugins/unicorn.js +2 -0
  141. package/packages/config-prettier/package.json +2 -2
  142. package/packages/config-stylelint/package.json +2 -2
@@ -0,0 +1,446 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.compositingVisitors = exports.skipTSAsExpression = exports.getStaticAttributes = exports.isI18nBlock = exports.isVElement = exports.getScriptSetupElement = exports.getVueObjectType = exports.defineCustomBlocksVisitor = exports.getLocaleMessages = exports.getStaticLiteralValue = exports.isStaticLiteral = exports.getDirective = exports.getAttribute = exports.defineTemplateBodyVisitor = void 0;
27
+ const glob_1 = require("glob");
28
+ const path_1 = require("path");
29
+ const locale_messages_1 = require("./locale-messages");
30
+ const cache_loader_1 = require("./cache-loader");
31
+ const cache_function_1 = require("./cache-function");
32
+ const jsoncESLintParser = __importStar(require("jsonc-eslint-parser"));
33
+ const yamlESLintParser = __importStar(require("yaml-eslint-parser"));
34
+ const get_cwd_1 = require("./get-cwd");
35
+ const compat_1 = require("./compat");
36
+ const UNEXPECTED_ERROR_LOCATION = { line: 1, column: 0 };
37
+ function defineTemplateBodyVisitor(context, templateBodyVisitor, scriptVisitor) {
38
+ const sourceCode = (0, compat_1.getSourceCode)(context);
39
+ if (sourceCode.parserServices.defineTemplateBodyVisitor == null) {
40
+ const filename = (0, compat_1.getFilename)(context);
41
+ if ((0, path_1.extname)(filename) === '.vue') {
42
+ context.report({
43
+ loc: UNEXPECTED_ERROR_LOCATION,
44
+ message: 'Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error'
45
+ });
46
+ }
47
+ return {};
48
+ }
49
+ return sourceCode.parserServices.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
50
+ }
51
+ exports.defineTemplateBodyVisitor = defineTemplateBodyVisitor;
52
+ function getAttribute(node, name) {
53
+ return (node.startTag.attributes
54
+ .map(node => (!node.directive ? node : null))
55
+ .find(node => {
56
+ return node && node.key.name === name;
57
+ }) || null);
58
+ }
59
+ exports.getAttribute = getAttribute;
60
+ function getDirective(node, name, argument) {
61
+ return (node.startTag.attributes
62
+ .map(node => (node.directive ? node : null))
63
+ .find(node => {
64
+ return (node &&
65
+ node.key.name.name === name &&
66
+ (argument === undefined ||
67
+ (node.key.argument &&
68
+ node.key.argument.type === 'VIdentifier' &&
69
+ node.key.argument.name) === argument));
70
+ }) || null);
71
+ }
72
+ exports.getDirective = getDirective;
73
+ function isStaticLiteral(node) {
74
+ return Boolean(node &&
75
+ (node.type === 'Literal' ||
76
+ (node.type === 'TemplateLiteral' && node.expressions.length === 0)));
77
+ }
78
+ exports.isStaticLiteral = isStaticLiteral;
79
+ function getStaticLiteralValue(node) {
80
+ return node.type !== 'TemplateLiteral'
81
+ ? node.value
82
+ : node.quasis[0].value.cooked || node.quasis[0].value.raw;
83
+ }
84
+ exports.getStaticLiteralValue = getStaticLiteralValue;
85
+ function loadLocaleMessages(localeFilesList, cwd) {
86
+ const results = [];
87
+ const checkDupeMap = {};
88
+ for (const { files, localeKey, localePattern } of localeFilesList) {
89
+ for (const file of files) {
90
+ const localeKeys = checkDupeMap[file] || (checkDupeMap[file] = []);
91
+ if (localeKeys.includes(localeKey)) {
92
+ continue;
93
+ }
94
+ localeKeys.push(localeKey);
95
+ const fullpath = (0, path_1.resolve)(cwd, file);
96
+ results.push(new locale_messages_1.FileLocaleMessage({ fullpath, localeKey, localePattern }));
97
+ }
98
+ }
99
+ return results;
100
+ }
101
+ const puttedSettingsError = new WeakSet();
102
+ function getLocaleMessages(context, options) {
103
+ const sourceCode = (0, compat_1.getSourceCode)(context);
104
+ const { settings } = context;
105
+ const localeDir = (settings['vue-i18n'] && settings['vue-i18n'].localeDir) || null;
106
+ const documentFragment = sourceCode.parserServices.getDocumentFragment &&
107
+ sourceCode.parserServices.getDocumentFragment();
108
+ const i18nBlocks = (documentFragment &&
109
+ documentFragment.children.filter((node) => node.type === 'VElement' && node.name === 'i18n')) ||
110
+ [];
111
+ if (!localeDir && !i18nBlocks.length) {
112
+ if (!puttedSettingsError.has(context) &&
113
+ !(options === null || options === void 0 ? void 0 : options.ignoreMissingSettingsError)) {
114
+ context.report({
115
+ loc: UNEXPECTED_ERROR_LOCATION,
116
+ message: `You need to set 'localeDir' at 'settings', or '<i18n>' blocks. See the 'eslint-plugin-vue-i18n' documentation`
117
+ });
118
+ puttedSettingsError.add(context);
119
+ }
120
+ return new locale_messages_1.LocaleMessages([]);
121
+ }
122
+ return new locale_messages_1.LocaleMessages([
123
+ ...(getLocaleMessagesFromI18nBlocks(context, i18nBlocks) || []),
124
+ ...((localeDir &&
125
+ localeDirLocaleMessagesCache.getLocaleMessagesFromLocaleDir(context, localeDir)) ||
126
+ [])
127
+ ]);
128
+ }
129
+ exports.getLocaleMessages = getLocaleMessages;
130
+ class LocaleDirLocaleMessagesCache {
131
+ constructor() {
132
+ this._targetFilesLoader = new cache_loader_1.CacheLoader((pattern, cwd) => (0, glob_1.sync)(pattern, { cwd }));
133
+ this._loadLocaleMessages = (0, cache_function_1.defineCacheFunction)((localeFilesList, cwd) => {
134
+ return loadLocaleMessages(localeFilesList, cwd);
135
+ });
136
+ }
137
+ getLocaleMessagesFromLocaleDir(context, localeDir) {
138
+ const cwd = (0, get_cwd_1.getCwd)(context);
139
+ let localeFilesList;
140
+ if (Array.isArray(localeDir)) {
141
+ localeFilesList = localeDir.map(dir => this._toLocaleFiles(dir, cwd));
142
+ }
143
+ else {
144
+ localeFilesList = [this._toLocaleFiles(localeDir, cwd)];
145
+ }
146
+ return this._loadLocaleMessages(localeFilesList, cwd);
147
+ }
148
+ _toLocaleFiles(localeDir, cwd) {
149
+ var _a;
150
+ const targetFilesLoader = this._targetFilesLoader;
151
+ if (typeof localeDir === 'string') {
152
+ return {
153
+ files: targetFilesLoader.get(localeDir, cwd),
154
+ localeKey: 'file'
155
+ };
156
+ }
157
+ else {
158
+ return {
159
+ files: targetFilesLoader.get(localeDir.pattern, cwd),
160
+ localeKey: String((_a = localeDir.localeKey) !== null && _a !== void 0 ? _a : 'file'),
161
+ localePattern: localeDir.localePattern
162
+ };
163
+ }
164
+ }
165
+ }
166
+ const localeDirLocaleMessagesCache = new LocaleDirLocaleMessagesCache();
167
+ const i18nBlockLocaleMessages = new WeakMap();
168
+ function getLocaleMessagesFromI18nBlocks(context, i18nBlocks) {
169
+ const sourceCode = (0, compat_1.getSourceCode)(context);
170
+ let localeMessages = i18nBlockLocaleMessages.get(sourceCode.ast);
171
+ if (localeMessages) {
172
+ return localeMessages;
173
+ }
174
+ const filename = (0, compat_1.getFilename)(context);
175
+ localeMessages = i18nBlocks
176
+ .map(block => {
177
+ const attrs = getStaticAttributes(block);
178
+ let localeMessage = null;
179
+ if (attrs.src) {
180
+ const fullpath = (0, path_1.resolve)((0, path_1.dirname)(filename), attrs.src);
181
+ if (attrs.locale) {
182
+ localeMessage = new locale_messages_1.FileLocaleMessage({
183
+ fullpath,
184
+ locales: [attrs.locale],
185
+ localeKey: 'file'
186
+ });
187
+ }
188
+ else {
189
+ localeMessage = new locale_messages_1.FileLocaleMessage({
190
+ fullpath,
191
+ localeKey: 'key'
192
+ });
193
+ }
194
+ }
195
+ else if (block.endTag) {
196
+ if (attrs.locale) {
197
+ localeMessage = new locale_messages_1.BlockLocaleMessage({
198
+ block,
199
+ fullpath: filename,
200
+ locales: [attrs.locale],
201
+ localeKey: 'file',
202
+ context,
203
+ lang: attrs.lang
204
+ });
205
+ }
206
+ else {
207
+ localeMessage = new locale_messages_1.BlockLocaleMessage({
208
+ block,
209
+ fullpath: filename,
210
+ localeKey: 'key',
211
+ context,
212
+ lang: attrs.lang
213
+ });
214
+ }
215
+ }
216
+ if (localeMessage) {
217
+ return localeMessage;
218
+ }
219
+ return null;
220
+ })
221
+ .filter(e => e);
222
+ i18nBlockLocaleMessages.set(sourceCode.ast, localeMessages);
223
+ return localeMessages;
224
+ }
225
+ function defineCustomBlocksVisitor(context, jsonRule, yamlRule) {
226
+ const sourceCode = (0, compat_1.getSourceCode)(context);
227
+ if (!sourceCode.parserServices.defineCustomBlocksVisitor) {
228
+ return {};
229
+ }
230
+ const jsonVisitor = sourceCode.parserServices.defineCustomBlocksVisitor(context, jsoncESLintParser, {
231
+ target(lang, block) {
232
+ if (block.name !== 'i18n') {
233
+ return false;
234
+ }
235
+ return !lang || lang === 'json' || lang === 'json5';
236
+ },
237
+ create: jsonRule
238
+ });
239
+ const yamlVisitor = sourceCode.parserServices.defineCustomBlocksVisitor(context, yamlESLintParser, {
240
+ target(lang, block) {
241
+ if (block.name !== 'i18n') {
242
+ return false;
243
+ }
244
+ return lang === 'yaml' || lang === 'yml';
245
+ },
246
+ create: yamlRule
247
+ });
248
+ return compositingVisitors(jsonVisitor, yamlVisitor);
249
+ }
250
+ exports.defineCustomBlocksVisitor = defineCustomBlocksVisitor;
251
+ function getVueObjectType(context, node) {
252
+ if (node.type !== 'ObjectExpression' || !node.parent) {
253
+ return null;
254
+ }
255
+ const parent = node.parent;
256
+ if (parent.type === 'ExportDefaultDeclaration') {
257
+ const ext = (0, path_1.extname)((0, compat_1.getFilename)(context)).toLowerCase();
258
+ if ((ext === '.vue' || ext === '.jsx' || !ext) &&
259
+ skipTSAsExpression(parent.declaration) === node) {
260
+ const scriptSetup = getScriptSetupElement(context);
261
+ if (scriptSetup &&
262
+ scriptSetup.range[0] <= parent.range[0] &&
263
+ parent.range[1] <= scriptSetup.range[1]) {
264
+ return null;
265
+ }
266
+ return 'export';
267
+ }
268
+ }
269
+ else if (parent.type === 'CallExpression') {
270
+ if (getVueComponentDefinitionType(node) != null &&
271
+ skipTSAsExpression(parent.arguments.slice(-1)[0]) === node) {
272
+ return 'definition';
273
+ }
274
+ }
275
+ else if (parent.type === 'NewExpression') {
276
+ if (isVueInstance(parent) &&
277
+ skipTSAsExpression(parent.arguments[0]) === node) {
278
+ return 'instance';
279
+ }
280
+ }
281
+ else if (parent.type === 'VariableDeclarator') {
282
+ if (parent.init === node &&
283
+ parent.id.type === 'Identifier' &&
284
+ /^[A-Z][a-zA-Z\d]+/u.test(parent.id.name) &&
285
+ parent.id.name.toUpperCase() !== parent.id.name) {
286
+ return 'variable';
287
+ }
288
+ }
289
+ else if (parent.type === 'Property') {
290
+ const componentsCandidate = parent.parent;
291
+ const pp = componentsCandidate.parent;
292
+ if (pp &&
293
+ pp.type === 'Property' &&
294
+ pp.value === componentsCandidate &&
295
+ !pp.computed &&
296
+ (pp.key.type === 'Identifier'
297
+ ? pp.key.name
298
+ : pp.key.type === 'Literal'
299
+ ? `${pp.key.value}`
300
+ : '') === 'components') {
301
+ return 'components-option';
302
+ }
303
+ }
304
+ if (getComponentComments(context).some(el => el.loc.end.line === node.loc.start.line - 1)) {
305
+ return 'mark';
306
+ }
307
+ return null;
308
+ }
309
+ exports.getVueObjectType = getVueObjectType;
310
+ function getScriptSetupElement(context) {
311
+ const sourceCode = (0, compat_1.getSourceCode)(context);
312
+ const df = sourceCode.parserServices.getDocumentFragment &&
313
+ sourceCode.parserServices.getDocumentFragment();
314
+ if (!df) {
315
+ return null;
316
+ }
317
+ const scripts = df.children
318
+ .filter(isVElement)
319
+ .filter(e => e.name === 'script');
320
+ if (scripts.length === 2) {
321
+ return scripts.find(e => getAttribute(e, 'setup')) || null;
322
+ }
323
+ else {
324
+ const script = scripts[0];
325
+ if (script && getAttribute(script, 'setup')) {
326
+ return script;
327
+ }
328
+ }
329
+ return null;
330
+ }
331
+ exports.getScriptSetupElement = getScriptSetupElement;
332
+ function isVElement(node) {
333
+ return node.type === 'VElement';
334
+ }
335
+ exports.isVElement = isVElement;
336
+ function isI18nBlock(node) {
337
+ return isVElement(node) && node.name === 'i18n';
338
+ }
339
+ exports.isI18nBlock = isI18nBlock;
340
+ function getStaticAttributes(element) {
341
+ const attrs = {};
342
+ for (const attr of element.startTag.attributes) {
343
+ if (!attr.directive && attr.value) {
344
+ attrs[attr.key.name] = attr.value.value;
345
+ }
346
+ }
347
+ return attrs;
348
+ }
349
+ exports.getStaticAttributes = getStaticAttributes;
350
+ function skipTSAsExpression(node) {
351
+ if (!node) {
352
+ return node;
353
+ }
354
+ if (node.type === 'TSAsExpression') {
355
+ return skipTSAsExpression(node.expression);
356
+ }
357
+ return node;
358
+ }
359
+ exports.skipTSAsExpression = skipTSAsExpression;
360
+ function compositingVisitors(visitor, ...visitors) {
361
+ for (const v of visitors) {
362
+ for (const key in v) {
363
+ if (visitor[key]) {
364
+ const o = visitor[key];
365
+ visitor[key] = (...args) => {
366
+ o(...args);
367
+ v[key](...args);
368
+ };
369
+ }
370
+ else {
371
+ visitor[key] = v[key];
372
+ }
373
+ }
374
+ }
375
+ return visitor;
376
+ }
377
+ exports.compositingVisitors = compositingVisitors;
378
+ function getVueComponentDefinitionType(node) {
379
+ const parent = node.parent;
380
+ if (parent && parent.type === 'CallExpression') {
381
+ const callee = parent.callee;
382
+ if (callee.type === 'MemberExpression') {
383
+ const calleeObject = skipTSAsExpression(callee.object);
384
+ if (calleeObject.type === 'Identifier') {
385
+ const propName = !callee.computed &&
386
+ callee.property.type === 'Identifier' &&
387
+ callee.property.name;
388
+ if (calleeObject.name === 'Vue') {
389
+ const maybeFullVueComponentForVue2 = propName && isObjectArgument(parent);
390
+ return maybeFullVueComponentForVue2 &&
391
+ (propName === 'component' ||
392
+ propName === 'mixin' ||
393
+ propName === 'extend')
394
+ ? propName
395
+ : null;
396
+ }
397
+ const maybeFullVueComponent = propName && isObjectArgument(parent);
398
+ return maybeFullVueComponent &&
399
+ (propName === 'component' || propName === 'mixin')
400
+ ? propName
401
+ : null;
402
+ }
403
+ }
404
+ if (callee.type === 'Identifier') {
405
+ if (callee.name === 'component') {
406
+ const isDestructedVueComponent = isObjectArgument(parent);
407
+ return isDestructedVueComponent ? 'component' : null;
408
+ }
409
+ if (callee.name === 'createApp') {
410
+ const isAppVueComponent = isObjectArgument(parent);
411
+ return isAppVueComponent ? 'createApp' : null;
412
+ }
413
+ if (callee.name === 'defineComponent') {
414
+ const isDestructedVueComponent = isObjectArgument(parent);
415
+ return isDestructedVueComponent ? 'defineComponent' : null;
416
+ }
417
+ }
418
+ }
419
+ return null;
420
+ function isObjectArgument(node) {
421
+ return (node.arguments.length > 0 &&
422
+ skipTSAsExpression(node.arguments.slice(-1)[0]).type ===
423
+ 'ObjectExpression');
424
+ }
425
+ }
426
+ function isVueInstance(node) {
427
+ const callee = node.callee;
428
+ return Boolean(node.type === 'NewExpression' &&
429
+ callee.type === 'Identifier' &&
430
+ callee.name === 'Vue' &&
431
+ node.arguments.length &&
432
+ skipTSAsExpression(node.arguments[0]).type === 'ObjectExpression');
433
+ }
434
+ const componentComments = new WeakMap();
435
+ function getComponentComments(context) {
436
+ let tokens = componentComments.get(context);
437
+ if (tokens) {
438
+ return tokens;
439
+ }
440
+ const sourceCode = (0, compat_1.getSourceCode)(context);
441
+ tokens = sourceCode
442
+ .getAllComments()
443
+ .filter(comment => /@vue\/component/g.test(comment.value));
444
+ componentComments.set(context, tokens);
445
+ return tokens;
446
+ }
@@ -0,0 +1,2 @@
1
+ export declare function joinPath(...paths: (string | number)[]): string;
2
+ export declare function parsePath(path: string): string[];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePath = exports.joinPath = void 0;
4
+ const core_base_1 = require("@intlify/core-base");
5
+ function joinPath(...paths) {
6
+ let result = '';
7
+ for (const p of paths) {
8
+ if (typeof p === 'number') {
9
+ result += `[${p}]`;
10
+ }
11
+ else if (/^[^\s,.[\]]+$/iu.test(p)) {
12
+ result = result ? `${result}.${p}` : p;
13
+ }
14
+ else if (/^(?:0|[1-9]\d*)*$/iu.test(p)) {
15
+ result += `[${p}]`;
16
+ }
17
+ else {
18
+ result += `[${JSON.stringify(p)}]`;
19
+ }
20
+ }
21
+ return result;
22
+ }
23
+ exports.joinPath = joinPath;
24
+ function parsePath(path) {
25
+ return (0, core_base_1.parse)(path) || [path];
26
+ }
27
+ exports.parsePath = parsePath;
@@ -0,0 +1,54 @@
1
+ import type { AST as VAST } from 'vue-eslint-parser';
2
+ import type { RuleContext, I18nLocaleMessageDictionary, LocaleKeyType } from '../types';
3
+ export declare abstract class LocaleMessage {
4
+ readonly fullpath: string;
5
+ readonly localeKey: LocaleKeyType;
6
+ readonly file: string;
7
+ readonly localePattern: RegExp;
8
+ private _locales;
9
+ constructor({ fullpath, locales, localeKey, localePattern }: {
10
+ fullpath: string;
11
+ locales?: string[];
12
+ localeKey: LocaleKeyType;
13
+ localePattern?: string | RegExp;
14
+ });
15
+ abstract getMessagesInternal(): I18nLocaleMessageDictionary;
16
+ getLocalePatternWithRegex(localePattern?: string | RegExp): RegExp;
17
+ get messages(): I18nLocaleMessageDictionary;
18
+ get locales(): string[];
19
+ isResolvedLocaleByFileName(): boolean;
20
+ getMessagesFromLocale(locale: string): I18nLocaleMessageDictionary;
21
+ }
22
+ export declare class BlockLocaleMessage extends LocaleMessage {
23
+ readonly block: VAST.VElement;
24
+ private lang;
25
+ private _messages;
26
+ constructor({ block, fullpath, locales, localeKey, lang }: {
27
+ block: VAST.VElement;
28
+ fullpath: string;
29
+ locales?: string[];
30
+ localeKey: LocaleKeyType;
31
+ context: RuleContext;
32
+ lang?: string;
33
+ });
34
+ getMessagesInternal(): I18nLocaleMessageDictionary;
35
+ }
36
+ export declare class FileLocaleMessage extends LocaleMessage {
37
+ private _resource;
38
+ constructor({ fullpath, locales, localeKey, localePattern }: {
39
+ fullpath: string;
40
+ locales?: string[];
41
+ localeKey: LocaleKeyType;
42
+ localePattern?: string | RegExp;
43
+ });
44
+ getMessagesInternal(): I18nLocaleMessageDictionary;
45
+ }
46
+ export declare class LocaleMessages {
47
+ readonly localeMessages: LocaleMessage[];
48
+ constructor(localeMessages: LocaleMessage[]);
49
+ get locales(): string[];
50
+ isEmpty(): boolean;
51
+ findExistLocaleMessage(fullpath: string): LocaleMessage | null;
52
+ findBlockLocaleMessage(block: VAST.VElement): BlockLocaleMessage | null;
53
+ findMissingPath(key: string): string | null;
54
+ }