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

chore(eslint): add unicorn Array rules #2877

Merged
merged 9 commits into from
Sep 25, 2023
Merged

Conversation

csouchet
Copy link
Member

@csouchet csouchet commented Sep 20, 2023

To avoid to have to many changes by enabling plugin:unicorn/recommended, I choose to enable some rule one-by-one.

https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-callback-reference.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-method-this-argument.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-push-push.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-instanceof-array.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-array-destructuring.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-length-check.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-index-of.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-array-join-separator.md

Part of #2824

Covers #2742

@csouchet csouchet added chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) depends on another PR ⚠️ Pull request depending on another one. The depending must be merged first refactoring Code refactoring labels Sep 20, 2023
@github-actions
Copy link

github-actions bot commented Sep 20, 2023

♻️ PR Preview ab4ebac has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@github-actions
Copy link

github-actions bot commented Sep 20, 2023

♻️ PR Preview ab4ebac has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

    no-array-callback-reference
    no-array-method-this-argument
    no-array-push-push
    no-array-reduce
    no-instanceof-array
    no-unreadable-array-destructuring
    no-useless-length-check
    prefer-array-find
    prefer-array-flat
    prefer-array-flat-map
    prefer-array-index-of
    prefer-array-some
    prefer-includes
    require-array-join-separator
- Do not pass function `originalBpmnModel` directly to `.filter(…)`  unicorn/no-array-callback-reference
- Do not use the `this` argument in `Array#filter()`                 unicorn/no-array-method-this-argument

(cherry picked from commit 2c937c77b416b28404f18d12869dae4a30f2e736)
…push

(cherry picked from commit cc69e1111922d7fc931afe6528ffd24179728b09)
….filter(…)`.(unicorn/no-array-callback-reference)

(cherry picked from commit 5b3641b680bc0c81958339ddd812a9826c2e4a24)
@csouchet csouchet removed the depends on another PR ⚠️ Pull request depending on another one. The depending must be merged first label Sep 22, 2023
@csouchet csouchet marked this pull request as ready for review September 22, 2023 11:59
@tbouffard
Copy link
Member

tbouffard commented Sep 22, 2023

⚠️ @csouchet https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-length-check.md advises to use it with https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/explicit-length-check.md#options (which is in recommended config as well)

⚠️ https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md is for ES2019 syntax. As we use TypeScript which is supposed to transpile to ES2015, this may not be an issue (I didn't check).

Copy link
Member

@tbouffard tbouffard left a comment

Choose a reason for hiding this comment

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

The rules are great.
I noticed some potential issues (see my previous comment) to review together.

@csouchet
Copy link
Member Author

⚠️ @csouchet https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-length-check.md advises to use it with https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/explicit-length-check.md#options (which is in recommended config as well)

⚠️ https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md is for ES2019 syntax. As we use TypeScript which is supposed to transpile to ES2015, this may not be an issue (I didn't check).

ℹ️ For prefer-array-flat rule, we already used flat function in the past. So, it's not an issue. 

https://github.com/process-analytics/bpmn-visualization-js/pull/2877/files#diff-b265bdc2a2ac4f04628ee67b5a8b415800ccc5845620f423e95938870bf69c20L30

@sonarcloud
Copy link

sonarcloud bot commented Sep 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@tbouffard tbouffard left a comment

Choose a reason for hiding this comment

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

LGTM

@csouchet csouchet merged commit dafc975 into master Sep 25, 2023
24 checks passed
@csouchet csouchet deleted the 2742-add_unicorn_array_rules branch September 25, 2023 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) refactoring Code refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants