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

Improve linting #5460

Merged
merged 7 commits into from Jul 12, 2023
Merged

Improve linting #5460

merged 7 commits into from Jul 12, 2023

Conversation

ripecosta
Copy link
Contributor

@ripecosta ripecosta commented Jan 22, 2023

Improves linting configs. Runs linting on the repo.

Details:

  • Prettier now covers every file in the repo
  • On commit hook now runs both Prettier and ESLint
  • CI now fails on both Prettier and ESLint errors
  • ESLint now uses cache - runs faster locally

Note: The ESLint config currently has a blind spot on .mjs and .ts files. Fixing that blindspot is out of scope of this PR.

@coveralls
Copy link

coveralls commented Jan 22, 2023

Coverage Status

coverage: 92.797%. remained the same when pulling 65463ea on ripecosta:rc/linting into ce6b591 on knex:master.

@kibertoad
Copy link
Collaborator

it's failing, workflow yamls shouldn't be modified

@ripecosta
Copy link
Contributor Author

it's failing, workflow yamls shouldn't be modified

I think the issue is the use of "[[" in the npm scripts. Fix incoming.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",
"debug:tape": "node --inspect-brk test/tape/index.js",
"coveralls": "nyc report --reporter=lcov",
"lint": "eslint \"lib/**/*.js\" \"test/**/*.js\" \"bin/**/*.js\"",
"lint": "eslint --cache --fix '**/*.js'",
Copy link
Collaborator

Choose a reason for hiding this comment

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

lint by definition is about checking, it would be better to have explicit lint:fix command for fixing.
And CI shouldn't be running it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. But you'll end up with two different patterns for similar things. For ESLint you'll need ":fix" to make changes but not for Prettier. And for Prettier you'll need ":check" for check-only but not for ESLint.

Given the formatter and linter will always both run (in check-mode for CI and fix-mode locally) does it not make more sense to a) follow the same script naming pattern; and b) be joined the same command ?

@OlivierCavadenti OlivierCavadenti merged commit a37f4f1 into knex:master Jul 12, 2023
53 checks passed
@ripecosta ripecosta deleted the rc/linting branch July 13, 2023 08:35
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.

None yet

4 participants