Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [no-unused-vars] fork the base rule#2768

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 2 commits intomasterfromfork-no-unused-vars
Nov 24, 2020

Conversation

bradzacher
Copy link
Member

@bradzacherbradzacher commentedNov 16, 2020
edited
Loading

I wanted to avoid doing this, but not doing this restricts our logic too much - it causes problems when we want to consider reporting on things that the base rule wouldn't report on.

By forking this logic - it also opens the door to using this innaming-convention to detect unused variables.

Fixes#2782
Fixes#2714
Fixes#2648
Closes#2679

hjdivad and dentuzhik reacted with hooray emojiHolgerJeromin, hjdivad, jonaskello, and dentuzhik reacted with heart emoji
@bradzacherbradzacher added enhancementNew feature or request DO NOT MERGEPRs which should not be merged yet labelsNov 16, 2020
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day.

@codecov
Copy link

codecovbot commentedNov 16, 2020
edited
Loading

Codecov Report

Merging#2768 (40e40c4) intomaster (c2dde58) willdecrease coverage by0.03%.
The diff coverage is91.88%.

@@            Coverage Diff             @@##           master    #2768      +/-   ##==========================================- Coverage   92.80%   92.76%   -0.04%==========================================  Files         300      301       +1       Lines        9857    10150     +293       Branches     2769     2870     +101     ==========================================+ Hits         9148     9416     +268- Misses        332      345      +13- Partials      377      389      +12
FlagCoverage Δ
unittest92.76% <91.88%> (-0.04%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
...ges/experimental-utils/src/ts-eslint/RuleTester.ts100.00% <ø> (ø)
packages/experimental-utils/src/ts-eslint/Scope.ts100.00% <ø> (ø)
...ges/experimental-utils/src/ast-utils/predicates.ts36.84% <20.00%> (-1.62%)⬇️
...ckages/scope-manager/src/referencer/VisitorBase.ts85.29% <75.00%> (-4.00%)⬇️
...s/eslint-plugin/src/util/collectUnusedVariables.ts91.10% <91.10%> (ø)
packages/eslint-plugin/src/rules/no-unused-vars.ts96.62% <98.95%> (+3.48%)⬆️

I wanted to avoid doing this, but not doing this restricts our logic too much - it causes problems when we want to consider reporting on things that the base rule wouldn't report on.Fixes#2714Fixes#2648Closes#2679
@bradzacherbradzacher removed the DO NOT MERGEPRs which should not be merged yet labelNov 23, 2020
@bradzacherbradzacherforce-pushed thefork-no-unused-vars branch 2 times, most recently from702650d to3478bb1CompareNovember 23, 2020 21:44
@bradzacherbradzacher marked this pull request as ready for reviewNovember 24, 2020 00:45
@bradzacherbradzacher merged commita8227a6 intomasterNov 24, 2020
@bradzacherbradzacher deleted the fork-no-unused-vars branchNovember 24, 2020 00:45
bradzacher added a commit that referenced this pull requestNov 24, 2020
Fixes#1510Leverages the infra added in#2768 to mark variables as unused
bradzacher added a commit that referenced this pull requestNov 24, 2020
Fixes#1510Leverages the infra added in#2768 to mark variables as unused
@dentuzhik
Copy link

dentuzhik commentedDec 8, 2020
edited
Loading

Hey 👋🏼

Sorry if this is not a correct channel to ask this, I can raise a separate issue as well, just let me know :)

Can you please help out to understand better the relation between this rule, newnaming-convnention options and theno-unused-vars-experimental?

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md

Up to4.7.0 we had to useno-unused-vars-experimental because of the case ofconst foo = (_myUnusedVar, myUsedVar) => {}, but I see that experimental rule gets no development and wondering if a newunused parameter introduced in#2810 innaming-convention fixes the case.

We currently have this, but as I understand we can change it to some combo of post4.9.0 non-experimental rules, right?

{// While main rules works, it reports errors in places where TS would not complain, like underscored variables e.g. _actions// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md//// Experimental rule seems to be aligned better with TS itself// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md'no-unused-vars':[OFF],'@typescript-eslint/no-unused-vars-experimental':[ERROR],}

Seems like documentation forno-unused-vars could maybe be a bit more clear on if and how it is expected to be combined withnaming-convention, I can help out with PR as well

@HolgerJeromin
Copy link

My understanding is this:
The no-unused-vars-experimental version was kind of a technology experiment which rebuilt the rule on a different technical base.
This no-unused-vars is another way to do it.
As the policy is to never delete a rule we now have both usable.

@bradzacher
Copy link
MemberAuthor

This is explained in#1856

HolgerJeromin and dentuzhik reacted with thumbs up emoji

@@ -4,11 +4,33 @@ import {
TSESTree,
} from '@typescript-eslint/experimental-utils';
import { PatternVisitor } from '@typescript-eslint/scope-manager';
importbaseRulefrom 'eslint/lib/rules/no-unused-vars';
import{ getNameLocationInGlobalDirectiveComment }from 'eslint/lib/rules/utils/ast-utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

this line breaks using eslint@5, which is supported:

"eslint":"^5.0.0 || ^6.0.0 || ^7.0.0"

Copy link
Contributor

@SimenBSimenBDec 18, 2020
edited
Loading

Choose a reason for hiding this comment

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

seejest-community/eslint-plugin-jest#732 for CI failure

    Cannot find module 'eslint/lib/rules/utils/ast-utils'    Require stack:    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/index.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/eslint/lib/config/plugins.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/eslint/lib/config.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/eslint/lib/cli-engine.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/eslint/lib/api.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/jest-runner-eslint/build/runner/runESLint.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/create-jest-runner/build/createJestRunner.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/create-jest-runner/build/index.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/jest-runner-eslint/build/runner/index.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/@jest/core/build/TestScheduler.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/@jest/core/build/jest.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/jest-cli/build/cli/index.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/jest-cli/bin/jest.js    - /home/runner/work/eslint-plugin-jest/eslint-plugin-jest/node_modules/jest/bin/jest.js

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 18, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@SimenBSimenBSimenB left review comments

Assignees
No one assigned
Labels
enhancementNew feature or request
Projects
None yet
Milestone
No milestone
4 participants
@bradzacher@dentuzhik@HolgerJeromin@SimenB

[8]ページ先頭

©2009-2025 Movatter.jp