Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Turn on some ESLint rules #17

Merged

Conversation

sabina-talipova
Copy link
Contributor

@sabina-talipova sabina-talipova commented Jun 28, 2023

Description

Turn on the following ESLint rules:

General rules:

  • indent: Enforce consistent indentation. Link
  • no-unused-vars: Disallow unused variables. Link
  • no-dupe-keys: Disallow duplicate keys in object literals. Link
  • no-multiple-empty-lines: Disallow multiple empty lines. Link
  • no-unneeded-ternary: Disallow ternary operators when simpler alternatives exist. Link
  • semi-style: Enforce location of semicolons. Link
  • lines-between-class-members: Require or disallow an empty line between class members. Link
  • max-classes-per-file: Enforce a maximum number of classes per file. Link
  • no-param-reassign: Disallow reassigning function parameters. Link

JSX-a11y:

  • jsx-a11y/href-no-hash: Probably was removed from API. Replaced with anchor-is-valid

Import rules:

  • import/order: Enforce a convention in the order of require() / import statements. Link
  • import/no-cycle: Ensures that there is no resolvable path back to this module via its dependencies. Link
  • import/no-unresolved: Ensures an imported module can be resolved to a module on the local filesystem, as defined by standard Node require.resolve behavior. Link
  • import/first: This rule reports any imports that come after non-import statements. Link

React lib rules:

  • react/no-access-state-in-setstateLink
  • react/jsx-fragments Enforce shorthand or standard form for React fragments. Link
  • react/jsx-curly-brace-presence: Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes. Link
  • react/jsx-no-useless-fragment: Disallow unnecessary fragments. Link
  • react/no-unused-state: Disallow definitions of unused state. Link
  • react/no-deprecated: Disallow usage of deprecated methods. Link
  • react/prefer-stateless-function: Enforce stateless components to be written as a pure function. Link
  • react/no-array-index-key: Disallow usage of Array index in keys. Link
  • react/jsx-indent: Enforce JSX indentation. Link
  • react/no-unused-prop-types: Disallow definitions of unused propTypes. Link

Should be reviewed and turned on in the future:

  • import/prefer-default-export: In exporting files, this rule checks if there is default export or not. Link
  • jsx-a11y/anchor-is-valid: The HTML a element, with a valid href attribute, is formally defined as representing a hyperlink. Link
  • jsx-a11y/iframe-has-title: <iframe> elements must have a unique title property to indicate its content to the user. Link
  • comma-dangle: Require or disallow trailing commas. Link
  • arrow-parens: Require parentheses around arrow function arguments. Link
  • prefer-destructuring: Require destructuring from arrays and/or objects. Link
  • func-names: Require or disallow named function expressions. Link
  • react/forbid-foreign-prop-types: Disallow using another component's propTypes. Link
  • react/prop-types: Disallow missing props validation in a React component definition. Link
  • no-restricted-globals Disallow specified global variables. Link
  • jsx-a11y/control-has-associated-label: Enforce that a control (an interactive element) has a text label. Link
  • jsx-a11y/click-events-have-key-events: Enforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress. Link
  • jsx-a11y/no-static-element-interactions: Static HTML elements do not have semantic meaning. Link
  • react/destructuring-assignment: Enforce consistent usage of destructuring assignment of props, state, and context. Link
  • react/button-has-type: Disallow usage of button elements without an explicit type attribute. Link
  • react/sort-comp: Enforce component methods order. Link
  • default-param-last: Enforce default parameters to be last. Link
  • prefer-object-spread: Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead. Link
  • no-redeclare: Disallow variable redeclaration. Link
  • no-else-return: Disallow else blocks after return statements in if statements. Link
  • function-call-argument-newline: Enforce line breaks between arguments of a function call. Link
  • react/jsx-wrap-multilines: Disallow missing parentheses around multiline JSX. Link
  • prefer-promise-reject-errors: Require using Error objects as Promise rejection reasons. Link
  • no-promise-executor-return: Disallow returning values from Promise executor functions. Link
  • react/require-default-props: Enforce a defaultProps definition for every prop that is not a required prop. Link
  • react/default-props-match-prop-types: Enforce all defaultProps have a corresponding non-required PropType. Link
  • react/no-find-dom-node: Disallow usage of findDOMNode. SUPPRESSED FOR NOW. Link

Rules that is still remaining turned off:

  • react/jsx-closing-tag-location: Enforce closing tag location for multiline JSX. Link
  • react/jsx-tag-spacing: Enforce whitespace in and around the JSX opening and closing brackets. Link
  • react/jsx-filename-extension: Disallow file extensions that may contain JSX. Link
  • function-paren-newline: Enforce consistent line breaks inside function parentheses. Link
  • object-curly-newline: Enforce consistent line breaks after opening and before closing braces. Link
  • operator-linebreak: Enforce consistent linebreak style for operators. Link
  • react/jsx-curly-newline: Enforce consistent linebreaks in curly braces in JSX attributes and expressions. Link
  • react/jsx-one-expression-per-line: Require one JSX element per line. Link
  • import/no-extraneous-dependencies: Forbid the import of external modules that are not declared in the package.json's dependencies, devDependencies, optionalDependencies, peerDependencies, or bundledDependencies. The closest parent package.json will be used. Link
  • no-underscore-dangle: Disallow dangling underscores in identifiers. Link
  • react/forbid-prop-types: Disallow certain propTypes. Link
  • class-methods-use-this: Enforce that class methods utilize this. Link
  • no-useless-escape: Disallow unnecessary escape characters. Link
  • jsx-a11y/anchor-has-content: Enforce that anchors have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden prop. Refer to the references to learn about why this is important. Link
  • react/jsx-props-no-spreading: Disallow JSX prop spreading. Link
  • react/no-unused-class-component-methods: Disallow declaring unused methods of component class. Link
  • react/function-component-definition: Enforce a specific function type for function components. Link

Parent issue

@sabina-talipova sabina-talipova force-pushed the pulls/1/turn-on-eslint-rules branch from 9c30030 to 1d82190 Compare July 3, 2023 00:50
@sabina-talipova sabina-talipova marked this pull request as ready for review July 3, 2023 00:54
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have left a general comment that applies to all PRs on the parent issue silverstripe/silverstripe-admin#1433 (comment)

@sabina-talipova sabina-talipova force-pushed the pulls/1/turn-on-eslint-rules branch from 1d82190 to 9c5ffea Compare July 5, 2023 03:04
@emteknetnz emteknetnz changed the title MNT Turn on some ESLint rules NEW Turn on some ESLint rules Jul 9, 2023
@emteknetnz emteknetnz merged commit 2ecc8f3 into silverstripe:1 Jul 9, 2023
@emteknetnz emteknetnz deleted the pulls/1/turn-on-eslint-rules branch July 9, 2023 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants