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: migrate codebase ESLint config #385

Merged
merged 15 commits into from May 18, 2021
Merged

Conversation

Belco90
Copy link
Member

@Belco90 Belco90 commented May 14, 2021

Closes #384

This PR:

  • replace eslint-config-standard by eslint-config-kentcdodds
  • forbid @typescript-eslint/experimental-utils/dist imports with no-restricted-imports
  • does not add eslint-plugin-unicorn to the codebase: it has several rules conflicting others, and some expecting to use node 16
  • updates prettier
  • fix issues generated by previous changes

@Belco90 Belco90 added the chore Changes that affect the build system, CI config or other changes that don't modify src/test files label May 14, 2021
@Belco90 Belco90 self-assigned this May 14, 2021
@Belco90 Belco90 marked this pull request as ready for review May 16, 2021 19:14
lib/node-utils/index.ts Outdated Show resolved Hide resolved
lib/rules/prefer-wait-for.ts Show resolved Hide resolved
.eslintrc.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@Belco90
Copy link
Member Author

Belco90 commented May 17, 2021

I'm getting a new error without updating any dependency now 🤔

Error: Error while loading rule 'import/no-import-module-exports': Cannot find module '/home/runner/work/eslint-plugin-testing-library/eslint-plugin-testing-library/index.js'. Please verify that the package.json has a valid "main" entry
Occurred while linting /home/runner/work/eslint-plugin-testing-library/eslint-plugin-testing-library/commitlint.config.js

And we are getting this error now too on CI. I don't know what's causing that, the CI was passing yesterday (I've checked the lint command locally without changing anything from yesterday and it fails too).

@MichaelDeBoey any idea?

Edit: I've just disabled import/no-import-module-exports for now.

Comment on lines +240 to +245
if (ASTUtils.isVariableDeclarator(node)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return context.getDeclaredVariables(node)[0]?.references?.slice(1) ?? [];
}

return [];
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do an early return instead?

Suggested change
if (ASTUtils.isVariableDeclarator(node)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return context.getDeclaredVariables(node)[0]?.references?.slice(1) ?? [];
}
return [];
if (!ASTUtils.isVariableDeclarator(node)) {
return [];
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return context.getDeclaredVariables(node)[0]?.references?.slice(1) ?? [];

I normally don't like negative conditions, but I'm more in favor of having the "main" thing at the end

Copy link
Member Author

Choose a reason for hiding this comment

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

That would fix it here but could potentially introduce errors in new code, so I've just switched off this rule until there is an option to ignore arrays within conditions.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't suggest it because of the disabling of ESLint, but because

I'm more in favor of having the "main" thing at the end

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sorry, didn't realize that. I don't see any benefit in this case, I guess it's a matter of taste.

@Belco90 Belco90 merged commit 5f734ea into main May 18, 2021
@Belco90 Belco90 deleted the 384_migrate-eslint-config branch May 18, 2021 15:30
@github-actions
Copy link

🎉 This PR is included in version 4.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that affect the build system, CI config or other changes that don't modify src/test files released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate codebase ESLint config
2 participants