X Tutup
The Wayback Machine - https://web.archive.org/web/20220405130502/https://github.com/nodejs/node-addon-api/pull/823
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

build: add pre-commit package for linting #823

Merged
merged 2 commits into from Nov 9, 2020

Conversation

Copy link
Contributor

@KevinEady KevinEady commented Oct 16, 2020

This extends #819 with a pre-commit hook to run the lint task prior to making a git commit.

For example, after I installed the package and tried to make a commit via:

git commit -m "build: add pre-commit package for linting"

I received this error, because the linting failed:

... output from lint task giving needed code changes ...
+                              0,
+                              1,
+                              testData,
+                              std::function<decltype(AcquireFinalizerCallback)>(
+                                  AcquireFinalizerCallback),
+                              testData);
 
   Object result = Object::New(env);
   result["createThread"] = Function::New( env, CreateThread, "createThread", testData);

      ERROR: please run "npm run lint:fix" to format changes in your commit
pre-commit: 
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit: 
pre-commit:   git commit -n (or --no-verify)
pre-commit: 
pre-commit: This is ill-advised since the commit is broken.
pre-commit: 

I was able to forcefully make the commit by adding the -n flag as mentioned in the error.

@legendecas we discussed that the linter runs on the CI because of cb0764a#diff-6ac3f79fc25d95cd1e3d51da53a4b21b939437392578a35ae8cd6d5366ca5485R57 but i find it odd that your PR #819 succeeded, but my local lint task is failing...?

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Oct 23, 2020

This should land after: #819

Copy link
Member

@mhdawson mhdawson left a comment

LGTM

@legendecas
Copy link
Member

@legendecas legendecas commented Nov 1, 2020

we discussed that the linter runs on the CI because of cb0764a#diff-6ac3f79fc25d95cd1e3d51da53a4b21b939437392578a35ae8cd6d5366ca5485R57 but i find it odd that your PR #819 succeeded, but my local lint task is failing...?

The checks run against the local master ref. So if the local master ref is outdated, the lint will probably fail for those seemingly unrelated lines. In the CI the comparison branch will always be updated, so it will always require the PR to be rebased on the latest main branch commit so that the checks will not complain about unrelated lines.

@mhdawson mhdawson merged commit 2c02d31 into nodejs:master Nov 9, 2020
1 check passed
@legendecas
Copy link
Member

@legendecas legendecas commented Nov 10, 2020

@mhdawson it seems like #819 is not landed before this.

Superlokkus added a commit to Superlokkus/node-addon-api that referenced this issue Nov 20, 2020
* build: add incremental clang-format checks
* build: add pre-commit package for linting
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

3 participants
X Tutup