@arcgis/eslint-config 5.1.0-next.61 → 5.1.0-next.63
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,4 +1,4 @@
|
|
|
1
|
-
import { m as makeEslintPlugin, l as luminaJsxExportName, a as luminaEntrypointName, b as luminaTestEntrypointName, s as sourceCodeDeclaresComponent, p as parsePropertyDecorator, c as getProperty, i as isGetterWithoutSetter, e as extractDeclareElementsInterface, d as isCreateEvent, h as hasDecorator, f as getName, j as checkForLuminaJsx, k as isBindThisCallee, g as getComponentDeclaration, u as unwrapExpression } from "../../estree-
|
|
1
|
+
import { m as makeEslintPlugin, l as luminaJsxExportName, a as luminaEntrypointName, b as luminaTestEntrypointName, s as sourceCodeDeclaresComponent, p as parsePropertyDecorator, c as getProperty, i as isGetterWithoutSetter, e as extractDeclareElementsInterface, d as isCreateEvent, h as hasDecorator, f as getName, j as checkForLuminaJsx, k as isBindThisCallee, g as getComponentDeclaration, u as unwrapExpression } from "../../estree-DaJTApwe.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as makeEslintPlugin, e as extractDeclareElementsInterface, g as getComponentDeclaration } from "../../estree-
|
|
1
|
+
import { m as makeEslintPlugin, e as extractDeclareElementsInterface, g as getComponentDeclaration } from "../../estree-DaJTApwe.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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/eslint-config",
|
|
3
|
-
"version": "5.1.0-next.
|
|
4
|
-
"description": "ESLint configuration for
|
|
3
|
+
"version": "5.1.0-next.63",
|
|
4
|
+
"description": "ESLint configuration for WebGIS SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"tslib": "^2.8.1",
|
|
36
36
|
"typescript": "~5.9.3",
|
|
37
37
|
"typescript-eslint": "^8.46.3",
|
|
38
|
-
"@arcgis/toolkit": "5.1.0-next.
|
|
38
|
+
"@arcgis/toolkit": "5.1.0-next.63"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"eslint": "^9.39.1"
|
package/dist/estree-kBWxXj93.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
2
|
-
const version = "5.1.0-next.60";
|
|
3
|
-
const packageJson = {
|
|
4
|
-
version
|
|
5
|
-
};
|
|
6
|
-
function makeEslintPlugin(pluginName, urlCreator) {
|
|
7
|
-
const rules = [];
|
|
8
|
-
const creator = ESLintUtils.RuleCreator(urlCreator);
|
|
9
|
-
return {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
-
createRule(rule) {
|
|
12
|
-
const { meta, name, ...rest } = rule;
|
|
13
|
-
const docs = { ...meta.docs, name };
|
|
14
|
-
const ruleModule = creator({ ...rest, meta: { ...meta, docs }, name });
|
|
15
|
-
rules.push(ruleModule);
|
|
16
|
-
return ruleModule;
|
|
17
|
-
},
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
19
|
-
finalize() {
|
|
20
|
-
const config = {
|
|
21
|
-
rules: Object.fromEntries(
|
|
22
|
-
rules.map((rule) => [`${pluginName}/${rule.meta.docs.name}`, rule.meta.docs.defaultLevel])
|
|
23
|
-
)
|
|
24
|
-
};
|
|
25
|
-
const plugin = {
|
|
26
|
-
meta: { name: `@arcgis/eslint-plugin-${pluginName}`, version: packageJson.version },
|
|
27
|
-
configs: {
|
|
28
|
-
recommended: config
|
|
29
|
-
},
|
|
30
|
-
rules: Object.fromEntries(rules.map((rule) => [rule.meta.docs.name, rule]))
|
|
31
|
-
};
|
|
32
|
-
config.plugins = {
|
|
33
|
-
[pluginName]: plugin
|
|
34
|
-
};
|
|
35
|
-
return plugin;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const unwrapExpression = (expression) => expression.type === AST_NODE_TYPES.TSAsExpression || expression.type === AST_NODE_TYPES.TSNonNullExpression || expression.type === AST_NODE_TYPES.TSSatisfiesExpression ? unwrapExpression(expression.expression) : expression;
|
|
40
|
-
const luminaEntrypointName = "@arcgis/lumina";
|
|
41
|
-
const luminaTestEntrypointName = "@arcgis/lumina-compiler/testing";
|
|
42
|
-
const luminaJsxExportName = "h";
|
|
43
|
-
function checkForLuminaJsx() {
|
|
44
|
-
const ImportDeclaration = (node) => {
|
|
45
|
-
if (node.source.value !== luminaEntrypointName) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (const specifier of node.specifiers) {
|
|
49
|
-
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === luminaJsxExportName || specifier.imported.type === AST_NODE_TYPES.Literal && specifier.imported.value === luminaJsxExportName)) {
|
|
50
|
-
withProperty.isLuminaJsx = true;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const withProperty = ImportDeclaration;
|
|
56
|
-
return withProperty;
|
|
57
|
-
}
|
|
58
|
-
function hasDecorator(node, decoratorName) {
|
|
59
|
-
return node.decorators.some(
|
|
60
|
-
(decorator) => decorator.expression.type === AST_NODE_TYPES.CallExpression && decorator.expression.callee.type === AST_NODE_TYPES.Identifier && decorator.expression.callee.name === decoratorName
|
|
61
|
-
) ?? false;
|
|
62
|
-
}
|
|
63
|
-
function extractDeclareElementsInterface(node) {
|
|
64
|
-
return node.kind === "global" ? node.body.body.find(
|
|
65
|
-
(node2) => node2.type === AST_NODE_TYPES.TSInterfaceDeclaration && node2.id.name === "DeclareElements"
|
|
66
|
-
) : void 0;
|
|
67
|
-
}
|
|
68
|
-
function getComponentDeclaration(node) {
|
|
69
|
-
for (const member of node.body.body) {
|
|
70
|
-
if (member.type !== AST_NODE_TYPES.TSPropertySignature) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const type = member.typeAnnotation?.typeAnnotation;
|
|
74
|
-
if (type?.type !== AST_NODE_TYPES.TSTypeReference || type.typeName.type !== AST_NODE_TYPES.Identifier) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (member.key.type !== AST_NODE_TYPES.Literal) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
return member;
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const sourceCodeDeclaresComponent = (sourceCode) => sourceCode.text.includes("interface DeclareElements");
|
|
85
|
-
function isCreateEvent(node) {
|
|
86
|
-
return node.value?.type === AST_NODE_TYPES.CallExpression && node.value.callee.type === AST_NODE_TYPES.Identifier && node.value.callee.name === "createEvent" && !node.static;
|
|
87
|
-
}
|
|
88
|
-
const getProperty = (properties, name) => properties?.find(
|
|
89
|
-
(option) => option.type === AST_NODE_TYPES.Property && option.key.type === AST_NODE_TYPES.Identifier && option.key.name === name
|
|
90
|
-
)?.value;
|
|
91
|
-
function isGetterWithoutSetter(node) {
|
|
92
|
-
const isGetter = node.type === AST_NODE_TYPES.MethodDefinition && node.kind === "get";
|
|
93
|
-
if (!isGetter) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
const index = node.parent.body.indexOf(node);
|
|
97
|
-
const previousNode = node.parent.body.at(index - 1);
|
|
98
|
-
const nextNode = node.parent.body.at(index + 1);
|
|
99
|
-
const name = getName(node);
|
|
100
|
-
if (name === void 0) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
const previousIsSetter = previousNode?.type === AST_NODE_TYPES.MethodDefinition && previousNode.kind === "set" && getName(previousNode) === name;
|
|
104
|
-
if (previousIsSetter) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
const nextIsSetter = nextNode?.type === AST_NODE_TYPES.MethodDefinition && nextNode.kind === "set" && getName(nextNode) === name;
|
|
108
|
-
return !nextIsSetter;
|
|
109
|
-
}
|
|
110
|
-
function getName(node) {
|
|
111
|
-
if (node.key.type === AST_NODE_TYPES.Identifier) {
|
|
112
|
-
return node.key.name;
|
|
113
|
-
} else if (node.key.type === AST_NODE_TYPES.Literal && typeof node.key.value === "string") {
|
|
114
|
-
return node.key.value;
|
|
115
|
-
} else {
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function parsePropertyDecorator(decorator) {
|
|
120
|
-
const isPropertyDecorator = decorator.expression.type === AST_NODE_TYPES.CallExpression && decorator.expression.callee.type === AST_NODE_TYPES.Identifier && decorator.expression.callee.name === "property";
|
|
121
|
-
if (!isPropertyDecorator) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const callExpression = decorator?.expression.type === AST_NODE_TYPES.CallExpression ? decorator.expression : void 0;
|
|
125
|
-
if (callExpression === void 0) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const options = callExpression.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression ? callExpression.arguments[0] : void 0;
|
|
129
|
-
const properties = options?.properties;
|
|
130
|
-
return {
|
|
131
|
-
callExpression,
|
|
132
|
-
options,
|
|
133
|
-
properties
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function isBindThisCallee(callee) {
|
|
137
|
-
return callee.type === AST_NODE_TYPES.MemberExpression && // expression.identifier(this)
|
|
138
|
-
callee.property.type === AST_NODE_TYPES.Identifier && // expression.bind(this)
|
|
139
|
-
callee.property.name === "bind" && // expression.expression.bind(this)
|
|
140
|
-
callee.object.type === AST_NODE_TYPES.MemberExpression && // expression.identifier.bind(this)
|
|
141
|
-
callee.object.property.type === AST_NODE_TYPES.Identifier && // this.identifier.bind(this)
|
|
142
|
-
callee.object.object.type === AST_NODE_TYPES.ThisExpression;
|
|
143
|
-
}
|
|
144
|
-
export {
|
|
145
|
-
luminaEntrypointName as a,
|
|
146
|
-
luminaTestEntrypointName as b,
|
|
147
|
-
getProperty as c,
|
|
148
|
-
isCreateEvent as d,
|
|
149
|
-
extractDeclareElementsInterface as e,
|
|
150
|
-
getName as f,
|
|
151
|
-
getComponentDeclaration as g,
|
|
152
|
-
hasDecorator as h,
|
|
153
|
-
isGetterWithoutSetter as i,
|
|
154
|
-
checkForLuminaJsx as j,
|
|
155
|
-
isBindThisCallee as k,
|
|
156
|
-
luminaJsxExportName as l,
|
|
157
|
-
makeEslintPlugin as m,
|
|
158
|
-
parsePropertyDecorator as p,
|
|
159
|
-
sourceCodeDeclaresComponent as s,
|
|
160
|
-
unwrapExpression as u
|
|
161
|
-
};
|