-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Apply Linting Only to Files Updated in git
#1548
Comments
git
can i work on it? |
@Nitya-Pasrija Please be aware of this issue |
Hi! Can I please work on this issue? |
I have setup and initialised lint-staged for the repo, in order to convert lint rules from "warn" to "error" , should it be done right now or should I wait for approval? @anwersayeed @tasneemkoushar |
@palisadoes I have setup lint-staged (to apply linting to only changed files for every commit). Should I proceed with changing the lint rules from 'warn' to 'error', as I am not sure if this is what was intended to be fixed by this issue. |
Yes, we want:
|
@NamitBhutani Context |
Extremely sorry! I'll look into it. |
@palisadoes The reason the tests are failing for each PR (including this one) is because we have edited the eslintrc.json, thus when npm run lint:check is ran, it uses the updated eslint rc file with errors instead of warns. We will need to update the github actions or make another eslintrc.json file for github workflows. |
The GitHub action used errors before. Browse the repository a week ago to see the differences in the files you mention then you'll be better able to see what happened It definitely used errors before, and ran against each file submitted in the PR as part of a for loop |
According to my understanding the job "Check for linting, formatting, and type errors" uses @actions/checkout and then runs the npm run lint:check which is essentially eslint . --max-warnings=1500, i.e it uses the eslintrc.json and as I have edited it to contain errors instead of warnings, that is why the action is erroring. |
How can we get this to work in the same way as proposed in Talawa Admin where we lint the code with increasing severity until we get it to the desired standard? Here is what they are planning. |
For example would it be easier to split this up into multiple issues each handling a different linting rule? |
I feel if we want to keep the PR workflow consistent, we can rather make a separate eslintrc.json for running on staged files (like I mentioned before but not for the PR workflow) with errors and revert the current eslintrc.json to have "warns" instead. |
Can we do linting for files committed in the local branch with errors, and do the same for the updated files in the PR? If not, then we'll need to create issues per lint rule and close this one. Can you implement the incremental approach in both scenarios? It hasn't looked promising so far. |
I will try my best to update the PR workflow too , to accommodate for updated files only instead of all the files! |
@NamitBhutani Your fix is failing it seems. |
We can't merge Family Members until this is fixed unfortunately |
Click on the arrow and you see that it failed, but didn't stop the workflow |
We have a similar PR linting feature in Admin. Check that YAML file for inspiration |
I feel that this is something to do with how its fast-forwarding the branch with the develop change we made to fix it, I have one more solution, we can try that too, if you allow. |
@EshaanAgg should I make a PR right now if you will be able to merge it? |
@NamitBhutani Just to help you.
|
Lint-staged only works in the pre-commit situation, i.e. when the files are staged ( as the name suggests). As here no files are staged, it won't work. |
Please also verify in Talawa Admin. I'd like to know how to standardize the typescript linting workflows |
Should we then lint on commit too, to prevent committing from being done? |
We already have that in pre-commit file. |
@NamitBhutani Are you sure this is working? We need to merge this PR, that initially discovered the problem |
Is it in the main or the develop branch of Talawa admin ? |
Develop |
They are using pre-made GitHub actions for checking the changed files, while we are using the git diff command in talawa-api. |
|
Actually, we have something similar created. You may want to provide some guidance here |
Yes! Sure |
Sure, I will look into it. |
@NamitBhutani I am the one who opened the pr Can you provide some guidance??? |
@NamitBhutani Your git linting seems to be failing again. Pleases take a look. |
I feel that using git diff is a bad approach as there are a lot of exceptions that rise up, we'll have to change that from the talawa-api too. We need to use the github action already being used in talawa-admin. You can look into the documentation https://github.com/marketplace/actions/changed-files#outputs- and implement it for talawa-admin. |
I'll soon make another PR to try fixing it. |
@NamitBhutani @palisadoes what about linting on only added files and not modified fields with a seperate eslint config especially for the action??? Example: |
Closing. This should be fixed. |
We need the ability to selectively adjust our linting rules so that they are eventually applied to our entire code base.
.eslintrc.json
file.warn
toerror
then every file in the code base will be checked and we have frequently seen our tests fail for dozens of files in hundreds of lines of code.This is not acceptable.
We have been trying to more strictly lint the entire code base manually, but it has been very slow.
At the user CLI
We need a way to edit
.eslintrc.json
with increasingly stricter linting rules in such a way that the tests are only applied to the changed files with everygit commit
andgit push
command.These
git
commands must fail if the linting fails.With Every Pull Request
We recently merged a Talawa-API pull request that checks each submitted file for linting compliance. This can be used as an example of how to run the test against individual files.
You must make sure that this functionality applied for all PRs for this repository whenever the
.eslintrc.json
file is updatedOther
git
talawa-admin#1270Screenshots
When complete, you should be able to convert all these
.eslintrc.json
file lines containingwarn
toerror
and the tests will only be applied to the changed files ingit
The text was updated successfully, but these errors were encountered: