@arcgis/eslint-config 5.0.0-next.3 → 5.0.0-next.30

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.
@@ -1,5 +1,5 @@
1
1
  import { ESLintUtils } from "@typescript-eslint/utils";
2
- const version = "5.0.0-next.3";
2
+ const version = "5.0.0-next.30";
3
3
  function makeEslintPlugin(pluginName, urlCreator) {
4
4
  const rules = [];
5
5
  const creator = ESLintUtils.RuleCreator(urlCreator);
@@ -1,4 +1,4 @@
1
- import { m as makeEslintPlugin } from "../../makePlugin-CnkyRdUm.js";
1
+ import { m as makeEslintPlugin } from "../../makePlugin-DofpGCSh.js";
2
2
  import { AST_NODE_TYPES, ESLintUtils, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
3
3
  import ts from "typescript";
4
4
  import { camelToKebab } from "@arcgis/toolkit/string";
@@ -2037,17 +2037,12 @@ plugin.createRule({
2037
2037
  noTagNameIdentifier: "Tag name must include a dash",
2038
2038
  unexpectedDeclareElementsEntry: "Unexpected entry in declare elements interface. Expected a property signature",
2039
2039
  unexpectedDeclarationType: "Unexpected declaration type. Expected component class identifier",
2040
- duplicateDeclaration: "The same component may only be assigned to one class name. If you need multiple tag names, consider sub-classing the component",
2040
+ duplicateDeclaration: "The same component may only be assigned to one class name. If you need multiple tag names, consider sub-classing the component",
2041
2041
  missingClassDeclaration: "Missing class declaration",
2042
2042
  unexpectedTypeArguments: "Unexpected type arguments in the component tag name declaration. Type arguments should be specified in the component class declaration",
2043
2043
  reservedTagName: "This is a reserved html element tag name. Declaring components with this name is forbidden by the custom elements specification.",
2044
- duplicateDeclareGlobal: `There should only be a single "declare global" block in a file. Declaring multiple components in a single file is supported, but they should share the same "declare global {" block. Example:
2045
- declare global {
2046
- interface DeclareElements {
2047
- "arcgis-test1": ArcgisTest1;
2048
- "arcgis-test2": ArcgisTest2;
2049
- }
2050
- }`,
2044
+ duplicateDeclareGlobal: `There should only be a single "declare global" block in a file.`,
2045
+ multipleDeclarations: `There should only be a single "DeclareElements" interface in a "declare global" block with a single component declaration inside. Create a separate file to define additional components.`,
2051
2046
  mustSubclass: "Lumina component is required to subclass LitElement or a subclass of LitElement",
2052
2047
  mustNotSubclassHtmlElement: "Lumina component is not allowed to subclass HTMLElement classes directly. Subclass LitElement or a subclass of LitElement instead",
2053
2048
  tagNameClassNameMismatch: 'The custom element tag name "{{tagName}}" does not seem to match the class name it is assigned to: "{{className}}". Make sure tag name and class name use the same characters in the same order (case insensitive, hyphens removed). {{namespaceNotice}}',
@@ -2090,123 +2085,130 @@ declare global {
2090
2085
  return;
2091
2086
  }
2092
2087
  seenDeclareGlobal = true;
2093
- luminaDeclarationInterface.body.body.forEach((member) => {
2094
- if (member.type !== AST_NODE_TYPES.TSPropertySignature) {
2095
- context.report({
2096
- messageId: "unexpectedDeclareElementsEntry",
2097
- node: member
2098
- });
2099
- return;
2100
- }
2101
- if (member.computed) {
2102
- context.report({
2103
- messageId: "noComputedTagName",
2104
- node: member.key
2105
- });
2106
- return;
2107
- }
2108
- if (member.key.type === AST_NODE_TYPES.Identifier) {
2109
- context.report({
2110
- messageId: "noTagNameIdentifier",
2111
- node: member.key
2112
- });
2113
- return;
2114
- }
2115
- if (typeof member.key.value !== "string") {
2116
- context.report({
2117
- messageId: "noNonStringTagName",
2118
- node: member.key
2119
- });
2120
- return;
2121
- }
2122
- const tagName = member.key.value;
2123
- let namespaceFreeTagName = tagName;
2124
- const namespaces = options[0].namespaces;
2125
- if (namespaces.length > 0) {
2126
- const namespace = namespaces.find((ns) => tagName.startsWith(ns));
2127
- if (namespace === void 0) {
2128
- context.report({
2129
- messageId: "requireNamespace",
2130
- node: member.key,
2131
- data: {
2132
- namespaces: namespaces.join(", ")
2133
- }
2134
- });
2135
- return;
2136
- } else {
2137
- namespaceFreeTagName = tagName.slice(namespace.length);
2138
- }
2139
- }
2140
- if (!tagName.includes("-")) {
2141
- context.report({
2142
- messageId: "missingHyphen",
2143
- node: member.key
2144
- });
2145
- return;
2146
- }
2147
- if (tagName.toLowerCase() !== tagName) {
2148
- context.report({
2149
- messageId: "lowercaseTagName",
2150
- node: member.key
2151
- });
2152
- return;
2153
- }
2154
- if (!reCustomElementName.test(tagName)) {
2088
+ const members = luminaDeclarationInterface.body.body;
2089
+ if (members.length !== 1) {
2090
+ context.report({
2091
+ messageId: "multipleDeclarations",
2092
+ node: luminaDeclarationInterface
2093
+ });
2094
+ return;
2095
+ }
2096
+ const member = members[0];
2097
+ if (member.type !== AST_NODE_TYPES.TSPropertySignature) {
2098
+ context.report({
2099
+ messageId: "unexpectedDeclareElementsEntry",
2100
+ node: member
2101
+ });
2102
+ return;
2103
+ }
2104
+ if (member.computed) {
2105
+ context.report({
2106
+ messageId: "noComputedTagName",
2107
+ node: member.key
2108
+ });
2109
+ return;
2110
+ }
2111
+ if (member.key.type === AST_NODE_TYPES.Identifier) {
2112
+ context.report({
2113
+ messageId: "noTagNameIdentifier",
2114
+ node: member.key
2115
+ });
2116
+ return;
2117
+ }
2118
+ if (typeof member.key.value !== "string") {
2119
+ context.report({
2120
+ messageId: "noNonStringTagName",
2121
+ node: member.key
2122
+ });
2123
+ return;
2124
+ }
2125
+ const tagName = member.key.value;
2126
+ let namespaceFreeTagName = tagName;
2127
+ const namespaces = options[0].namespaces;
2128
+ if (namespaces.length > 0) {
2129
+ const namespace = namespaces.find((ns) => tagName.startsWith(ns));
2130
+ if (namespace === void 0) {
2155
2131
  context.report({
2156
- messageId: "invalidTagName",
2132
+ messageId: "requireNamespace",
2157
2133
  node: member.key,
2158
2134
  data: {
2159
- regex: reCustomElementName.toString()
2135
+ namespaces: namespaces.join(", ")
2160
2136
  }
2161
2137
  });
2162
2138
  return;
2139
+ } else {
2140
+ namespaceFreeTagName = tagName.slice(namespace.length);
2163
2141
  }
2164
- if (blockListedCustomElementNames.has(tagName)) {
2165
- context.report({
2166
- messageId: "reservedTagName",
2167
- node: member.key
2168
- });
2169
- return;
2170
- }
2171
- const type = member.typeAnnotation?.typeAnnotation;
2172
- if (type?.type !== AST_NODE_TYPES.TSTypeReference || type.typeName.type !== AST_NODE_TYPES.Identifier) {
2173
- context.report({
2174
- messageId: "unexpectedDeclarationType",
2175
- node: type ?? member
2176
- });
2177
- return;
2178
- }
2179
- if (type.typeArguments !== void 0) {
2180
- context.report({
2181
- messageId: "unexpectedTypeArguments",
2182
- node: type
2183
- });
2184
- return;
2185
- }
2186
- const className = type.typeName.name;
2187
- const classNameFromTagName = tagNameToNormalizedClassName(tagName);
2188
- const classNameFromShortTagName = tagNameToNormalizedClassName(namespaceFreeTagName);
2189
- if (classNameFromTagName !== className.toLowerCase() && classNameFromShortTagName !== className.toLowerCase()) {
2190
- context.report({
2191
- messageId: "tagNameClassNameMismatch",
2192
- node: type.typeName,
2193
- data: {
2194
- tagName,
2195
- className,
2196
- namespaceNotice: namespaces.length > 0 ? `In addition, the following tag name prefixes are expected: ${namespaces.join(", ")}` : ""
2197
- }
2198
- });
2199
- return;
2200
- }
2201
- if (declaredComponents.has(className)) {
2202
- context.report({
2203
- messageId: "duplicateDeclaration",
2204
- node: type.typeName
2205
- });
2206
- return;
2207
- }
2208
- declaredComponents.set(className, type.typeName);
2209
- });
2142
+ }
2143
+ if (!tagName.includes("-")) {
2144
+ context.report({
2145
+ messageId: "missingHyphen",
2146
+ node: member.key
2147
+ });
2148
+ return;
2149
+ }
2150
+ if (tagName.toLowerCase() !== tagName) {
2151
+ context.report({
2152
+ messageId: "lowercaseTagName",
2153
+ node: member.key
2154
+ });
2155
+ return;
2156
+ }
2157
+ if (!reCustomElementName.test(tagName)) {
2158
+ context.report({
2159
+ messageId: "invalidTagName",
2160
+ node: member.key,
2161
+ data: {
2162
+ regex: reCustomElementName.toString()
2163
+ }
2164
+ });
2165
+ return;
2166
+ }
2167
+ if (blockListedCustomElementNames.has(tagName)) {
2168
+ context.report({
2169
+ messageId: "reservedTagName",
2170
+ node: member.key
2171
+ });
2172
+ return;
2173
+ }
2174
+ const type = member.typeAnnotation?.typeAnnotation;
2175
+ if (type?.type !== AST_NODE_TYPES.TSTypeReference || type.typeName.type !== AST_NODE_TYPES.Identifier) {
2176
+ context.report({
2177
+ messageId: "unexpectedDeclarationType",
2178
+ node: type ?? member
2179
+ });
2180
+ return;
2181
+ }
2182
+ if (type.typeArguments !== void 0) {
2183
+ context.report({
2184
+ messageId: "unexpectedTypeArguments",
2185
+ node: type
2186
+ });
2187
+ return;
2188
+ }
2189
+ const className = type.typeName.name;
2190
+ const classNameFromTagName = tagNameToNormalizedClassName(tagName);
2191
+ const classNameFromShortTagName = tagNameToNormalizedClassName(namespaceFreeTagName);
2192
+ if (classNameFromTagName !== className.toLowerCase() && classNameFromShortTagName !== className.toLowerCase()) {
2193
+ context.report({
2194
+ messageId: "tagNameClassNameMismatch",
2195
+ node: type.typeName,
2196
+ data: {
2197
+ tagName,
2198
+ className,
2199
+ namespaceNotice: namespaces.length > 0 ? `In addition, the following tag name prefixes are expected: ${namespaces.join(", ")}` : ""
2200
+ }
2201
+ });
2202
+ return;
2203
+ }
2204
+ if (declaredComponents.has(className)) {
2205
+ context.report({
2206
+ messageId: "duplicateDeclaration",
2207
+ node: type.typeName
2208
+ });
2209
+ return;
2210
+ }
2211
+ declaredComponents.set(className, type.typeName);
2210
2212
  },
2211
2213
  "ClassDeclaration"(node) {
2212
2214
  if (node.id !== null && declaredComponents.has(node.id.name)) {
@@ -3,6 +3,6 @@ type Options = [
3
3
  namespaces?: readonly string[];
4
4
  }
5
5
  ];
6
- type Messages = "duplicateDeclaration" | "duplicateDeclareGlobal" | "invalidTagName" | "lowercaseTagName" | "missingClassDeclaration" | "missingHyphen" | "mustNotSubclassHtmlElement" | "mustSubclass" | "noComputedTagName" | "noNonStringTagName" | "noTagNameIdentifier" | "requireNamespace" | "reservedTagName" | "tagNameClassNameMismatch" | "unexpectedDeclarationType" | "unexpectedDeclareElementsEntry" | "unexpectedTypeArguments";
6
+ type Messages = "duplicateDeclaration" | "duplicateDeclareGlobal" | "invalidTagName" | "lowercaseTagName" | "missingClassDeclaration" | "missingHyphen" | "multipleDeclarations" | "mustNotSubclassHtmlElement" | "mustSubclass" | "noComputedTagName" | "noNonStringTagName" | "noTagNameIdentifier" | "requireNamespace" | "reservedTagName" | "tagNameClassNameMismatch" | "unexpectedDeclarationType" | "unexpectedDeclareElementsEntry" | "unexpectedTypeArguments";
7
7
  declare const _default: import('@typescript-eslint/utils/ts-eslint').RuleModule<Messages, Options, import('../../utils/makePlugin').CommonDocs, import('@typescript-eslint/utils/ts-eslint').RuleListener>;
8
8
  export default _default;
@@ -1,4 +1,4 @@
1
- import { m as makeEslintPlugin } from "../../makePlugin-CnkyRdUm.js";
1
+ import { m as makeEslintPlugin } from "../../makePlugin-DofpGCSh.js";
2
2
  import { resolve } from "path/posix";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
  const plugin = makeEslintPlugin(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/eslint-config",
3
- "version": "5.0.0-next.3",
3
+ "version": "5.0.0-next.30",
4
4
  "description": "ESLint configuration for arcgis-web-components",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "license": "SEE LICENSE IN LICENSE.md",
22
22
  "dependencies": {
23
- "@arcgis/toolkit": "5.0.0-next.3",
23
+ "@arcgis/toolkit": "5.0.0-next.30",
24
24
  "@eslint/js": "^9.29.0",
25
25
  "@eslint/markdown": "^6.6.0",
26
26
  "@types/confusing-browser-globals": "^1.0.3",