@storm-software/eslint 0.20.0 → 0.21.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.
- package/README.md +1 -1
- package/dist/preset.d.mts +1214 -0
- package/dist/preset.d.ts +1214 -0
- package/dist/preset.mjs +939 -3
- package/package.json +1 -1
package/dist/preset.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import tsEslint from 'typescript-eslint';
|
|
2
2
|
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
3
3
|
import markdown from 'eslint-plugin-markdown';
|
|
4
4
|
import globals from 'globals';
|
|
5
|
+
import nxPlugin from '@nx/eslint-plugin';
|
|
6
|
+
import jsoncParser from 'jsonc-eslint-parser';
|
|
7
|
+
import react from 'eslint-plugin-react';
|
|
8
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
9
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
10
|
+
import tsdoc from 'eslint-plugin-tsdoc';
|
|
5
11
|
|
|
6
12
|
function getDefaultExportFromCjs (x) {
|
|
7
13
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -340,7 +346,876 @@ const formatConfig = (name, config = []) => {
|
|
|
340
346
|
});
|
|
341
347
|
};
|
|
342
348
|
|
|
343
|
-
|
|
349
|
+
const config$3 = {
|
|
350
|
+
// This rule has been deprecated, but not yet removed.
|
|
351
|
+
"jsx-a11y/no-onchange": "off",
|
|
352
|
+
// ensure emoji are accessible
|
|
353
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
|
|
354
|
+
// disabled; rule is deprecated
|
|
355
|
+
"jsx-a11y/accessible-emoji": "off",
|
|
356
|
+
// Enforce that all elements that require alternative text have meaningful information
|
|
357
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
|
|
358
|
+
"jsx-a11y/alt-text": [
|
|
359
|
+
"error",
|
|
360
|
+
{
|
|
361
|
+
elements: ["img", "object", "area", 'input[type="image"]'],
|
|
362
|
+
img: [],
|
|
363
|
+
object: [],
|
|
364
|
+
area: [],
|
|
365
|
+
'input[type="image"]': []
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
// Enforce that anchors have content
|
|
369
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
|
|
370
|
+
"jsx-a11y/anchor-has-content": ["error", { components: [] }],
|
|
371
|
+
// ensure <a> tags are valid
|
|
372
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
|
|
373
|
+
"jsx-a11y/anchor-is-valid": [
|
|
374
|
+
"error",
|
|
375
|
+
{
|
|
376
|
+
components: ["Link"],
|
|
377
|
+
specialLink: ["to"],
|
|
378
|
+
aspects: ["noHref", "invalidHref", "preferButton"]
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
// elements with aria-activedescendant must be tabbable
|
|
382
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
|
|
383
|
+
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
|
|
384
|
+
// Enforce all aria-* props are valid.
|
|
385
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
|
|
386
|
+
"jsx-a11y/aria-props": "error",
|
|
387
|
+
// Enforce ARIA state and property values are valid.
|
|
388
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
|
|
389
|
+
"jsx-a11y/aria-proptypes": "error",
|
|
390
|
+
// Require ARIA roles to be valid and non-abstract
|
|
391
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
|
|
392
|
+
"jsx-a11y/aria-role": ["error", { ignoreNonDOM: false }],
|
|
393
|
+
// Enforce that elements that do not support ARIA roles, states, and
|
|
394
|
+
// properties do not have those attributes.
|
|
395
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
|
|
396
|
+
"jsx-a11y/aria-unsupported-elements": "error",
|
|
397
|
+
// Ensure the autocomplete attribute is correct and suitable for the form field it is used with
|
|
398
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md
|
|
399
|
+
"jsx-a11y/autocomplete-valid": [
|
|
400
|
+
"off",
|
|
401
|
+
{
|
|
402
|
+
inputComponents: []
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
|
|
406
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
|
|
407
|
+
"jsx-a11y/click-events-have-key-events": "error",
|
|
408
|
+
// Enforce that a control (an interactive element) has a text label.
|
|
409
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
|
|
410
|
+
"jsx-a11y/control-has-associated-label": [
|
|
411
|
+
"error",
|
|
412
|
+
{
|
|
413
|
+
labelAttributes: ["label"],
|
|
414
|
+
controlComponents: [],
|
|
415
|
+
ignoreElements: [
|
|
416
|
+
"audio",
|
|
417
|
+
"canvas",
|
|
418
|
+
"embed",
|
|
419
|
+
"input",
|
|
420
|
+
"textarea",
|
|
421
|
+
"tr",
|
|
422
|
+
"video"
|
|
423
|
+
],
|
|
424
|
+
ignoreRoles: [
|
|
425
|
+
"grid",
|
|
426
|
+
"listbox",
|
|
427
|
+
"menu",
|
|
428
|
+
"menubar",
|
|
429
|
+
"radiogroup",
|
|
430
|
+
"row",
|
|
431
|
+
"tablist",
|
|
432
|
+
"toolbar",
|
|
433
|
+
"tree",
|
|
434
|
+
"treegrid"
|
|
435
|
+
],
|
|
436
|
+
depth: 5
|
|
437
|
+
}
|
|
438
|
+
],
|
|
439
|
+
// ensure <hX> tags have content and are not aria-hidden
|
|
440
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
|
|
441
|
+
"jsx-a11y/heading-has-content": ["error", { components: [""] }],
|
|
442
|
+
// require HTML elements to have a "lang" prop
|
|
443
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
|
|
444
|
+
"jsx-a11y/html-has-lang": "error",
|
|
445
|
+
// ensure iframe elements have a unique title
|
|
446
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
|
|
447
|
+
"jsx-a11y/iframe-has-title": "error",
|
|
448
|
+
// Prevent img alt text from containing redundant words like "image", "picture", or "photo"
|
|
449
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
|
|
450
|
+
"jsx-a11y/img-redundant-alt": "error",
|
|
451
|
+
// Elements with an interactive role and interaction handlers must be focusable
|
|
452
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
|
|
453
|
+
"jsx-a11y/interactive-supports-focus": "error",
|
|
454
|
+
// Enforce that a label tag has a text label and an associated control.
|
|
455
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
|
|
456
|
+
"jsx-a11y/label-has-associated-control": [
|
|
457
|
+
"error",
|
|
458
|
+
{
|
|
459
|
+
labelComponents: [],
|
|
460
|
+
labelAttributes: [],
|
|
461
|
+
controlComponents: [],
|
|
462
|
+
assert: "both",
|
|
463
|
+
depth: 25
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
// require HTML element's lang prop to be valid
|
|
467
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
|
|
468
|
+
"jsx-a11y/lang": "error",
|
|
469
|
+
// media elements must have captions
|
|
470
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
|
|
471
|
+
"jsx-a11y/media-has-caption": [
|
|
472
|
+
"error",
|
|
473
|
+
{
|
|
474
|
+
audio: [],
|
|
475
|
+
video: [],
|
|
476
|
+
track: []
|
|
477
|
+
}
|
|
478
|
+
],
|
|
479
|
+
// require that mouseover/out come with focus/blur, for keyboard-only users
|
|
480
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
|
|
481
|
+
"jsx-a11y/mouse-events-have-key-events": "error",
|
|
482
|
+
// Prevent use of `accessKey`
|
|
483
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
|
|
484
|
+
"jsx-a11y/no-access-key": "error",
|
|
485
|
+
// prohibit autoFocus prop
|
|
486
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
|
|
487
|
+
"jsx-a11y/no-autofocus": ["error", { ignoreNonDOM: true }],
|
|
488
|
+
// prevent distracting elements, like <marquee> and <blink>
|
|
489
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
|
|
490
|
+
"jsx-a11y/no-distracting-elements": [
|
|
491
|
+
"error",
|
|
492
|
+
{
|
|
493
|
+
elements: ["marquee", "blink"]
|
|
494
|
+
}
|
|
495
|
+
],
|
|
496
|
+
// WAI-ARIA roles should not be used to convert an interactive element to non-interactive
|
|
497
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
|
|
498
|
+
"jsx-a11y/no-interactive-element-to-noninteractive-role": [
|
|
499
|
+
"error",
|
|
500
|
+
{
|
|
501
|
+
tr: ["none", "presentation"]
|
|
502
|
+
}
|
|
503
|
+
],
|
|
504
|
+
// A non-interactive element does not support event handlers (mouse and key handlers)
|
|
505
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
|
|
506
|
+
"jsx-a11y/no-noninteractive-element-interactions": [
|
|
507
|
+
"error",
|
|
508
|
+
{
|
|
509
|
+
handlers: [
|
|
510
|
+
"onClick",
|
|
511
|
+
"onMouseDown",
|
|
512
|
+
"onMouseUp",
|
|
513
|
+
"onKeyPress",
|
|
514
|
+
"onKeyDown",
|
|
515
|
+
"onKeyUp"
|
|
516
|
+
]
|
|
517
|
+
}
|
|
518
|
+
],
|
|
519
|
+
// WAI-ARIA roles should not be used to convert a non-interactive element to interactive
|
|
520
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
|
|
521
|
+
"jsx-a11y/no-noninteractive-element-to-interactive-role": [
|
|
522
|
+
"error",
|
|
523
|
+
{
|
|
524
|
+
ul: [
|
|
525
|
+
"listbox",
|
|
526
|
+
"menu",
|
|
527
|
+
"menubar",
|
|
528
|
+
"radiogroup",
|
|
529
|
+
"tablist",
|
|
530
|
+
"tree",
|
|
531
|
+
"treegrid"
|
|
532
|
+
],
|
|
533
|
+
ol: [
|
|
534
|
+
"listbox",
|
|
535
|
+
"menu",
|
|
536
|
+
"menubar",
|
|
537
|
+
"radiogroup",
|
|
538
|
+
"tablist",
|
|
539
|
+
"tree",
|
|
540
|
+
"treegrid"
|
|
541
|
+
],
|
|
542
|
+
li: ["menuitem", "option", "row", "tab", "treeitem"],
|
|
543
|
+
table: ["grid"],
|
|
544
|
+
td: ["gridcell"]
|
|
545
|
+
}
|
|
546
|
+
],
|
|
547
|
+
// Tab key navigation should be limited to elements on the page that can be interacted with.
|
|
548
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
|
|
549
|
+
"jsx-a11y/no-noninteractive-tabindex": [
|
|
550
|
+
"error",
|
|
551
|
+
{
|
|
552
|
+
tags: [],
|
|
553
|
+
roles: ["tabpanel"],
|
|
554
|
+
allowExpressionValues: true
|
|
555
|
+
}
|
|
556
|
+
],
|
|
557
|
+
// ensure HTML elements do not specify redundant ARIA roles
|
|
558
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
|
|
559
|
+
"jsx-a11y/no-redundant-roles": [
|
|
560
|
+
"error",
|
|
561
|
+
{
|
|
562
|
+
nav: ["navigation"]
|
|
563
|
+
}
|
|
564
|
+
],
|
|
565
|
+
// Enforce that DOM elements without semantic behavior not have interaction handlers
|
|
566
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
|
|
567
|
+
"jsx-a11y/no-static-element-interactions": [
|
|
568
|
+
"error",
|
|
569
|
+
{
|
|
570
|
+
handlers: [
|
|
571
|
+
"onClick",
|
|
572
|
+
"onMouseDown",
|
|
573
|
+
"onMouseUp",
|
|
574
|
+
"onKeyPress",
|
|
575
|
+
"onKeyDown",
|
|
576
|
+
"onKeyUp"
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
],
|
|
580
|
+
// Enforce that elements with ARIA roles must have all required attributes
|
|
581
|
+
// for that role.
|
|
582
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
|
|
583
|
+
"jsx-a11y/role-has-required-aria-props": "error",
|
|
584
|
+
// Enforce that elements with explicit or implicit roles defined contain
|
|
585
|
+
// only aria-* properties supported by that role.
|
|
586
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
|
|
587
|
+
"jsx-a11y/role-supports-aria-props": "error",
|
|
588
|
+
// only allow <th> to have the "scope" attr
|
|
589
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
|
|
590
|
+
"jsx-a11y/scope": "error",
|
|
591
|
+
// Enforce tabIndex value is not greater than zero.
|
|
592
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
|
|
593
|
+
"jsx-a11y/tabindex-no-positive": "error",
|
|
594
|
+
// ----------------------------------------------------
|
|
595
|
+
// Rules that no longer exist in eslint-plugin-jsx-a11y
|
|
596
|
+
// ----------------------------------------------------
|
|
597
|
+
// require that JSX labels use "htmlFor"
|
|
598
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
|
|
599
|
+
// deprecated: replaced by `label-has-associated-control` rule
|
|
600
|
+
"jsx-a11y/label-has-for": [
|
|
601
|
+
"off",
|
|
602
|
+
{
|
|
603
|
+
components: [],
|
|
604
|
+
required: {
|
|
605
|
+
every: ["nesting", "id"]
|
|
606
|
+
},
|
|
607
|
+
allowChildren: false
|
|
608
|
+
}
|
|
609
|
+
],
|
|
610
|
+
// Ensures anchor text is not ambiguous
|
|
611
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/anchor-ambiguous-text.md
|
|
612
|
+
// TODO: semver-major, enable
|
|
613
|
+
"jsx-a11y/anchor-ambiguous-text": "off",
|
|
614
|
+
// Enforce that aria-hidden="true" is not set on focusable elements.
|
|
615
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/no-aria-hidden-on-focusable.md
|
|
616
|
+
// TODO: semver-major, enable
|
|
617
|
+
"jsx-a11y/no-aria-hidden-on-focusable": "off",
|
|
618
|
+
// Enforces using semantic DOM elements over the ARIA role property.
|
|
619
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/prefer-tag-over-role.md
|
|
620
|
+
// TODO: semver-major, enable
|
|
621
|
+
"jsx-a11y/prefer-tag-over-role": "off"
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const config$2 = {
|
|
625
|
+
// We recommend using TypeScript over `prop-types`, as `prop-types` can add
|
|
626
|
+
// to a project's build size.
|
|
627
|
+
"react/prop-types": "off",
|
|
628
|
+
// Disable requiring React to be imported, as this is no longer required.
|
|
629
|
+
"react/react-in-jsx-scope": "off",
|
|
630
|
+
/**
|
|
631
|
+
* Require an explicit type when using button elements.
|
|
632
|
+
*
|
|
633
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
634
|
+
*/
|
|
635
|
+
"react/button-has-type": [
|
|
636
|
+
"error",
|
|
637
|
+
{
|
|
638
|
+
button: true,
|
|
639
|
+
submit: true,
|
|
640
|
+
reset: true
|
|
641
|
+
}
|
|
642
|
+
],
|
|
643
|
+
/**
|
|
644
|
+
* Require consistent function type for function components.
|
|
645
|
+
*
|
|
646
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
|
|
647
|
+
*/
|
|
648
|
+
"react/function-component-definition": "warn",
|
|
649
|
+
/**
|
|
650
|
+
* Require destructuring and symmetric naming of `useState` hook value and setter variables.
|
|
651
|
+
*
|
|
652
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
653
|
+
*/
|
|
654
|
+
"react/hook-use-state": "warn",
|
|
655
|
+
/**
|
|
656
|
+
* Require consistent boolean attributes notation in JSX.
|
|
657
|
+
*
|
|
658
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
659
|
+
*/
|
|
660
|
+
"react/jsx-boolean-value": "warn",
|
|
661
|
+
/**
|
|
662
|
+
* Disallow unnecessary curly braces in JSX props and children.
|
|
663
|
+
*
|
|
664
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
665
|
+
*/
|
|
666
|
+
"react/jsx-curly-brace-presence": "warn",
|
|
667
|
+
/**
|
|
668
|
+
* Require using shorthand form for React fragments, unless required.
|
|
669
|
+
*
|
|
670
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
671
|
+
*/
|
|
672
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
673
|
+
/**
|
|
674
|
+
* Prevent problematic leaked values from being rendered.
|
|
675
|
+
*
|
|
676
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
677
|
+
*/
|
|
678
|
+
"react/jsx-no-leaked-render": "warn",
|
|
679
|
+
/**
|
|
680
|
+
* Prevents usage of unsafe `target='_blank'`.
|
|
681
|
+
*
|
|
682
|
+
* This rule is a part of `react/recommended`, but we've modified it to
|
|
683
|
+
* allow referrer.
|
|
684
|
+
*
|
|
685
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
686
|
+
*/
|
|
687
|
+
"react/jsx-no-target-blank": [
|
|
688
|
+
"error",
|
|
689
|
+
{
|
|
690
|
+
enforceDynamicLinks: "always",
|
|
691
|
+
allowReferrer: true
|
|
692
|
+
}
|
|
693
|
+
],
|
|
694
|
+
/**
|
|
695
|
+
* Disallow empty React fragments.
|
|
696
|
+
*
|
|
697
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
698
|
+
*/
|
|
699
|
+
"react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
|
|
700
|
+
/**
|
|
701
|
+
* Require the use of PascalCase for user-defined JSX components.
|
|
702
|
+
*
|
|
703
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
704
|
+
*/
|
|
705
|
+
"react/jsx-pascal-case": [
|
|
706
|
+
"error",
|
|
707
|
+
{
|
|
708
|
+
allowAllCaps: true,
|
|
709
|
+
ignore: []
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
/**
|
|
713
|
+
* Disallow usage of Array index in keys.
|
|
714
|
+
*
|
|
715
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
716
|
+
*/
|
|
717
|
+
"react/no-array-index-key": "warn",
|
|
718
|
+
/**
|
|
719
|
+
* Disallow creating unstable components inside components.
|
|
720
|
+
*
|
|
721
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
722
|
+
*/
|
|
723
|
+
"react/no-unstable-nested-components": "error",
|
|
724
|
+
/**
|
|
725
|
+
* Disallow closing tags for components without children.
|
|
726
|
+
*
|
|
727
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
728
|
+
*/
|
|
729
|
+
"react/self-closing-comp": "warn",
|
|
730
|
+
// Specify whether double or single quotes should be used in JSX attributes
|
|
731
|
+
// https://eslint.org/docs/rules/jsx-quotes
|
|
732
|
+
"jsx-quotes": ["error", "prefer-double"],
|
|
733
|
+
"class-methods-use-this": [
|
|
734
|
+
"error",
|
|
735
|
+
{
|
|
736
|
+
exceptMethods: [
|
|
737
|
+
"render",
|
|
738
|
+
"getInitialState",
|
|
739
|
+
"getDefaultProps",
|
|
740
|
+
"getChildContext",
|
|
741
|
+
"componentWillMount",
|
|
742
|
+
"UNSAFE_componentWillMount",
|
|
743
|
+
"componentDidMount",
|
|
744
|
+
"componentWillReceiveProps",
|
|
745
|
+
"UNSAFE_componentWillReceiveProps",
|
|
746
|
+
"shouldComponentUpdate",
|
|
747
|
+
"componentWillUpdate",
|
|
748
|
+
"UNSAFE_componentWillUpdate",
|
|
749
|
+
"componentDidUpdate",
|
|
750
|
+
"componentWillUnmount",
|
|
751
|
+
"componentDidCatch",
|
|
752
|
+
"getSnapshotBeforeUpdate"
|
|
753
|
+
]
|
|
754
|
+
}
|
|
755
|
+
],
|
|
756
|
+
// This rule enforces onChange or readonly attribute for checked property of input elements.
|
|
757
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md
|
|
758
|
+
"react/checked-requires-onchange-or-readonly": [
|
|
759
|
+
"off",
|
|
760
|
+
{
|
|
761
|
+
ignoreMissingProperties: false,
|
|
762
|
+
ignoreExclusiveCheckedAttribute: false
|
|
763
|
+
}
|
|
764
|
+
],
|
|
765
|
+
// Prevent missing displayName in a React component definition
|
|
766
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
767
|
+
"react/display-name": ["off", { ignoreTranspilerName: false }],
|
|
768
|
+
// Forbid certain propTypes (any, array, object)
|
|
769
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md
|
|
770
|
+
"react/forbid-prop-types": [
|
|
771
|
+
"error",
|
|
772
|
+
{
|
|
773
|
+
forbid: ["any", "array", "object"],
|
|
774
|
+
checkContextTypes: true,
|
|
775
|
+
checkChildContextTypes: true
|
|
776
|
+
}
|
|
777
|
+
],
|
|
778
|
+
// Forbid certain props on DOM Nodes
|
|
779
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md
|
|
780
|
+
"react/forbid-dom-props": ["off", { forbid: [] }],
|
|
781
|
+
// Validate closing bracket location in JSX
|
|
782
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
783
|
+
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
784
|
+
// Validate closing tag location in JSX
|
|
785
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
786
|
+
"react/jsx-closing-tag-location": "error",
|
|
787
|
+
// Enforce or disallow spaces inside of curly braces in JSX attributes
|
|
788
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
789
|
+
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
790
|
+
// Enforce event handler naming conventions in JSX
|
|
791
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
792
|
+
"react/jsx-handler-names": [
|
|
793
|
+
"warn",
|
|
794
|
+
{
|
|
795
|
+
eventHandlerPrefix: "handle",
|
|
796
|
+
eventHandlerPropPrefix: "on"
|
|
797
|
+
}
|
|
798
|
+
],
|
|
799
|
+
// Validate props indentation in JSX
|
|
800
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
801
|
+
"react/jsx-indent-props": ["error", 2],
|
|
802
|
+
// Validate JSX has key prop when in array or iterator
|
|
803
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
804
|
+
// Turned off because it has too many false positives
|
|
805
|
+
"react/jsx-key": "warn",
|
|
806
|
+
// Limit maximum of props on a single line in JSX
|
|
807
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
808
|
+
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
809
|
+
// Prevent usage of .bind() in JSX props
|
|
810
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
811
|
+
"react/jsx-no-bind": [
|
|
812
|
+
"error",
|
|
813
|
+
{
|
|
814
|
+
ignoreRefs: true,
|
|
815
|
+
allowArrowFunctions: true,
|
|
816
|
+
allowFunctions: false,
|
|
817
|
+
allowBind: false,
|
|
818
|
+
ignoreDOMComponents: true
|
|
819
|
+
}
|
|
820
|
+
],
|
|
821
|
+
// Prevent duplicate props in JSX
|
|
822
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
823
|
+
"react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
|
|
824
|
+
// Prevent usage of unwrapped JSX strings
|
|
825
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
|
|
826
|
+
"react/jsx-no-literals": ["off", { noStrings: true }],
|
|
827
|
+
// Disallow undeclared variables in JSX
|
|
828
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
829
|
+
"react/jsx-no-undef": "error",
|
|
830
|
+
// Deprecated in favor of react/jsx-sort-props
|
|
831
|
+
"react/jsx-sort-prop-types": "off",
|
|
832
|
+
/**
|
|
833
|
+
* Require props to be sorted alphabetically.
|
|
834
|
+
*
|
|
835
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
836
|
+
*/
|
|
837
|
+
"react/jsx-sort-props": [
|
|
838
|
+
"warn",
|
|
839
|
+
{
|
|
840
|
+
ignoreCase: true,
|
|
841
|
+
callbacksLast: false,
|
|
842
|
+
shorthandFirst: false,
|
|
843
|
+
shorthandLast: false,
|
|
844
|
+
noSortAlphabetically: false,
|
|
845
|
+
reservedFirst: true
|
|
846
|
+
}
|
|
847
|
+
],
|
|
848
|
+
// Enforce defaultProps declarations alphabetical sorting
|
|
849
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md
|
|
850
|
+
"react/jsx-sort-default-props": [
|
|
851
|
+
"warn",
|
|
852
|
+
{
|
|
853
|
+
ignoreCase: true
|
|
854
|
+
}
|
|
855
|
+
],
|
|
856
|
+
// Prevent React to be incorrectly marked as unused
|
|
857
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
|
|
858
|
+
"react/jsx-uses-react": ["error"],
|
|
859
|
+
// Prevent variables used in JSX to be incorrectly marked as unused
|
|
860
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
861
|
+
"react/jsx-uses-vars": "error",
|
|
862
|
+
// Prevent usage of dangerous JSX properties
|
|
863
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
|
|
864
|
+
"react/no-danger": "warn",
|
|
865
|
+
// Prevent usage of deprecated methods
|
|
866
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
867
|
+
"react/no-deprecated": ["error"],
|
|
868
|
+
// Prevent usage of setState in componentDidMount
|
|
869
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
|
870
|
+
// this is necessary for server-rendering
|
|
871
|
+
"react/no-did-mount-set-state": "off",
|
|
872
|
+
// Prevent usage of setState in componentDidUpdate
|
|
873
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
874
|
+
"react/no-did-update-set-state": "error",
|
|
875
|
+
// Prevent usage of setState in componentWillUpdate
|
|
876
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
877
|
+
"react/no-will-update-set-state": "error",
|
|
878
|
+
// Prevent direct mutation of this.state
|
|
879
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
880
|
+
"react/no-direct-mutation-state": "off",
|
|
881
|
+
// Prevent usage of isMounted
|
|
882
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
883
|
+
"react/no-is-mounted": "error",
|
|
884
|
+
// Prevent multiple component definition per file
|
|
885
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
|
|
886
|
+
"react/no-multi-comp": "off",
|
|
887
|
+
// Prevent usage of setState
|
|
888
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
889
|
+
"react/no-set-state": "off",
|
|
890
|
+
// Prevent using string references
|
|
891
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
892
|
+
"react/no-string-refs": "error",
|
|
893
|
+
// Prevent usage of unknown DOM property
|
|
894
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
895
|
+
"react/no-unknown-property": "error",
|
|
896
|
+
// Require ES6 class declarations over React.createClass
|
|
897
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
898
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
899
|
+
// Require stateless functions when not using lifecycle methods, setState or ref
|
|
900
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
901
|
+
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
902
|
+
// Require render() methods to return something
|
|
903
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
904
|
+
"react/require-render-return": "error",
|
|
905
|
+
// Enforce component methods order
|
|
906
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
|
|
907
|
+
"react/sort-comp": [
|
|
908
|
+
"error",
|
|
909
|
+
{
|
|
910
|
+
order: [
|
|
911
|
+
"static-variables",
|
|
912
|
+
"static-methods",
|
|
913
|
+
"instance-variables",
|
|
914
|
+
"lifecycle",
|
|
915
|
+
"/^handle.+$/",
|
|
916
|
+
"/^on.+$/",
|
|
917
|
+
"getters",
|
|
918
|
+
"setters",
|
|
919
|
+
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
|
|
920
|
+
"instance-methods",
|
|
921
|
+
"everything-else",
|
|
922
|
+
"rendering"
|
|
923
|
+
],
|
|
924
|
+
groups: {
|
|
925
|
+
lifecycle: [
|
|
926
|
+
"displayName",
|
|
927
|
+
"propTypes",
|
|
928
|
+
"contextTypes",
|
|
929
|
+
"childContextTypes",
|
|
930
|
+
"mixins",
|
|
931
|
+
"statics",
|
|
932
|
+
"defaultProps",
|
|
933
|
+
"constructor",
|
|
934
|
+
"getDefaultProps",
|
|
935
|
+
"getInitialState",
|
|
936
|
+
"state",
|
|
937
|
+
"getChildContext",
|
|
938
|
+
"getDerivedStateFromProps",
|
|
939
|
+
"componentWillMount",
|
|
940
|
+
"UNSAFE_componentWillMount",
|
|
941
|
+
"componentDidMount",
|
|
942
|
+
"componentWillReceiveProps",
|
|
943
|
+
"UNSAFE_componentWillReceiveProps",
|
|
944
|
+
"shouldComponentUpdate",
|
|
945
|
+
"componentWillUpdate",
|
|
946
|
+
"UNSAFE_componentWillUpdate",
|
|
947
|
+
"getSnapshotBeforeUpdate",
|
|
948
|
+
"componentDidUpdate",
|
|
949
|
+
"componentDidCatch",
|
|
950
|
+
"componentWillUnmount"
|
|
951
|
+
],
|
|
952
|
+
rendering: ["/^render.+$/", "render"]
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
],
|
|
956
|
+
// Prevent missing parentheses around multilines JSX
|
|
957
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md
|
|
958
|
+
"react/jsx-wrap-multilines": [
|
|
959
|
+
"error",
|
|
960
|
+
{
|
|
961
|
+
declaration: "parens-new-line",
|
|
962
|
+
assignment: "parens-new-line",
|
|
963
|
+
return: "parens-new-line",
|
|
964
|
+
arrow: "parens-new-line",
|
|
965
|
+
condition: "parens-new-line",
|
|
966
|
+
logical: "parens-new-line",
|
|
967
|
+
prop: "parens-new-line"
|
|
968
|
+
}
|
|
969
|
+
],
|
|
970
|
+
// Require that the first prop in a JSX element be on a new line when the element is multiline
|
|
971
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
972
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
973
|
+
// Enforce spacing around jsx equals signs
|
|
974
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
975
|
+
"react/jsx-equals-spacing": ["error", "never"],
|
|
976
|
+
// Enforce JSX indentation
|
|
977
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
|
978
|
+
"react/jsx-indent": ["error", 2],
|
|
979
|
+
// only ".jsx", ".tsx", or ".mdx" files may have JSX
|
|
980
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
981
|
+
"react/jsx-filename-extension": [
|
|
982
|
+
"error",
|
|
983
|
+
{ extensions: [".jsx", ".tsx", ".mdx"] }
|
|
984
|
+
],
|
|
985
|
+
// prevent accidental JS comments from being injected into JSX as text
|
|
986
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
987
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
988
|
+
// disallow using React.render/ReactDOM.render's return value
|
|
989
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
990
|
+
"react/no-render-return-value": "error",
|
|
991
|
+
// require a shouldComponentUpdate method, or PureRenderMixin
|
|
992
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
|
993
|
+
"react/require-optimization": ["off", { allowDecorators: [] }],
|
|
994
|
+
// warn against using findDOMNode()
|
|
995
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
996
|
+
"react/no-find-dom-node": "error",
|
|
997
|
+
// Forbid certain props on Components
|
|
998
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
999
|
+
"react/forbid-component-props": ["off", { forbid: [] }],
|
|
1000
|
+
// Forbid certain elements
|
|
1001
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
1002
|
+
"react/forbid-elements": ["off", { forbid: [] }],
|
|
1003
|
+
// Prevent problem with children and props.dangerouslySetInnerHTML
|
|
1004
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
1005
|
+
"react/no-danger-with-children": "error",
|
|
1006
|
+
// Prevent unused propType definitions
|
|
1007
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
1008
|
+
"react/no-unused-prop-types": [
|
|
1009
|
+
"error",
|
|
1010
|
+
{
|
|
1011
|
+
customValidators: [],
|
|
1012
|
+
skipShapeProps: true
|
|
1013
|
+
}
|
|
1014
|
+
],
|
|
1015
|
+
// Require style prop value be an object or var
|
|
1016
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
1017
|
+
"react/style-prop-object": "error",
|
|
1018
|
+
// Prevent invalid characters from appearing in markup
|
|
1019
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
1020
|
+
"react/no-unescaped-entities": "error",
|
|
1021
|
+
// Prevent passing of children as props
|
|
1022
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
1023
|
+
"react/no-children-prop": "error",
|
|
1024
|
+
// Validate whitespace in and around the JSX opening and closing brackets
|
|
1025
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md
|
|
1026
|
+
"react/jsx-tag-spacing": [
|
|
1027
|
+
"error",
|
|
1028
|
+
{
|
|
1029
|
+
closingSlash: "never",
|
|
1030
|
+
beforeSelfClosing: "always",
|
|
1031
|
+
afterOpening: "never",
|
|
1032
|
+
beforeClosing: "never"
|
|
1033
|
+
}
|
|
1034
|
+
],
|
|
1035
|
+
// Enforce spaces before the closing bracket of self-closing JSX elements
|
|
1036
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
|
|
1037
|
+
// Deprecated in favor of jsx-tag-spacing
|
|
1038
|
+
"react/jsx-space-before-closing": ["off", "always"],
|
|
1039
|
+
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
1040
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
|
|
1041
|
+
"react/require-default-props": [
|
|
1042
|
+
"error",
|
|
1043
|
+
{
|
|
1044
|
+
forbidDefaultForRequired: true
|
|
1045
|
+
}
|
|
1046
|
+
],
|
|
1047
|
+
// Forbids using non-exported propTypes
|
|
1048
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
1049
|
+
// this is intentionally set to "warn". it would be "error",
|
|
1050
|
+
// but it's only critical if you're stripping propTypes in production.
|
|
1051
|
+
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
1052
|
+
// Prevent void DOM elements from receiving children
|
|
1053
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
|
|
1054
|
+
"react/void-dom-elements-no-children": "error",
|
|
1055
|
+
// Enforce all defaultProps have a corresponding non-required PropType
|
|
1056
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md
|
|
1057
|
+
"react/default-props-match-prop-types": [
|
|
1058
|
+
"error",
|
|
1059
|
+
{ allowRequiredDefaults: false }
|
|
1060
|
+
],
|
|
1061
|
+
// Prevent usage of shouldComponentUpdate when extending React.PureComponent
|
|
1062
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md
|
|
1063
|
+
"react/no-redundant-should-component-update": "error",
|
|
1064
|
+
// Prevent unused state values
|
|
1065
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/pull/1103/
|
|
1066
|
+
"react/no-unused-state": "error",
|
|
1067
|
+
// Enforces consistent naming for boolean props
|
|
1068
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md
|
|
1069
|
+
"react/boolean-prop-naming": [
|
|
1070
|
+
"off",
|
|
1071
|
+
{
|
|
1072
|
+
propTypeNames: ["bool", "mutuallyExclusiveTrueProps"],
|
|
1073
|
+
rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+",
|
|
1074
|
+
message: ""
|
|
1075
|
+
}
|
|
1076
|
+
],
|
|
1077
|
+
// Prevents common casing typos
|
|
1078
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md
|
|
1079
|
+
"react/no-typos": "error",
|
|
1080
|
+
// One JSX Element Per Line
|
|
1081
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md
|
|
1082
|
+
"react/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
1083
|
+
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
1084
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md
|
|
1085
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
1086
|
+
// Prevent using this.state within a this.setState
|
|
1087
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md
|
|
1088
|
+
"react/no-access-state-in-setstate": "error",
|
|
1089
|
+
// Ensures inline tags are not rendered without spaces between them
|
|
1090
|
+
"react/jsx-child-element-spacing": "off",
|
|
1091
|
+
// Prevent this from being used in stateless functional components
|
|
1092
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md
|
|
1093
|
+
"react/no-this-in-sfc": "error",
|
|
1094
|
+
// Validate JSX maximum depth
|
|
1095
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md
|
|
1096
|
+
"react/jsx-max-depth": "off",
|
|
1097
|
+
// Disallow multiple spaces between inline JSX props
|
|
1098
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md
|
|
1099
|
+
"react/jsx-props-no-multi-spaces": "error",
|
|
1100
|
+
// Prevent usage of UNSAFE_ methods
|
|
1101
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md
|
|
1102
|
+
"react/no-unsafe": "off",
|
|
1103
|
+
// Enforce linebreaks in curly braces in JSX attributes and expressions.
|
|
1104
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
1105
|
+
"react/jsx-curly-newline": [
|
|
1106
|
+
"error",
|
|
1107
|
+
{
|
|
1108
|
+
multiline: "consistent",
|
|
1109
|
+
singleline: "consistent"
|
|
1110
|
+
}
|
|
1111
|
+
],
|
|
1112
|
+
// Enforce state initialization style
|
|
1113
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
1114
|
+
// TODO: set to "never" once babel-preset-airbnb supports public class fields
|
|
1115
|
+
"react/state-in-constructor": ["error", "always"],
|
|
1116
|
+
// Enforces where React component static properties should be positioned
|
|
1117
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
|
|
1118
|
+
// TODO: set to "static public field" once babel-preset-airbnb supports public class fields
|
|
1119
|
+
"react/static-property-placement": ["error", "property assignment"],
|
|
1120
|
+
// Disallow JSX props spreading
|
|
1121
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
|
|
1122
|
+
"react/jsx-props-no-spreading": [
|
|
1123
|
+
"off",
|
|
1124
|
+
{
|
|
1125
|
+
html: "enforce",
|
|
1126
|
+
custom: "enforce",
|
|
1127
|
+
explicitSpread: "ignore",
|
|
1128
|
+
exceptions: []
|
|
1129
|
+
}
|
|
1130
|
+
],
|
|
1131
|
+
// Enforce that props are read-only
|
|
1132
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
|
|
1133
|
+
"react/prefer-read-only-props": "off",
|
|
1134
|
+
// Prevent usage of `javascript:` URLs
|
|
1135
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
1136
|
+
"react/jsx-no-script-url": [
|
|
1137
|
+
"error",
|
|
1138
|
+
[
|
|
1139
|
+
{
|
|
1140
|
+
name: "Link",
|
|
1141
|
+
props: ["to"]
|
|
1142
|
+
}
|
|
1143
|
+
]
|
|
1144
|
+
],
|
|
1145
|
+
// Prevent adjacent inline elements not separated by whitespace
|
|
1146
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
|
|
1147
|
+
// TODO: enable? semver-major
|
|
1148
|
+
"react/no-adjacent-inline-elements": "off",
|
|
1149
|
+
// Enforce a new line after jsx elements and expressions
|
|
1150
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-newline.md
|
|
1151
|
+
"react/jsx-newline": "off",
|
|
1152
|
+
// Prevent react contexts from taking non-stable values
|
|
1153
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md
|
|
1154
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
1155
|
+
// Enforce that namespaces are not used in React elements
|
|
1156
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md
|
|
1157
|
+
"react/no-namespace": "error",
|
|
1158
|
+
// Prefer exact proptype definitions
|
|
1159
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
|
|
1160
|
+
"react/prefer-exact-props": "error",
|
|
1161
|
+
// Lifecycle methods should be methods on the prototype, not class fields
|
|
1162
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md
|
|
1163
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
1164
|
+
// Prevent usage of invalid attributes
|
|
1165
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md
|
|
1166
|
+
"react/no-invalid-html-attribute": "error",
|
|
1167
|
+
// Prevent declaring unused methods of component class
|
|
1168
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md
|
|
1169
|
+
"react/no-unused-class-component-methods": "error",
|
|
1170
|
+
// Enforce sandbox attribute on iframe elements
|
|
1171
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/iframe-missing-sandbox.md
|
|
1172
|
+
// TODO: semver-major, enable
|
|
1173
|
+
"react/iframe-missing-sandbox": "off",
|
|
1174
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md
|
|
1175
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md
|
|
1176
|
+
// TODO: semver-major, enable
|
|
1177
|
+
"react/no-object-type-as-default-prop": "off",
|
|
1178
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md
|
|
1179
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md
|
|
1180
|
+
// TODO: semver-major, enable?
|
|
1181
|
+
"react/sort-default-props": [
|
|
1182
|
+
"off",
|
|
1183
|
+
{
|
|
1184
|
+
ignoreCase: false
|
|
1185
|
+
}
|
|
1186
|
+
]
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
const config$1 = {
|
|
1190
|
+
// Enforce Rules of Hooks
|
|
1191
|
+
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
1192
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1193
|
+
// Verify the list of the dependencies for Hooks like useEffect and similar
|
|
1194
|
+
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
1195
|
+
"react-hooks/exhaustive-deps": "warn"
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
const config = {
|
|
1199
|
+
/**
|
|
1200
|
+
* Require TSDoc comments conform to the TSDoc specification.
|
|
1201
|
+
*
|
|
1202
|
+
* 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
|
|
1203
|
+
*/
|
|
1204
|
+
"tsdoc/syntax": "error"
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
function stormPreset(options = {
|
|
1208
|
+
moduleBoundaries: {
|
|
1209
|
+
enforceBuildableLibDependency: true,
|
|
1210
|
+
allow: [],
|
|
1211
|
+
depConstraints: [
|
|
1212
|
+
{
|
|
1213
|
+
sourceTag: "*",
|
|
1214
|
+
onlyDependOnLibsWithTags: ["*"]
|
|
1215
|
+
}
|
|
1216
|
+
]
|
|
1217
|
+
}
|
|
1218
|
+
}, ...userConfigs) {
|
|
344
1219
|
const rules = {
|
|
345
1220
|
"unicorn/number-literal-case": 0,
|
|
346
1221
|
"unicorn/template-indent": 0,
|
|
@@ -368,7 +1243,7 @@ function stormPreset(options = {}, ...userConfigs) {
|
|
|
368
1243
|
// https://eslint.org/docs/latest/rules/
|
|
369
1244
|
eslint.configs.recommended,
|
|
370
1245
|
// https://typescript-eslint.io/
|
|
371
|
-
...
|
|
1246
|
+
...tsEslint.configs.recommended,
|
|
372
1247
|
// https://github.com/sindresorhus/eslint-plugin-unicorn
|
|
373
1248
|
eslintPluginUnicorn.configs["flat/recommended"],
|
|
374
1249
|
// Preset overrides
|
|
@@ -407,6 +1282,67 @@ function stormPreset(options = {}, ...userConfigs) {
|
|
|
407
1282
|
...options.markdown?.rules
|
|
408
1283
|
}
|
|
409
1284
|
},
|
|
1285
|
+
// React
|
|
1286
|
+
// https://www.npmjs.com/package/eslint-plugin-react
|
|
1287
|
+
options.react !== false && {
|
|
1288
|
+
plugins: { react, "react-hooks": reactHooks, "jsx-a11y": jsxA11y }
|
|
1289
|
+
},
|
|
1290
|
+
options.react !== false && {
|
|
1291
|
+
files: ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
1292
|
+
rules: {
|
|
1293
|
+
...config$2,
|
|
1294
|
+
...config$1,
|
|
1295
|
+
...config$3,
|
|
1296
|
+
...options.react?.rules
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
// TSDoc
|
|
1300
|
+
// https://www.npmjs.com/package/eslint-plugin-tsdoc
|
|
1301
|
+
{ plugins: { tsdoc } },
|
|
1302
|
+
{
|
|
1303
|
+
files: ["*.ts", "*.tsx"],
|
|
1304
|
+
rules: {
|
|
1305
|
+
...config
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
// Nx plugin
|
|
1309
|
+
{ plugins: { "@nx": nxPlugin } },
|
|
1310
|
+
{
|
|
1311
|
+
languageOptions: {
|
|
1312
|
+
parser: tsEslint.parser,
|
|
1313
|
+
globals: {
|
|
1314
|
+
...globals.node
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
rules: {
|
|
1318
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error"]
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
files: ["*.json", "*.jsonc"],
|
|
1323
|
+
languageOptions: {
|
|
1324
|
+
parser: jsoncParser
|
|
1325
|
+
},
|
|
1326
|
+
rules: {}
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
files: ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
1330
|
+
rules: {
|
|
1331
|
+
"@nx/enforce-module-boundaries": [
|
|
1332
|
+
"error",
|
|
1333
|
+
options.moduleBoundaries ? options.moduleBoundaries : {
|
|
1334
|
+
enforceBuildableLibDependency: true,
|
|
1335
|
+
allow: [],
|
|
1336
|
+
depConstraints: [
|
|
1337
|
+
{
|
|
1338
|
+
sourceTag: "*",
|
|
1339
|
+
onlyDependOnLibsWithTags: ["*"]
|
|
1340
|
+
}
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
]
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
410
1346
|
// User overrides
|
|
411
1347
|
...userConfigs
|
|
412
1348
|
].filter(Boolean);
|