@itcase/lint 1.1.97 → 1.1.99
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/CHANGELOG.md +18 -0
- package/README.md +50 -4
- package/dist/eslint/plugin.d.ts +17 -0
- package/dist/eslint/react/dataTestIdPlugin/example.d.ts +13 -0
- package/dist/eslint/react/dataTestIdPlugin/extra.d.ts +8 -0
- package/dist/eslint/react/dataTestIdPlugin/interface.d.ts +12 -0
- package/dist/eslint/react/dataTestIdPlugin/plugin.d.ts +46 -0
- package/dist/eslint/restrictWords/config.d.ts +11 -0
- package/dist/eslint/restrictWords/index.d.ts +6 -0
- package/dist/eslint/restrictWords.js +79 -0
- package/dist/eslint/storybook/index.d.ts +19 -1
- package/dist/eslint/storybook/metaParametersDesign/constants.d.ts +12 -0
- package/dist/eslint/storybook/metaParametersDesign/extra.d.ts +8 -0
- package/dist/eslint/storybook/metaParametersDesign/interface.d.ts +6 -0
- package/dist/eslint/storybook/metaParametersDesign/plugin.d.ts +12 -0
- package/dist/eslint/storybook/metaParametersDesign/rule.d.ts +5 -0
- package/dist/eslint/storybook/metaParametersDesign/ruleVisitors.d.ts +3 -0
- package/dist/eslint/storybook/metaParametersDesign/utils.d.ts +6 -0
- package/dist/eslint/storybook.js +3 -10
- package/dist/eslint/utils/createPlugin.d.ts +14 -0
- package/dist/eslint/utils/createRuleCreator.d.ts +5 -0
- package/dist/eslint/utils/types.d.ts +4 -0
- package/dist/eslint.js +10 -278
- package/dist/index_CChA61aj.js +434 -0
- package/dist/stylelint.js +1 -1
- package/package.json +28 -25
- package/dist/eslint/customPlugins/dataTestIdPlugin/extra.d.ts +0 -18
- package/dist/eslint/customPlugins/dataTestIdPlugin/plugin.d.ts +0 -40
- /package/dist/eslint/{customPlugins → react}/dataTestIdPlugin/constants.d.ts +0 -0
- /package/dist/eslint/{customPlugins → react}/dataTestIdPlugin/rule.d.ts +0 -0
- /package/dist/eslint/{customPlugins → react}/dataTestIdPlugin/rule.test.d.ts +0 -0
- /package/dist/eslint/{customPlugins → react}/dataTestIdPlugin/ruleVisitors.d.ts +0 -0
- /package/dist/eslint/{customPlugins → react}/dataTestIdPlugin/utils.d.ts +0 -0
- /package/dist/eslint/{customPlugins/dataTestIdPlugin/example.d.ts → storybook/metaParametersDesign/rule.test.d.ts} +0 -0
- /package/dist/eslint/{utils.d.ts → utils/wrapArray.d.ts} +0 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import eslintStorybook from 'eslint-plugin-storybook';
|
|
2
|
+
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
3
|
+
|
|
4
|
+
const DOC_BASE = 'https://github.com/ITCase/itcase-lint/tree/main/src/eslint';
|
|
5
|
+
function createRuleCreator(pluginPath) {
|
|
6
|
+
return ESLintUtils.RuleCreator((name) => pluginPath ? `${DOC_BASE}/${pluginPath}#${name}` : '');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const createRule$1 = createRuleCreator('react/dataTestIdPlugin');
|
|
10
|
+
const ruleName$1 = 'react-data-test-id';
|
|
11
|
+
// Use a shared namespace for our custom rules.
|
|
12
|
+
const pluginName$1 = 'itcase-lint';
|
|
13
|
+
const defaultOptions$1 = [
|
|
14
|
+
{
|
|
15
|
+
appendElementNamesToCheck: null,
|
|
16
|
+
overrideElementNamesToCheck: null,
|
|
17
|
+
overrideElementNamesToIgnore: null,
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const MESSAGE_IDS$1 = {
|
|
22
|
+
missingAttribute: 'missingAttribute',
|
|
23
|
+
missingAttributeValue: 'missingAttributeValue',
|
|
24
|
+
};
|
|
25
|
+
const MESSAGES$1 = {
|
|
26
|
+
[MESSAGE_IDS$1.missingAttribute]: 'JSX element is missing the required "{{propName}}" attribute.',
|
|
27
|
+
[MESSAGE_IDS$1.missingAttributeValue]: 'JSX element has a "{{propName}}" attribute with a missing value.',
|
|
28
|
+
};
|
|
29
|
+
const ASSERT_DEFAULT_MESSAGE = 'Assert violation';
|
|
30
|
+
/**
|
|
31
|
+
* Property name to check for in JSX elements.
|
|
32
|
+
*/
|
|
33
|
+
const PROP_TO_CHECK_BY_COMPONENT_TYPE = {
|
|
34
|
+
CUSTOM: {
|
|
35
|
+
name: 'dataTestId'},
|
|
36
|
+
HTML: {
|
|
37
|
+
name: 'data-test-id'},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Custom element names to which the rule should apply.
|
|
41
|
+
* If the array is empty, the rule applies to all JSX elements.
|
|
42
|
+
*/
|
|
43
|
+
const ELEMENT_NAMES_TO_CHECK = [
|
|
44
|
+
'Group',
|
|
45
|
+
'Modal',
|
|
46
|
+
'Drawer',
|
|
47
|
+
'ModalSheetBottom',
|
|
48
|
+
'Grid',
|
|
49
|
+
'Flex',
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Custom element names to ignore by the rule.
|
|
53
|
+
*/
|
|
54
|
+
const ELEMENT_NAMES_TO_IGNORE = [
|
|
55
|
+
// Element to ignore for testing purposes
|
|
56
|
+
'IgnoredElement',
|
|
57
|
+
// Html element from Next.js
|
|
58
|
+
'Html',
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
/** Throw an error if the condition is falsy */
|
|
62
|
+
function assert(condition) {
|
|
63
|
+
if (!condition) {
|
|
64
|
+
throw new Error(ASSERT_DEFAULT_MESSAGE);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Extract name from a string or Identifier node */
|
|
68
|
+
function extractNameFromPossibleIdentifier(nodeOrName) {
|
|
69
|
+
if (typeof nodeOrName === 'string') {
|
|
70
|
+
return nodeOrName;
|
|
71
|
+
}
|
|
72
|
+
return nodeOrName.name;
|
|
73
|
+
}
|
|
74
|
+
/** Get name items of functions and variables that wraps the given node */
|
|
75
|
+
const getFunctionOrVariableAncestorNameItems = (context, node) => {
|
|
76
|
+
const ancestorNodes = context.sourceCode.getAncestors(node);
|
|
77
|
+
const functionOrVariableNodes = ancestorNodes.filter((ancestor) => {
|
|
78
|
+
return (ancestor.type === AST_NODE_TYPES.FunctionExpression ||
|
|
79
|
+
ancestor.type === AST_NODE_TYPES.FunctionDeclaration ||
|
|
80
|
+
ancestor.type === AST_NODE_TYPES.VariableDeclaration);
|
|
81
|
+
});
|
|
82
|
+
const nullableNameItems = functionOrVariableNodes.map((node) => {
|
|
83
|
+
if (node.type === AST_NODE_TYPES.FunctionDeclaration ||
|
|
84
|
+
node.type === AST_NODE_TYPES.FunctionExpression) {
|
|
85
|
+
if (node.id !== null) {
|
|
86
|
+
return {
|
|
87
|
+
name: node.id.name,
|
|
88
|
+
kind: 'function',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (node.type === AST_NODE_TYPES.VariableDeclaration) {
|
|
93
|
+
const firstDeclaration = node.declarations[0];
|
|
94
|
+
if (firstDeclaration.id.type === AST_NODE_TYPES.Identifier) {
|
|
95
|
+
return {
|
|
96
|
+
name: firstDeclaration.id.name,
|
|
97
|
+
kind: 'variable',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
});
|
|
103
|
+
const nameItems = nullableNameItems.filter((item) => item !== null);
|
|
104
|
+
return nameItems;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const handleReturnStatement = (context, returnStatementNode, options) => {
|
|
108
|
+
const { elementNamesToCheck, elementNamesToIgnore } = options;
|
|
109
|
+
// We only care about return statements that return JSX elements
|
|
110
|
+
assert(returnStatementNode.argument);
|
|
111
|
+
assert(returnStatementNode.argument.type === AST_NODE_TYPES.JSXElement);
|
|
112
|
+
const openingElement = returnStatementNode.argument.openingElement;
|
|
113
|
+
// Something is wrong if it's not a JSXIdentifier
|
|
114
|
+
assert(openingElement.name.type === AST_NODE_TYPES.JSXIdentifier);
|
|
115
|
+
const elementName = openingElement.name.name;
|
|
116
|
+
const isIgnoredElement = elementNamesToIgnore.includes(elementName);
|
|
117
|
+
// Ignore elements that are in the ignore list
|
|
118
|
+
assert(!isIgnoredElement);
|
|
119
|
+
const isLowerCasedName = elementName[0] === elementName[0].toLowerCase();
|
|
120
|
+
const isElementToCheck = elementNamesToCheck.includes(elementName);
|
|
121
|
+
const isAllElementsToCheck = elementNamesToCheck.length === 0;
|
|
122
|
+
// We only care about lowercase elements or specific Elements
|
|
123
|
+
assert(isLowerCasedName || isElementToCheck || isAllElementsToCheck);
|
|
124
|
+
// Determine which prop name we are looking for
|
|
125
|
+
const propNameWeLookingFor = isLowerCasedName
|
|
126
|
+
? PROP_TO_CHECK_BY_COMPONENT_TYPE.HTML
|
|
127
|
+
: PROP_TO_CHECK_BY_COMPONENT_TYPE.CUSTOM;
|
|
128
|
+
// Try to find the prop we are looking for
|
|
129
|
+
const propNodeWeLookingFor = openingElement.attributes.find((attr) => {
|
|
130
|
+
// Ignore spread attributes
|
|
131
|
+
if (attr.type === AST_NODE_TYPES.JSXAttribute) {
|
|
132
|
+
const attributeName = extractNameFromPossibleIdentifier(attr.name.name);
|
|
133
|
+
return propNameWeLookingFor.name === attributeName;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
const ancestorNameItems = getFunctionOrVariableAncestorNameItems(context, returnStatementNode);
|
|
137
|
+
// Get the nearest ancestor name as the component name
|
|
138
|
+
const parentComponentNameItem = ancestorNameItems.at(-1);
|
|
139
|
+
// Something is wrong if there is no component name
|
|
140
|
+
assert(parentComponentNameItem);
|
|
141
|
+
if (!propNodeWeLookingFor) {
|
|
142
|
+
// If we reach here - the prop is missing - report it
|
|
143
|
+
context.report({
|
|
144
|
+
messageId: MESSAGE_IDS$1.missingAttribute,
|
|
145
|
+
fix: (fixer) => {
|
|
146
|
+
const propName = propNameWeLookingFor.name;
|
|
147
|
+
const parentName = parentComponentNameItem.name;
|
|
148
|
+
// Insert the missing prop
|
|
149
|
+
if (parentComponentNameItem.kind === 'function') {
|
|
150
|
+
return fixer.insertTextAfter(openingElement.name, ' ' + `${propName}={${parentName}.name}`);
|
|
151
|
+
}
|
|
152
|
+
if (parentComponentNameItem.kind === 'variable') {
|
|
153
|
+
return fixer.insertTextAfter(openingElement.name, ' ' + `${propName}="${parentName}"`);
|
|
154
|
+
}
|
|
155
|
+
assert(false);
|
|
156
|
+
},
|
|
157
|
+
data: {
|
|
158
|
+
propName: propNameWeLookingFor.name,
|
|
159
|
+
},
|
|
160
|
+
node: openingElement,
|
|
161
|
+
});
|
|
162
|
+
assert(false);
|
|
163
|
+
}
|
|
164
|
+
// At this moment we only care about prop without value
|
|
165
|
+
assert(!propNodeWeLookingFor.value);
|
|
166
|
+
// If we reach here - the prop exists but has no value - report it
|
|
167
|
+
context.report({
|
|
168
|
+
messageId: MESSAGE_IDS$1.missingAttributeValue,
|
|
169
|
+
fix: (fixer) => {
|
|
170
|
+
const propName = propNameWeLookingFor.name;
|
|
171
|
+
const parentName = parentComponentNameItem.name;
|
|
172
|
+
// Replace incomplete prop with complete one
|
|
173
|
+
if (parentComponentNameItem.kind === 'function') {
|
|
174
|
+
return fixer.replaceText(propNodeWeLookingFor, `${propName}={${parentName}.name}`);
|
|
175
|
+
}
|
|
176
|
+
if (parentComponentNameItem.kind === 'variable') {
|
|
177
|
+
return fixer.replaceText(propNodeWeLookingFor, `${propName}="${parentName}"`);
|
|
178
|
+
}
|
|
179
|
+
assert(false);
|
|
180
|
+
},
|
|
181
|
+
data: {
|
|
182
|
+
propName: propNameWeLookingFor.name,
|
|
183
|
+
},
|
|
184
|
+
node: openingElement,
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
const ruleVisitors$1 = (context, optionsWithDefault) => {
|
|
188
|
+
const [options] = optionsWithDefault;
|
|
189
|
+
const { appendElementNamesToCheck, overrideElementNamesToCheck, overrideElementNamesToIgnore, } = options;
|
|
190
|
+
let elementNamesToCheck = ELEMENT_NAMES_TO_CHECK.slice();
|
|
191
|
+
let elementNamesToIgnore = ELEMENT_NAMES_TO_IGNORE.slice();
|
|
192
|
+
// Override default element names
|
|
193
|
+
if (overrideElementNamesToCheck) {
|
|
194
|
+
elementNamesToCheck = overrideElementNamesToCheck.slice();
|
|
195
|
+
}
|
|
196
|
+
// Override default element names
|
|
197
|
+
if (overrideElementNamesToIgnore) {
|
|
198
|
+
elementNamesToIgnore = overrideElementNamesToIgnore.slice();
|
|
199
|
+
}
|
|
200
|
+
// Append additional element names
|
|
201
|
+
if (appendElementNamesToCheck) {
|
|
202
|
+
elementNamesToCheck.push(...appendElementNamesToCheck);
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
// Iterate over all return statements
|
|
206
|
+
[AST_NODE_TYPES.ReturnStatement]: (node) => {
|
|
207
|
+
try {
|
|
208
|
+
handleReturnStatement(context, node, {
|
|
209
|
+
elementNamesToCheck,
|
|
210
|
+
elementNamesToIgnore,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
// Only log errors that are not from assert checks.
|
|
215
|
+
// Assert errors are used for early exit.
|
|
216
|
+
if (error instanceof Error &&
|
|
217
|
+
error.message === ASSERT_DEFAULT_MESSAGE) {
|
|
218
|
+
// Ignore assert errors
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// Log other errors
|
|
222
|
+
console.log(`${pluginName$1} visitor error:`, error);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const ruleMeta$1 = {
|
|
229
|
+
type: 'suggestion',
|
|
230
|
+
messages: MESSAGES$1,
|
|
231
|
+
docs: {
|
|
232
|
+
description: '',
|
|
233
|
+
},
|
|
234
|
+
fixable: 'code',
|
|
235
|
+
schema: [
|
|
236
|
+
{
|
|
237
|
+
type: 'object',
|
|
238
|
+
additionalProperties: false,
|
|
239
|
+
properties: {
|
|
240
|
+
appendElementNamesToCheck: {
|
|
241
|
+
anyOf: [
|
|
242
|
+
{ type: 'array', items: { type: 'string' } },
|
|
243
|
+
{ type: 'null' },
|
|
244
|
+
],
|
|
245
|
+
default: defaultOptions$1[0].appendElementNamesToCheck,
|
|
246
|
+
},
|
|
247
|
+
overrideElementNamesToCheck: {
|
|
248
|
+
anyOf: [
|
|
249
|
+
{ type: 'array', items: { type: 'string' } },
|
|
250
|
+
{ type: 'null' },
|
|
251
|
+
],
|
|
252
|
+
default: defaultOptions$1[0].overrideElementNamesToCheck,
|
|
253
|
+
},
|
|
254
|
+
overrideElementNamesToIgnore: {
|
|
255
|
+
anyOf: [
|
|
256
|
+
{ type: 'array', items: { type: 'string' } },
|
|
257
|
+
{ type: 'null' },
|
|
258
|
+
],
|
|
259
|
+
default: defaultOptions$1[0].overrideElementNamesToIgnore,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
const rule$1 = createRule$1({
|
|
266
|
+
name: ruleName$1,
|
|
267
|
+
create: ruleVisitors$1,
|
|
268
|
+
defaultOptions: defaultOptions$1,
|
|
269
|
+
meta: ruleMeta$1,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const createRule = createRuleCreator('storybook/metaParametersDesign');
|
|
273
|
+
const ruleName = 'storybook-meta-parameters-design';
|
|
274
|
+
const pluginName = 'itcase-lint';
|
|
275
|
+
const defaultOptions = [];
|
|
276
|
+
|
|
277
|
+
const MESSAGE_IDS = {
|
|
278
|
+
missingOrEmptyUrl: 'missingOrEmptyUrl',
|
|
279
|
+
typeMustBeFigma: 'typeMustBeFigma',
|
|
280
|
+
urlMustContainFigma: 'urlMustContainFigma',
|
|
281
|
+
};
|
|
282
|
+
const MESSAGES = {
|
|
283
|
+
[MESSAGE_IDS.missingOrEmptyUrl]: 'parameters.design.url обязателен и не должен быть пустым.',
|
|
284
|
+
[MESSAGE_IDS.typeMustBeFigma]: 'parameters.design.type должен быть "figma".',
|
|
285
|
+
[MESSAGE_IDS.urlMustContainFigma]: 'parameters.design.url должен содержать ссылку на figma.com.',
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
function getPropertyName(key) {
|
|
289
|
+
if (key.type === AST_NODE_TYPES.Identifier) {
|
|
290
|
+
return key.name;
|
|
291
|
+
}
|
|
292
|
+
if (key.type === AST_NODE_TYPES.Literal && typeof key.value === 'string') {
|
|
293
|
+
return key.value;
|
|
294
|
+
}
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
function findProperty(node, name) {
|
|
298
|
+
return node.properties.find((prop) => {
|
|
299
|
+
if (prop.type !== AST_NODE_TYPES.Property)
|
|
300
|
+
return false;
|
|
301
|
+
return getPropertyName(prop.key) === name;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function getStringLiteralValue(node) {
|
|
305
|
+
if (node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string') {
|
|
306
|
+
return node.value;
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
function resolveMetaObject(declaration, sourceCode) {
|
|
311
|
+
if (declaration.type === AST_NODE_TYPES.ObjectExpression) {
|
|
312
|
+
return declaration;
|
|
313
|
+
}
|
|
314
|
+
if (declaration.type === AST_NODE_TYPES.Identifier) {
|
|
315
|
+
const name = declaration.name;
|
|
316
|
+
for (const statement of sourceCode.body) {
|
|
317
|
+
if (statement.type === AST_NODE_TYPES.VariableDeclaration) {
|
|
318
|
+
for (const decl of statement.declarations) {
|
|
319
|
+
const init = decl.init;
|
|
320
|
+
if (decl.id.type === AST_NODE_TYPES.Identifier &&
|
|
321
|
+
decl.id.name === name &&
|
|
322
|
+
init != null &&
|
|
323
|
+
init.type === AST_NODE_TYPES.ObjectExpression) {
|
|
324
|
+
return init;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const FIGMA_DOMAIN = 'figma.com';
|
|
334
|
+
const ruleVisitors = (context, optionsWithDefault) => {
|
|
335
|
+
const sourceCode = context.sourceCode.ast;
|
|
336
|
+
return {
|
|
337
|
+
ExportDefaultDeclaration(node) {
|
|
338
|
+
const metaObject = resolveMetaObject(node.declaration, sourceCode);
|
|
339
|
+
if (!metaObject)
|
|
340
|
+
return;
|
|
341
|
+
const parametersProp = findProperty(metaObject, 'parameters');
|
|
342
|
+
if (!parametersProp)
|
|
343
|
+
return;
|
|
344
|
+
const parametersValue = parametersProp.value;
|
|
345
|
+
if (parametersValue.type !== AST_NODE_TYPES.ObjectExpression)
|
|
346
|
+
return;
|
|
347
|
+
const designProp = findProperty(parametersValue, 'design');
|
|
348
|
+
if (!designProp) {
|
|
349
|
+
context.report({
|
|
350
|
+
messageId: MESSAGE_IDS.missingOrEmptyUrl,
|
|
351
|
+
node: parametersProp,
|
|
352
|
+
});
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const designValue = designProp.value;
|
|
356
|
+
if (designValue.type !== AST_NODE_TYPES.ObjectExpression) {
|
|
357
|
+
context.report({
|
|
358
|
+
messageId: MESSAGE_IDS.missingOrEmptyUrl,
|
|
359
|
+
node: designProp,
|
|
360
|
+
});
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const typeProp = findProperty(designValue, 'type');
|
|
364
|
+
const typeStr = typeProp
|
|
365
|
+
? getStringLiteralValue(typeProp.value)
|
|
366
|
+
: undefined;
|
|
367
|
+
if (typeStr !== 'figma') {
|
|
368
|
+
context.report({
|
|
369
|
+
messageId: MESSAGE_IDS.typeMustBeFigma,
|
|
370
|
+
node: designProp,
|
|
371
|
+
});
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
const urlProp = findProperty(designValue, 'url');
|
|
375
|
+
const urlStr = urlProp ? getStringLiteralValue(urlProp.value) : undefined;
|
|
376
|
+
if (urlStr === undefined || urlStr.trim() === '') {
|
|
377
|
+
context.report({
|
|
378
|
+
messageId: MESSAGE_IDS.missingOrEmptyUrl,
|
|
379
|
+
node: designProp,
|
|
380
|
+
});
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (!urlStr.includes(FIGMA_DOMAIN)) {
|
|
384
|
+
context.report({
|
|
385
|
+
messageId: MESSAGE_IDS.urlMustContainFigma,
|
|
386
|
+
node: urlProp ?? designProp,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const ruleMeta = {
|
|
394
|
+
type: 'suggestion',
|
|
395
|
+
messages: MESSAGES,
|
|
396
|
+
docs: {
|
|
397
|
+
description: 'Require parameters.design.url to be non-empty and contain a figma.com link.',
|
|
398
|
+
},
|
|
399
|
+
schema: [],
|
|
400
|
+
};
|
|
401
|
+
const rule = createRule({
|
|
402
|
+
name: ruleName,
|
|
403
|
+
create: ruleVisitors,
|
|
404
|
+
defaultOptions: defaultOptions,
|
|
405
|
+
meta: ruleMeta,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
const itcaseLintPlugin = {
|
|
409
|
+
meta: {
|
|
410
|
+
name: pluginName$1,
|
|
411
|
+
version: '1.0.0',
|
|
412
|
+
},
|
|
413
|
+
processors: {},
|
|
414
|
+
rules: {
|
|
415
|
+
[ruleName$1]: rule$1,
|
|
416
|
+
[ruleName]: rule,
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
// eslint-disable-next-line import/no-default-export
|
|
421
|
+
var storybookConfig = [
|
|
422
|
+
{
|
|
423
|
+
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],
|
|
424
|
+
plugins: {
|
|
425
|
+
[pluginName]: itcaseLintPlugin,
|
|
426
|
+
storybook: eslintStorybook,
|
|
427
|
+
},
|
|
428
|
+
rules: {
|
|
429
|
+
[`${pluginName}/${ruleName}`]: 'warn',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
];
|
|
433
|
+
|
|
434
|
+
export { itcaseLintPlugin as i, pluginName$1 as p, ruleName$1 as r, storybookConfig as s };
|
package/dist/stylelint.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/lint",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.99",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "Code style linter configuration presets",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=22"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "npm run build-js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"prepack": "NODE_ENV=production npm run build",
|
|
15
15
|
"pre-commit": "npm run typecheck",
|
|
16
16
|
"semantic-release": "semantic-release",
|
|
17
|
-
"test": "npx tsx --test --test-reporter=
|
|
17
|
+
"test": "npx tsx --test --test-reporter=spec src/**/*.test.ts",
|
|
18
18
|
"typecheck": "tsc --noEmit"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"@figma/eslint-plugin-figma-plugins": "^1.0.0",
|
|
52
52
|
"@eslint/js": "^10.0.1",
|
|
53
53
|
"@eslint/markdown": "^7.5.1",
|
|
54
|
-
"@html-eslint/eslint-plugin": "^0.
|
|
55
|
-
"@html-eslint/parser": "^0.
|
|
54
|
+
"@html-eslint/eslint-plugin": "^0.58.0",
|
|
55
|
+
"@html-eslint/parser": "^0.58.0",
|
|
56
56
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
58
|
-
"@typescript-eslint/parser": "^8.
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
58
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
59
59
|
"eslint": "9.39.2",
|
|
60
60
|
"eslint-config-prettier": "^10.1.8",
|
|
61
61
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
@@ -63,49 +63,52 @@
|
|
|
63
63
|
"eslint-plugin-import": "^2.32.0",
|
|
64
64
|
"eslint-plugin-json": "^4.0.1",
|
|
65
65
|
"eslint-plugin-mobx": "^0.0.13",
|
|
66
|
-
"eslint-plugin-n": "^17.
|
|
66
|
+
"eslint-plugin-n": "^17.24.0",
|
|
67
67
|
"eslint-plugin-node": "^11.1.0",
|
|
68
|
-
"eslint-plugin-perfectionist": "^5.
|
|
68
|
+
"eslint-plugin-perfectionist": "^5.6.0",
|
|
69
69
|
"eslint-plugin-prettier": "^5.5.5",
|
|
70
70
|
"eslint-plugin-promise": "^7.2.1",
|
|
71
71
|
"eslint-plugin-react": "^7.37.5",
|
|
72
72
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
73
73
|
"eslint-plugin-react-native": "^5.0.0",
|
|
74
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
75
|
-
"eslint-plugin-storybook": "^10.2.
|
|
76
|
-
"expo-modules-autolinking": "^
|
|
77
|
-
"globals": "^17.
|
|
74
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
75
|
+
"eslint-plugin-storybook": "^10.2.15",
|
|
76
|
+
"expo-modules-autolinking": "^55.0.8",
|
|
77
|
+
"globals": "^17.4.0",
|
|
78
78
|
"prettier": "^3.8.1",
|
|
79
|
-
"stylelint": "^17.
|
|
79
|
+
"stylelint": "^17.4.0",
|
|
80
80
|
"stylelint-config-standard": "^40.0.0",
|
|
81
81
|
"stylelint-no-unsupported-browser-features": "^8.1.1",
|
|
82
82
|
"stylelint-order": "^7.0.1",
|
|
83
83
|
"stylelint-prettier": "^5.0.3",
|
|
84
|
-
"typescript-eslint": "^8.
|
|
84
|
+
"typescript-eslint": "^8.56.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@commitlint/cli": "^20.4.
|
|
88
|
-
"@commitlint/config-conventional": "^20.4.
|
|
89
|
-
"@itcase/config": "^1.6.
|
|
87
|
+
"@commitlint/cli": "^20.4.3",
|
|
88
|
+
"@commitlint/config-conventional": "^20.4.3",
|
|
89
|
+
"@itcase/config": "^1.6.52",
|
|
90
90
|
"@rollup/plugin-alias": "^6.0.0",
|
|
91
|
-
"@rollup/plugin-babel": "^
|
|
91
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
92
92
|
"@rollup/plugin-image": "^3.0.3",
|
|
93
93
|
"@rollup/plugin-json": "^6.1.0",
|
|
94
94
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
95
|
-
"@rollup/plugin-terser": "^0.
|
|
95
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
96
96
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
97
|
-
"@types/node": "^25.
|
|
98
|
-
"@
|
|
99
|
-
"
|
|
97
|
+
"@types/node": "^25.3.3",
|
|
98
|
+
"@types/react": "^18.3.0",
|
|
99
|
+
"@typescript-eslint/rule-tester": "^8.56.1",
|
|
100
|
+
"conventional-changelog-conventionalcommits": "^9.3.0",
|
|
100
101
|
"del-cli": "^7.0.0",
|
|
101
102
|
"husky": "^9.1.7",
|
|
102
|
-
"lint-staged": "^16.2
|
|
103
|
-
"rollup": "4.
|
|
103
|
+
"lint-staged": "^16.3.2",
|
|
104
|
+
"rollup": "4.59.0",
|
|
104
105
|
"rollup-plugin-copy": "^3.5.0",
|
|
105
106
|
"rollup-plugin-dts": "^6.3.0",
|
|
106
107
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
108
|
+
"react": "^18.3.0",
|
|
107
109
|
"rollup-preserve-directives": "^1.1.3",
|
|
108
110
|
"semantic-release": "^25.0.3",
|
|
111
|
+
"storybook": "^10.2.15",
|
|
109
112
|
"tsx": "^4.21.0",
|
|
110
113
|
"typescript": "^5.9.3"
|
|
111
114
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
import { type MessageIds } from './constants';
|
|
3
|
-
declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
declare const ruleName = "data-test-id";
|
|
7
|
-
declare const pluginName = "data-test-id-plugin";
|
|
8
|
-
type Options = [
|
|
9
|
-
{
|
|
10
|
-
appendElementNamesToCheck?: string[] | null;
|
|
11
|
-
overrideElementNamesToCheck?: string[] | null;
|
|
12
|
-
overrideElementNamesToIgnore?: string[] | null;
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
declare const defaultOptions: Options;
|
|
16
|
-
type Context = Readonly<TSESLint.RuleContext<keyof MessageIds, Options>>;
|
|
17
|
-
type RuleVisitors = (context: Context, optionsWithDefault: Readonly<Options>) => TSESLint.RuleListener;
|
|
18
|
-
export { type Context, createRule, defaultOptions, type Options, pluginName, ruleName, type RuleVisitors, };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import parser from '@typescript-eslint/parser';
|
|
2
|
-
import { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
-
declare const pluginWithConfigs: {
|
|
4
|
-
configs: {
|
|
5
|
-
recommended: {
|
|
6
|
-
languageOptions: {
|
|
7
|
-
ecmaVersion: "latest";
|
|
8
|
-
parser: typeof parser;
|
|
9
|
-
};
|
|
10
|
-
plugins: {
|
|
11
|
-
"data-test-id-plugin": {
|
|
12
|
-
meta: {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
15
|
-
};
|
|
16
|
-
processors: {};
|
|
17
|
-
rules: {
|
|
18
|
-
"data-test-id": TSESLint.RuleModule<"missingAttribute" | "missingAttributeValue", import("./extra").Options, unknown, TSESLint.RuleListener> & {
|
|
19
|
-
name: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
rules: {
|
|
25
|
-
"data-test-id-plugin/data-test-id": "off";
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
meta: {
|
|
30
|
-
name: string;
|
|
31
|
-
version: string;
|
|
32
|
-
};
|
|
33
|
-
processors: {};
|
|
34
|
-
rules: {
|
|
35
|
-
"data-test-id": TSESLint.RuleModule<"missingAttribute" | "missingAttributeValue", import("./extra").Options, unknown, TSESLint.RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export default pluginWithConfigs;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|