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

fix(eslint-plugin): [space-before-function-paren] incorrect handling of abstract methods #2275

Merged
merged 1 commit into from Jul 6, 2020

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Jul 6, 2020

Fixes #2274

@bradzacher bradzacher added the bug label Jul 6, 2020
@typescript-eslint
Copy link
Contributor

@typescript-eslint typescript-eslint bot commented Jul 6, 2020

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 on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

@codecov codecov bot commented Jul 6, 2020

Codecov Report

Merging #2275 into master will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2275   +/-   ##
=======================================
  Coverage   93.10%   93.10%           
=======================================
  Files         283      283           
  Lines        9024     9024           
  Branches     2467     2467           
=======================================
  Hits         8402     8402           
  Misses        301      301           
  Partials      321      321           
Flag Coverage Δ
#unittest 93.10% <100.00%> (ø)
Impacted Files Coverage Δ
...nt-plugin/src/rules/space-before-function-paren.ts 100.00% <100.00%> (ø)

@bradzacher bradzacher merged commit ced6591 into master Jul 6, 2020
10 checks passed
@bradzacher bradzacher deleted the abstract-space-before branch Jul 6, 2020
@orta
Copy link

@orta orta commented Jul 6, 2020

👋 this just hit us on the typescript codebase, I think I would have expected this to take the named option into account: e.g. these settings:

    "@typescript-eslint/space-before-function-paren": ["error", {
            "asyncArrow": "always",
            "anonymous": "always",
            "named": "never"
        }],
    export abstract class RunnerBase {
        // contains the tests to run
        public tests: (string | FileBasedTest)[] = [];

        /** Add a source file to the runner's list of tests that need to be initialized with initializeTests */
        public addTest(fileName: string) {
            this.tests.push(fileName);
        }

        public enumerateFiles(folder: string, regex?: RegExp, options?: { recursive: boolean }): string[] {
            return ts.map(IO.listFiles(userSpecifiedRoot + folder, regex, { recursive: (options ? options.recursive : false) }), ts.normalizeSlashes);
        }

        abstract kind(): TestRunnerKind;
//                   ^
        abstract enumerateTestFiles(): (string | FileBasedTest)[];
//                                 ^
}

Does that make sense?

@bradzacher
Copy link
Member Author

@bradzacher bradzacher commented Jul 6, 2020

ja that's what this fix is doing.
I didn't think enough about merging the original PR to add support for it, and this PR fixes that.

give the canary tag on npm a go and LMK if there are issues.

@orta
Copy link

@orta orta commented Jul 6, 2020

Cool, it doesn't look like it fixed it:

$ npm install  typescript-eslint@canary     
❯ cat node_modules/@typescript-eslint/eslint-plugin/package.json | grep version
  "version": "3.6.1-alpha.1"
[lint] same

I got a failing test on master too when in the valid section of the tests:

    {
      code: 'abstract class Baz { constructor () {} abstract report(result: number, cwd: string): string | null; }',
      options: [{ named: 'never' }],
    },

It was the constructor () {} causing the fail above. The test seems to pass on master, must be my setup

@bradzacher
Copy link
Member Author

@bradzacher bradzacher commented Jul 6, 2020

ced6591 - the tests are passing fine on the latest master
https://github.com/typescript-eslint/typescript-eslint/actions?query=branch%3Amaster+workflow%3Aci+event%3Apush

and checking out locally for me they're passing fine as well.

Dumping your example code + config into a test also passes fine against master for me:
image

@orta
Copy link

@orta orta commented Jul 6, 2020

Hah, sorry for dragging you along there

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants