eslint-plugin-react-features 1.2.8 → 1.2.10

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 (65) hide show
  1. package/package.json +2 -3
  2. package/src/index.js +1 -239
  3. package/src/oxlint.js +1 -3
  4. package/src/rules/component-api/no-arbitrary-token-class.js +1 -74
  5. package/src/rules/component-api/no-default-test-id.js +1 -46
  6. package/src/rules/component-api/no-inline-style.js +1 -57
  7. package/src/rules/component-api/no-is-prefix-prop.js +1 -59
  8. package/src/rules/component-api/no-kind-prop-discriminator.js +1 -57
  9. package/src/rules/component-api/no-raw-color-literal.js +1 -55
  10. package/src/rules/component-api/no-wrapper-sub-component.js +1 -95
  11. package/src/rules/component-api/require-data-slot.js +1 -40
  12. package/src/rules/migration/react-class-to-hooks.js +1 -159
  13. package/src/rules/performance/no-unnecessary-rerenders.js +1 -185
  14. package/src/rules/performance/react-no-inline-functions.js +1 -187
  15. package/src/rules/performance/react-render-optimization.js +1 -256
  16. package/src/rules/react/checked-requires-onchange-or-readonly.js +1 -68
  17. package/src/rules/react/default-props-match-prop-types.js +1 -99
  18. package/src/rules/react/display-name.js +1 -133
  19. package/src/rules/react/hooks-exhaustive-deps.js +1 -466
  20. package/src/rules/react/jsx-handler-names.js +1 -50
  21. package/src/rules/react/jsx-key.js +1 -323
  22. package/src/rules/react/jsx-max-depth.js +1 -71
  23. package/src/rules/react/jsx-no-bind.js +1 -55
  24. package/src/rules/react/jsx-no-duplicate-props.js +1 -66
  25. package/src/rules/react/jsx-no-literals.js +1 -79
  26. package/src/rules/react/jsx-no-script-url.js +1 -119
  27. package/src/rules/react/jsx-no-target-blank.js +1 -163
  28. package/src/rules/react/no-access-state-in-setstate.js +1 -80
  29. package/src/rules/react/no-adjacent-inline-elements.js +1 -72
  30. package/src/rules/react/no-arrow-function-lifecycle.js +1 -57
  31. package/src/rules/react/no-children-prop.js +1 -54
  32. package/src/rules/react/no-danger-with-children.js +1 -99
  33. package/src/rules/react/no-danger.js +1 -43
  34. package/src/rules/react/no-deprecated.js +1 -130
  35. package/src/rules/react/no-did-mount-set-state.js +1 -50
  36. package/src/rules/react/no-did-update-set-state.js +1 -71
  37. package/src/rules/react/no-direct-mutation-state.js +3 -211
  38. package/src/rules/react/no-find-dom-node.js +1 -50
  39. package/src/rules/react/no-invalid-html-attribute.js +1 -80
  40. package/src/rules/react/no-is-mounted.js +1 -46
  41. package/src/rules/react/no-multi-comp.js +1 -150
  42. package/src/rules/react/no-namespace.js +1 -37
  43. package/src/rules/react/no-object-type-as-default-prop.js +1 -53
  44. package/src/rules/react/no-redundant-should-component-update.js +1 -50
  45. package/src/rules/react/no-render-return-value.js +1 -67
  46. package/src/rules/react/no-set-state.js +1 -45
  47. package/src/rules/react/no-string-refs.js +1 -61
  48. package/src/rules/react/no-this-in-sfc.js +1 -55
  49. package/src/rules/react/no-typos.js +1 -90
  50. package/src/rules/react/no-unescaped-entities.js +1 -44
  51. package/src/rules/react/no-unknown-property.js +1 -124
  52. package/src/rules/react/no-unsafe.js +1 -106
  53. package/src/rules/react/prefer-es6-class.js +1 -50
  54. package/src/rules/react/prefer-stateless-function.js +1 -126
  55. package/src/rules/react/prop-types.js +1 -143
  56. package/src/rules/react/react-in-jsx-scope.js +1 -86
  57. package/src/rules/react/require-default-props.js +1 -134
  58. package/src/rules/react/require-optimization.js +1 -397
  59. package/src/rules/react/require-render-return.js +1 -79
  60. package/src/rules/react/required-attributes.js +1 -185
  61. package/src/rules/react/sort-comp.js +1 -146
  62. package/src/rules/react/state-in-constructor.js +1 -95
  63. package/src/rules/react/static-property-placement.js +1 -122
  64. package/src/rules/react/void-dom-elements-no-children.js +1 -89
  65. package/src/types/index.js +1 -2
@@ -1,53 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noObjectTypeAsDefaultProp = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noObjectTypeAsDefaultProp = (0, eslint_devkit_1.createRule)({
7
- name: 'no-object-type-as-default-prop',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-object-type-as-default-prop.md',
12
- description: 'Prevent object types as default props',
13
- },
14
- messages: {
15
- noObjectTypeAsDefaultProp: (0, eslint_devkit_2.formatLLMMessage)({
16
- icon: eslint_devkit_2.MessageIcons.WARNING,
17
- issueName: 'Object as Default Prop',
18
- description: 'Object used as default prop value',
19
- severity: 'MEDIUM',
20
- fix: 'Create object outside component or use factory function',
21
- documentationLink: 'https://react.dev/learn/passing-props-to-a-component#default-props',
22
- }),
23
- },
24
- schema: [],
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- return {
29
- 'PropertyDefinition[key.name="defaultProps"]'(node) {
30
- if (node.value && node.value.type === 'ObjectExpression') {
31
- for (const prop of node.value.properties) {
32
- if (prop.type === 'Property' && prop.value.type === 'ObjectExpression') {
33
- context.report({
34
- node: prop.key,
35
- messageId: 'noObjectTypeAsDefaultProp',
36
- });
37
- }
38
- }
39
- }
40
- },
41
- AssignmentPattern(node) {
42
- if (node.right.type === 'ObjectExpression') {
43
- if (node.parent.type === 'Property' || node.parent.type === 'RestElement') {
44
- context.report({
45
- node: node.left,
46
- messageId: 'noObjectTypeAsDefaultProp',
47
- });
48
- }
49
- }
50
- },
51
- };
52
- },
53
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noObjectTypeAsDefaultProp=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noObjectTypeAsDefaultProp=(0,eslint_devkit_1.createRule)({name:"no-object-type-as-default-prop",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-object-type-as-default-prop.md",description:"Prevent object types as default props"},messages:{noObjectTypeAsDefaultProp:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Object as Default Prop",description:"Object used as default prop value",severity:"MEDIUM",fix:"Create object outside component or use factory function",documentationLink:"https://react.dev/learn/passing-props-to-a-component#default-props"})},schema:[]},defaultOptions:[],create(context){return{'PropertyDefinition[key.name="defaultProps"]'(node){if(node.value&&node.value.type==="ObjectExpression"){for(const prop of node.value.properties){if(prop.type==="Property"&&prop.value.type==="ObjectExpression"){context.report({node:prop.key,messageId:"noObjectTypeAsDefaultProp"})}}}},AssignmentPattern(node){if(node.right.type==="ObjectExpression"){if(node.parent.type==="Property"||node.parent.type==="RestElement"){context.report({node:node.left,messageId:"noObjectTypeAsDefaultProp"})}}}}}});
@@ -1,50 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noRedundantShouldComponentUpdate = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noRedundantShouldComponentUpdate = (0, eslint_devkit_1.createRule)({
7
- name: 'no-redundant-should-component-update',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-redundant-should-component-update.md',
12
- description: 'Prevent redundant shouldComponentUpdate',
13
- },
14
- messages: {
15
- noRedundantShouldComponentUpdate: (0, eslint_devkit_2.formatLLMMessage)({
16
- icon: eslint_devkit_2.MessageIcons.WARNING,
17
- issueName: 'Redundant shouldComponentUpdate',
18
- description: 'shouldComponentUpdate method does nothing useful',
19
- severity: 'MEDIUM',
20
- fix: 'Remove redundant shouldComponentUpdate or implement proper logic',
21
- documentationLink: 'https://react.dev/reference/react/Component#shouldcomponentupdate',
22
- }),
23
- },
24
- schema: [],
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- return {
29
- MethodDefinition(node) {
30
- if (node.key.type === 'Identifier' &&
31
- node.key.name === 'shouldComponentUpdate' &&
32
- node.value.type === 'FunctionExpression') {
33
- const body = node.value.body;
34
- if (body.type === 'BlockStatement' && body.body.length === 1) {
35
- const statement = body.body[0];
36
- if (statement.type === 'ReturnStatement' &&
37
- statement.argument &&
38
- statement.argument.type === 'Literal' &&
39
- statement.argument.value === true) {
40
- context.report({
41
- node: node.key,
42
- messageId: 'noRedundantShouldComponentUpdate',
43
- });
44
- }
45
- }
46
- }
47
- },
48
- };
49
- },
50
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRedundantShouldComponentUpdate=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noRedundantShouldComponentUpdate=(0,eslint_devkit_1.createRule)({name:"no-redundant-should-component-update",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-redundant-should-component-update.md",description:"Prevent redundant shouldComponentUpdate"},messages:{noRedundantShouldComponentUpdate:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Redundant shouldComponentUpdate",description:"shouldComponentUpdate method does nothing useful",severity:"MEDIUM",fix:"Remove redundant shouldComponentUpdate or implement proper logic",documentationLink:"https://react.dev/reference/react/Component#shouldcomponentupdate"})},schema:[]},defaultOptions:[],create(context){return{MethodDefinition(node){if(node.key.type==="Identifier"&&node.key.name==="shouldComponentUpdate"&&node.value.type==="FunctionExpression"){const body=node.value.body;if(body.type==="BlockStatement"&&body.body.length===1){const statement=body.body[0];if(statement.type==="ReturnStatement"&&statement.argument&&statement.argument.type==="Literal"&&statement.argument.value===true){context.report({node:node.key,messageId:"noRedundantShouldComponentUpdate"})}}}}}}});
@@ -1,67 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noRenderReturnValue = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noRenderReturnValue = (0, eslint_devkit_1.createRule)({
7
- name: 'no-render-return-value',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-render-return-value.md',
12
- description: 'Prevent using render return value',
13
- },
14
- messages: {
15
- noRenderReturnValue: (0, eslint_devkit_2.formatLLMMessage)({
16
- icon: eslint_devkit_2.MessageIcons.WARNING,
17
- issueName: 'Render Return Value Usage',
18
- description: 'Using return value of ReactDOM.render()',
19
- severity: 'HIGH',
20
- fix: 'ReactDOM.render() return value is deprecated, use refs instead',
21
- documentationLink: 'https://react.dev/reference/react-dom/render',
22
- }),
23
- },
24
- schema: [],
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- return {
29
- VariableDeclarator(node) {
30
- if (node.init &&
31
- node.init.type === 'CallExpression' &&
32
- isReactDOMRenderCall(node.init)) {
33
- context.report({
34
- node: node.id,
35
- messageId: 'noRenderReturnValue',
36
- });
37
- }
38
- },
39
- AssignmentExpression(node) {
40
- if (node.right.type === 'CallExpression' &&
41
- isReactDOMRenderCall(node.right)) {
42
- context.report({
43
- node: node.left,
44
- messageId: 'noRenderReturnValue',
45
- });
46
- }
47
- },
48
- };
49
- },
50
- });
51
- function isReactDOMRenderCall(node) {
52
- if (node.callee.type === 'MemberExpression' &&
53
- node.callee.object.type === 'MemberExpression' &&
54
- node.callee.object.object.type === 'Identifier' &&
55
- node.callee.object.object.name === 'ReactDOM' &&
56
- node.callee.object.property.type === 'Identifier' &&
57
- node.callee.object.property.name === 'render' &&
58
- node.callee.property.type === 'Identifier' &&
59
- node.callee.property.name === 'render') {
60
- return false;
61
- }
62
- return (node.callee.type === 'MemberExpression' &&
63
- node.callee.object.type === 'Identifier' &&
64
- node.callee.object.name === 'ReactDOM' &&
65
- node.callee.property.type === 'Identifier' &&
66
- node.callee.property.name === 'render');
67
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRenderReturnValue=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noRenderReturnValue=(0,eslint_devkit_1.createRule)({name:"no-render-return-value",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-render-return-value.md",description:"Prevent using render return value"},messages:{noRenderReturnValue:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Render Return Value Usage",description:"Using return value of ReactDOM.render()",severity:"HIGH",fix:"ReactDOM.render() return value is deprecated, use refs instead",documentationLink:"https://react.dev/reference/react-dom/render"})},schema:[]},defaultOptions:[],create(context){return{VariableDeclarator(node){if(node.init&&node.init.type==="CallExpression"&&isReactDOMRenderCall(node.init)){context.report({node:node.id,messageId:"noRenderReturnValue"})}},AssignmentExpression(node){if(node.right.type==="CallExpression"&&isReactDOMRenderCall(node.right)){context.report({node:node.left,messageId:"noRenderReturnValue"})}}}}});function isReactDOMRenderCall(node){if(node.callee.type==="MemberExpression"&&node.callee.object.type==="MemberExpression"&&node.callee.object.object.type==="Identifier"&&node.callee.object.object.name==="ReactDOM"&&node.callee.object.property.type==="Identifier"&&node.callee.object.property.name==="render"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="render"){return false}return node.callee.type==="MemberExpression"&&node.callee.object.type==="Identifier"&&node.callee.object.name==="ReactDOM"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="render"}
@@ -1,45 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noSetState = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noSetState = (0, eslint_devkit_1.createRule)({
7
- name: 'no-set-state',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-set-state.md',
12
- description: 'Disallow usage of setState to encourage functional components with hooks',
13
- },
14
- messages: {
15
- noSetState: (0, eslint_devkit_2.formatLLMMessage)({
16
- icon: eslint_devkit_2.MessageIcons.MIGRATION,
17
- issueName: 'setState Usage',
18
- description: 'Usage of setState detected',
19
- severity: 'MEDIUM',
20
- fix: 'Convert to functional component with useState hook',
21
- documentationLink: 'https://react.dev/reference/react/useState',
22
- }),
23
- },
24
- schema: [],
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- return {
29
- CallExpression(node) {
30
- if (node.callee.type === 'MemberExpression' &&
31
- node.callee.property.type === 'Identifier' &&
32
- node.callee.property.name === 'setState') {
33
- context.report({
34
- node: node.callee.property,
35
- messageId: 'noSetState',
36
- data: {
37
- methodName: 'setState',
38
- suggestion: 'Use useState hook in functional component',
39
- },
40
- });
41
- }
42
- },
43
- };
44
- },
45
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSetState=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noSetState=(0,eslint_devkit_1.createRule)({name:"no-set-state",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-set-state.md",description:"Disallow usage of setState to encourage functional components with hooks"},messages:{noSetState:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.MIGRATION,issueName:"setState Usage",description:"Usage of setState detected",severity:"MEDIUM",fix:"Convert to functional component with useState hook",documentationLink:"https://react.dev/reference/react/useState"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="setState"){context.report({node:node.callee.property,messageId:"noSetState",data:{methodName:"setState",suggestion:"Use useState hook in functional component"}})}}}}});
@@ -1,61 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noStringRefs = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noStringRefs = (0, eslint_devkit_1.createRule)({
7
- name: 'no-string-refs',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-string-refs.md',
12
- description: 'Disallow string refs',
13
- },
14
- messages: {
15
- noStringRefs: (0, eslint_devkit_2.formatLLMMessage)({
16
- icon: eslint_devkit_2.MessageIcons.MIGRATION,
17
- issueName: 'String Refs',
18
- description: 'Usage of string refs detected',
19
- severity: 'HIGH',
20
- fix: 'Use callback refs: ref={(el) => this.myRef = el} or createRef: this.myRef = React.createRef()',
21
- documentationLink: 'https://react.dev/reference/react/forwardRef',
22
- }),
23
- },
24
- schema: [],
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- return {
29
- JSXAttribute(node) {
30
- if (node.name.type === 'JSXIdentifier' &&
31
- node.name.name === 'ref') {
32
- if (node.value &&
33
- node.value.type === 'Literal' &&
34
- typeof node.value.value === 'string') {
35
- context.report({
36
- node: node.name,
37
- messageId: 'noStringRefs',
38
- });
39
- }
40
- else if (node.value &&
41
- node.value.type === 'JSXExpressionContainer' &&
42
- node.value.expression.type === 'Literal' &&
43
- typeof node.value.expression.value === 'string') {
44
- context.report({
45
- node: node.name,
46
- messageId: 'noStringRefs',
47
- });
48
- }
49
- else if (node.value &&
50
- node.value.type === 'JSXExpressionContainer' &&
51
- node.value.expression.type === 'TemplateLiteral') {
52
- context.report({
53
- node: node.name,
54
- messageId: 'noStringRefs',
55
- });
56
- }
57
- }
58
- },
59
- };
60
- },
61
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noStringRefs=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noStringRefs=(0,eslint_devkit_1.createRule)({name:"no-string-refs",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-string-refs.md",description:"Disallow string refs"},messages:{noStringRefs:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.MIGRATION,issueName:"String Refs",description:"Usage of string refs detected",severity:"HIGH",fix:"Use callback refs: ref={(el) => this.myRef = el} or createRef: this.myRef = React.createRef()",documentationLink:"https://react.dev/reference/react/forwardRef"})},schema:[]},defaultOptions:[],create(context){return{JSXAttribute(node){if(node.name.type==="JSXIdentifier"&&node.name.name==="ref"){if(node.value&&node.value.type==="Literal"&&typeof node.value.value==="string"){context.report({node:node.name,messageId:"noStringRefs"})}else if(node.value&&node.value.type==="JSXExpressionContainer"&&node.value.expression.type==="Literal"&&typeof node.value.expression.value==="string"){context.report({node:node.name,messageId:"noStringRefs"})}else if(node.value&&node.value.type==="JSXExpressionContainer"&&node.value.expression.type==="TemplateLiteral"){context.report({node:node.name,messageId:"noStringRefs"})}}}}}});
@@ -1,55 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noThisInSfc = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- exports.noThisInSfc = (0, eslint_devkit_1.createRule)({
7
- name: 'no-this-in-sfc',
8
- meta: {
9
- type: 'problem',
10
- docs: {
11
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-this-in-sfc.md',
12
- description: 'Disallow this from being used in stateless functional components',
13
- },
14
- schema: [],
15
- messages: {
16
- noThisInSfc: (0, eslint_devkit_2.formatLLMMessage)({
17
- icon: eslint_devkit_2.MessageIcons.WARNING,
18
- issueName: 'Invalid this usage',
19
- description: 'this cannot be used in stateless functional components',
20
- severity: 'HIGH',
21
- fix: 'Convert to class component or use hooks for state',
22
- documentationLink: 'https://react.dev/learn/your-first-component',
23
- }),
24
- },
25
- },
26
- defaultOptions: [],
27
- create(context) {
28
- let inClassContext = false;
29
- return {
30
- ClassDeclaration() {
31
- inClassContext = true;
32
- },
33
- 'ClassDeclaration:exit'() {
34
- inClassContext = false;
35
- },
36
- ClassExpression() {
37
- inClassContext = true;
38
- },
39
- 'ClassExpression:exit'() {
40
- inClassContext = false;
41
- },
42
- MethodDefinition() {
43
- },
44
- ThisExpression(node) {
45
- if (inClassContext) {
46
- return;
47
- }
48
- context.report({
49
- node,
50
- messageId: 'noThisInSfc',
51
- });
52
- },
53
- };
54
- },
55
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noThisInSfc=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noThisInSfc=(0,eslint_devkit_1.createRule)({name:"no-this-in-sfc",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-this-in-sfc.md",description:"Disallow this from being used in stateless functional components"},schema:[],messages:{noThisInSfc:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid this usage",description:"this cannot be used in stateless functional components",severity:"HIGH",fix:"Convert to class component or use hooks for state",documentationLink:"https://react.dev/learn/your-first-component"})}},defaultOptions:[],create(context){let inClassContext=false;return{ClassDeclaration(){inClassContext=true},"ClassDeclaration:exit"(){inClassContext=false},ClassExpression(){inClassContext=true},"ClassExpression:exit"(){inClassContext=false},MethodDefinition(){},ThisExpression(node){if(inClassContext){return}context.report({node,messageId:"noThisInSfc"})}}}});
@@ -1,90 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noTypos = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- const COMMON_TYPOS = new Map([
7
- ['defaulProps', 'defaultProps'],
8
- ['defaulProps', 'defaultProps'],
9
- ['defalutProps', 'defaultProps'],
10
- ['defualtProps', 'defaultProps'],
11
- ['DefaulProps', 'DefaultProps'],
12
- ['DefalutProps', 'DefaultProps'],
13
- ['DefualtProps', 'DefaultProps'],
14
- ['propTypes', 'propTypes'],
15
- ['PropTypes', 'PropTypes'],
16
- ['componenDidMount', 'componentDidMount'],
17
- ['componenDidUpdate', 'componentDidUpdate'],
18
- ['componenWillUnmount', 'componentWillUnmount'],
19
- ['componenWillMount', 'componentWillMount'],
20
- ['componenWillReceiveProps', 'componentWillReceiveProps'],
21
- ['componenWillUpdate', 'componentWillUpdate'],
22
- ['shoudComponentUpdate', 'shouldComponentUpdate'],
23
- ['getDerivedStateFromProps', 'getDerivedStateFromProps'],
24
- ['getSnapshoBeforeUpdate', 'getSnapshotBeforeUpdate'],
25
- ['UNSAFE_componenWillMount', 'UNSAFE_componentWillMount'],
26
- ['UNSAFE_componenWillReceiveProps', 'UNSAFE_componentWillReceiveProps'],
27
- ['UNSAFE_componenWillUpdate', 'UNSAFE_componentWillUpdate'],
28
- ]);
29
- exports.noTypos = (0, eslint_devkit_1.createRule)({
30
- name: 'no-typos',
31
- meta: {
32
- type: 'problem',
33
- docs: {
34
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-typos.md',
35
- description: 'Catch common typos',
36
- },
37
- schema: [],
38
- messages: {
39
- noTypos: (0, eslint_devkit_2.formatLLMMessage)({
40
- icon: eslint_devkit_2.MessageIcons.WARNING,
41
- issueName: 'Typo Detected',
42
- description: 'Common typo in React method/property name',
43
- severity: 'LOW',
44
- fix: 'Correct the spelling to match React API',
45
- documentationLink: 'https://react.dev/reference/react/Component',
46
- }),
47
- },
48
- },
49
- defaultOptions: [],
50
- create(context) {
51
- return {
52
- PropertyDefinition(node) {
53
- if (node.key.type === 'Identifier') {
54
- const name = node.key.name;
55
- const correction = COMMON_TYPOS.get(name);
56
- if (correction) {
57
- context.report({
58
- node: node.key,
59
- messageId: 'noTypos',
60
- });
61
- }
62
- }
63
- },
64
- MethodDefinition(node) {
65
- if (node.key.type === 'Identifier') {
66
- const name = node.key.name;
67
- const correction = COMMON_TYPOS.get(name);
68
- if (correction) {
69
- context.report({
70
- node: node.key,
71
- messageId: 'noTypos',
72
- });
73
- }
74
- }
75
- },
76
- MemberExpression(node) {
77
- if (node.property.type === 'Identifier') {
78
- const name = node.property.name;
79
- const correction = COMMON_TYPOS.get(name);
80
- if (correction) {
81
- context.report({
82
- node: node.property,
83
- messageId: 'noTypos',
84
- });
85
- }
86
- }
87
- },
88
- };
89
- },
90
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noTypos=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const COMMON_TYPOS=new Map([["defaulProps","defaultProps"],["defaulProps","defaultProps"],["defalutProps","defaultProps"],["defualtProps","defaultProps"],["DefaulProps","DefaultProps"],["DefalutProps","DefaultProps"],["DefualtProps","DefaultProps"],["propTypes","propTypes"],["PropTypes","PropTypes"],["componenDidMount","componentDidMount"],["componenDidUpdate","componentDidUpdate"],["componenWillUnmount","componentWillUnmount"],["componenWillMount","componentWillMount"],["componenWillReceiveProps","componentWillReceiveProps"],["componenWillUpdate","componentWillUpdate"],["shoudComponentUpdate","shouldComponentUpdate"],["getDerivedStateFromProps","getDerivedStateFromProps"],["getSnapshoBeforeUpdate","getSnapshotBeforeUpdate"],["UNSAFE_componenWillMount","UNSAFE_componentWillMount"],["UNSAFE_componenWillReceiveProps","UNSAFE_componentWillReceiveProps"],["UNSAFE_componenWillUpdate","UNSAFE_componentWillUpdate"]]);exports.noTypos=(0,eslint_devkit_1.createRule)({name:"no-typos",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-typos.md",description:"Catch common typos"},schema:[],messages:{noTypos:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Typo Detected",description:"Common typo in React method/property name",severity:"LOW",fix:"Correct the spelling to match React API",documentationLink:"https://react.dev/reference/react/Component"})}},defaultOptions:[],create(context){return{PropertyDefinition(node){if(node.key.type==="Identifier"){const name=node.key.name;const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.key,messageId:"noTypos"})}}},MethodDefinition(node){if(node.key.type==="Identifier"){const name=node.key.name;const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.key,messageId:"noTypos"})}}},MemberExpression(node){if(node.property.type==="Identifier"){const name=node.property.name;const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.property,messageId:"noTypos"})}}}}}});
@@ -1,44 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUnescapedEntities = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
- const UNESCAPED_ENTITIES = /[<>"]/;
7
- exports.noUnescapedEntities = (0, eslint_devkit_1.createRule)({
8
- name: 'no-unescaped-entities',
9
- meta: {
10
- type: 'problem',
11
- docs: {
12
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unescaped-entities.md',
13
- description: 'Prevent unescaped entities',
14
- },
15
- messages: {
16
- noUnescapedEntities: (0, eslint_devkit_2.formatLLMMessage)({
17
- icon: eslint_devkit_2.MessageIcons.WARNING,
18
- issueName: 'Unescaped Entity',
19
- description: 'Unescaped HTML entity in JSX text',
20
- severity: 'MEDIUM',
21
- fix: 'Use HTML entities (&lt;, &gt;, &quot;) or wrap in curly braces',
22
- documentationLink: 'https://react.dev/learn/javascript-in-jsx-with-curly-braces',
23
- }),
24
- },
25
- schema: [],
26
- },
27
- defaultOptions: [],
28
- create(context) {
29
- return {
30
- JSXText(node) {
31
- const text = node.value;
32
- if (!text.trim()) {
33
- return;
34
- }
35
- if (UNESCAPED_ENTITIES.test(text)) {
36
- context.report({
37
- node,
38
- messageId: 'noUnescapedEntities',
39
- });
40
- }
41
- },
42
- };
43
- },
44
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnescapedEntities=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const UNESCAPED_ENTITIES=/[<>"]/;exports.noUnescapedEntities=(0,eslint_devkit_1.createRule)({name:"no-unescaped-entities",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unescaped-entities.md",description:"Prevent unescaped entities"},messages:{noUnescapedEntities:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unescaped Entity",description:"Unescaped HTML entity in JSX text",severity:"MEDIUM",fix:"Use HTML entities (&lt;, &gt;, &quot;) or wrap in curly braces",documentationLink:"https://react.dev/learn/javascript-in-jsx-with-curly-braces"})},schema:[]},defaultOptions:[],create(context){return{JSXText(node){const text=node.value;if(!text.trim()){return}if(UNESCAPED_ENTITIES.test(text)){context.report({node,messageId:"noUnescapedEntities"})}}}}});