@lvce-editor/eslint-plugin-virtual-dom 16.4.0 → 16.5.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 (2) hide show
  1. package/dist/index.js +72 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ const isStringLiteral = node => {
77
77
  return isLiteralNode(node) && typeof node.value === 'string';
78
78
  };
79
79
 
80
- const meta$a = {
80
+ const meta$b = {
81
81
  docs: {
82
82
  description: 'Require an explicit role on clickable virtual-dom div nodes'
83
83
  },
@@ -86,7 +86,7 @@ const meta$a = {
86
86
  },
87
87
  type: 'problem'
88
88
  };
89
- const create$a = context => {
89
+ const create$b = context => {
90
90
  return {
91
91
  ObjectExpression(node) {
92
92
  if (!isVirtualDomNode(node)) {
@@ -108,11 +108,11 @@ const create$a = context => {
108
108
 
109
109
  const clickableDivNeedsRole = {
110
110
  __proto__: null,
111
- create: create$a,
112
- meta: meta$a
111
+ create: create$b,
112
+ meta: meta$b
113
113
  };
114
114
 
115
- const meta$9 = {
115
+ const meta$a = {
116
116
  docs: {
117
117
  description: 'Disallow empty ARIA values in virtual-dom nodes'
118
118
  },
@@ -124,7 +124,7 @@ const meta$9 = {
124
124
  const isAriaProperty = name => {
125
125
  return /^aria[A-Z]/.test(name);
126
126
  };
127
- const create$9 = context => {
127
+ const create$a = context => {
128
128
  return {
129
129
  ObjectExpression(node) {
130
130
  if (!isVirtualDomNode(node)) {
@@ -149,11 +149,11 @@ const create$9 = context => {
149
149
 
150
150
  const noEmptyAria = {
151
151
  __proto__: null,
152
- create: create$9,
153
- meta: meta$9
152
+ create: create$a,
153
+ meta: meta$a
154
154
  };
155
155
 
156
- const meta$8 = {
156
+ const meta$9 = {
157
157
  docs: {
158
158
  description: 'Disallow empty className values in virtual-dom nodes'
159
159
  },
@@ -162,7 +162,7 @@ const meta$8 = {
162
162
  },
163
163
  type: 'problem'
164
164
  };
165
- const create$8 = context => {
165
+ const create$9 = context => {
166
166
  return {
167
167
  ObjectExpression(node) {
168
168
  if (!isVirtualDomNode(node)) {
@@ -182,11 +182,11 @@ const create$8 = context => {
182
182
 
183
183
  const noEmptyClassName = {
184
184
  __proto__: null,
185
- create: create$8,
186
- meta: meta$8
185
+ create: create$9,
186
+ meta: meta$9
187
187
  };
188
188
 
189
- const meta$7 = {
189
+ const meta$8 = {
190
190
  docs: {
191
191
  description: 'Disallow inline event handlers in virtual-dom nodes'
192
192
  },
@@ -201,7 +201,7 @@ const isEventPropertyName = name => {
201
201
  const isInlineEventHandler = node => {
202
202
  return isStringLiteral(node) || isTemplateLiteralNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
203
203
  };
204
- const create$7 = context => {
204
+ const create$8 = context => {
205
205
  return {
206
206
  ObjectExpression(node) {
207
207
  if (!isVirtualDomNode(node)) {
@@ -226,11 +226,11 @@ const create$7 = context => {
226
226
 
227
227
  const noInlineEventHandlers = {
228
228
  __proto__: null,
229
- create: create$7,
230
- meta: meta$7
229
+ create: create$8,
230
+ meta: meta$8
231
231
  };
232
232
 
233
- const meta$6 = {
233
+ const meta$7 = {
234
234
  docs: {
235
235
  description: 'Disallow inline style attributes in virtual-dom nodes'
236
236
  },
@@ -239,7 +239,7 @@ const meta$6 = {
239
239
  },
240
240
  type: 'problem'
241
241
  };
242
- const create$6 = context => {
242
+ const create$7 = context => {
243
243
  return {
244
244
  ObjectExpression(node) {
245
245
  if (!isVirtualDomNode(node)) {
@@ -259,11 +259,11 @@ const create$6 = context => {
259
259
 
260
260
  const noInlineStyle = {
261
261
  __proto__: null,
262
- create: create$6,
263
- meta: meta$6
262
+ create: create$7,
263
+ meta: meta$7
264
264
  };
265
265
 
266
- const meta$5 = {
266
+ const meta$6 = {
267
267
  docs: {
268
268
  description: 'Disallow object-like attribute values in virtual-dom nodes'
269
269
  },
@@ -276,7 +276,7 @@ const ignoredProperties = new Set(['childCount', 'type']);
276
276
  const isObjectLikeAttributeValue = node => {
277
277
  return isObjectExpressionNode(node) || isArrayExpressionNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
278
278
  };
279
- const create$5 = context => {
279
+ const create$6 = context => {
280
280
  return {
281
281
  ObjectExpression(node) {
282
282
  if (!isVirtualDomNode(node)) {
@@ -301,11 +301,11 @@ const create$5 = context => {
301
301
 
302
302
  const noObjectAttributeValues = {
303
303
  __proto__: null,
304
- create: create$5,
305
- meta: meta$5
304
+ create: create$6,
305
+ meta: meta$6
306
306
  };
307
307
 
308
- const meta$4 = {
308
+ const meta$5 = {
309
309
  docs: {
310
310
  description: 'Disallow raw string children in virtual-dom arrays'
311
311
  },
@@ -317,7 +317,7 @@ const meta$4 = {
317
317
  const isVirtualDomArray = node => {
318
318
  return isArrayExpressionNode(node) && node.elements.some(element => isVirtualDomNode(element) || isTextCall(element));
319
319
  };
320
- const create$4 = context => {
320
+ const create$5 = context => {
321
321
  return {
322
322
  ArrayExpression(node) {
323
323
  if (!isVirtualDomArray(node)) {
@@ -338,11 +338,11 @@ const create$4 = context => {
338
338
 
339
339
  const noRawTextChildren = {
340
340
  __proto__: null,
341
- create: create$4,
342
- meta: meta$4
341
+ create: create$5,
342
+ meta: meta$5
343
343
  };
344
344
 
345
- const meta$3 = {
345
+ const meta$4 = {
346
346
  docs: {
347
347
  description: 'Prefer virtual-dom constants over raw type, role, aria boolean, and tabIndex values'
348
348
  },
@@ -357,7 +357,7 @@ const meta$3 = {
357
357
  const isAriaBooleanProperty = name => {
358
358
  return /^aria[A-Z]/.test(name);
359
359
  };
360
- const create$3 = context => {
360
+ const create$4 = context => {
361
361
  return {
362
362
  ObjectExpression(node) {
363
363
  if (!isVirtualDomNode(node)) {
@@ -404,6 +404,46 @@ const create$3 = context => {
404
404
  };
405
405
 
406
406
  const preferConstants = {
407
+ __proto__: null,
408
+ create: create$4,
409
+ meta: meta$4
410
+ };
411
+
412
+ const meta$3 = {
413
+ docs: {
414
+ description: 'Require Intl.DateTimeFormat instances to be created lazily'
415
+ },
416
+ messages: {
417
+ preferLazyDateTimeFormat: 'Create Intl.DateTimeFormat instances lazily.'
418
+ },
419
+ type: 'suggestion'
420
+ };
421
+ const isFunctionNode = node => {
422
+ return ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(node.type);
423
+ };
424
+ const isDateTimeFormat = node => {
425
+ return node.type === 'MemberExpression' && !node.computed && node.object.type === 'Identifier' && node.object.name === 'Intl' && node.property.type === 'Identifier' && node.property.name === 'DateTimeFormat';
426
+ };
427
+ const create$3 = context => {
428
+ const isCreatedLazily = node => {
429
+ return context.sourceCode.getAncestors(node).some(isFunctionNode);
430
+ };
431
+ const reportEagerDateTimeFormat = node => {
432
+ if (!isDateTimeFormat(node.callee) || isCreatedLazily(node)) {
433
+ return;
434
+ }
435
+ context.report({
436
+ messageId: 'preferLazyDateTimeFormat',
437
+ node
438
+ });
439
+ };
440
+ return {
441
+ CallExpression: reportEagerDateTimeFormat,
442
+ NewExpression: reportEagerDateTimeFormat
443
+ };
444
+ };
445
+
446
+ const preferLazyDateTimeFormat = {
407
447
  __proto__: null,
408
448
  create: create$3,
409
449
  meta: meta$3
@@ -645,6 +685,7 @@ const plugin = {
645
685
  'no-object-attribute-values': noObjectAttributeValues,
646
686
  'no-raw-text-children': noRawTextChildren,
647
687
  'prefer-constants': preferConstants,
688
+ 'prefer-lazy-date-time-format': preferLazyDateTimeFormat,
648
689
  'prefer-merge-class-names': preferMergeClassNames,
649
690
  'prefer-state-destructuring': preferStateDestructuring,
650
691
  'valid-child-count': validChildCount
@@ -664,6 +705,7 @@ const recommended = [{
664
705
  'virtual-dom/no-object-attribute-values': 'error',
665
706
  'virtual-dom/no-raw-text-children': 'error',
666
707
  'virtual-dom/prefer-constants': 'error',
708
+ 'virtual-dom/prefer-lazy-date-time-format': 'error',
667
709
  'virtual-dom/prefer-merge-class-names': 'error',
668
710
  'virtual-dom/prefer-state-destructuring': 'error',
669
711
  'virtual-dom/valid-child-count': 'error'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-virtual-dom",
3
- "version": "16.4.0",
3
+ "version": "16.5.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",