Skip to content

@typescript-eslint/semi function declarations should have semi at end, throws error #971

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

Closed
ctfrancia opened this issue Sep 12, 2019 · 5 comments
Labels
awaiting response Issues waiting for a reply from the OP or another party package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ctfrancia
Copy link

ctfrancia commented Sep 12, 2019

Repro

module.exports =  {
  parser:  '@typescript-eslint/parser', 
  extends:  [
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'prettier/@typescript-eslint',
    'plugin:prettier/recommended',
  ],
 parserOptions:  {
    ecmaVersion:  2018, 
    sourceType:  'module',
  },
  rules:  {
    "semi": "off",
    "@typescript-eslint/semi": ["error"]
  },
};
public someFunc = (input: string): string | null => {
  //some code
}; // <--- ERROR: Unnecessary semicolon

Expected Result
I would like to have it recognize that it's a definition and therefore a semicolon is ok

Actual Result
error as stated above. Whenever I try to remove the semi colon then there is a prettier issue and when I save the semi colon is placed back, which makes sense.

const obj = {
  foo: 'bar',
}; 
const func = () => {
 return true;
}; ❗️

Additional Info
this is a cross post

I would like to note that I have tried many different possibilities with rules, adding, removing, etc.
tried following this section to disable it/allow a semi colon at the end

Versions

package version
@typescript-eslint/eslint-plugin 1.13.0
@typescript-eslint/parser 1.13.0
TypeScript 3.6.3
ESLint 6.3.0
node 12.7.0
npm 6.10.2
@ctfrancia ctfrancia added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 12, 2019
@JamesHenry
Copy link
Member

JamesHenry commented Sep 12, 2019

@ctfrancia the whole idea behind using the prettier plugins is that you don’t use style based rules like that - behind the scenes it’s letting your prettier setup handle it. You should remove the rules: {} config you currently have and everything should work as expected.

Feel free to reopen if that does not solve your issues

@ctfrancia
Copy link
Author

@JamesHenry thank you for your reply, however, as you could imagine, I didn't just run into the first sign of trouble and decide to open up an issue for it. I have previously had the rules section empty and still the issue persists. I don't want to bombard the thread with the minutiae of every variant I've tried

@JamesHenry
Copy link
Member

Please provide a full repro so we can help you out

@JamesHenry JamesHenry reopened this Sep 12, 2019
@JamesHenry
Copy link
Member

I can see you are using an old version of our packages, it could be that you are using older versions of the others as well, or the combination of versions you are using are incompatible. Right now there is not enough information, but it should hopefully be quite quick to prepare a minimal reproduction.

Thanks!

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for team members to take a look labels Sep 12, 2019
@bradzacher
Copy link
Member

I'm unable to reproduce this against master.
We have passing tests in master for this as well.

`
class Class {
prop: string;
}
`,
`
abstract class AbsClass {
abstract prop: string;
abstract meth(): string;
}
`,
`
class PanCamera extends FreeCamera {
public invertY: boolean = false;
}
`,

{
code: `
class Class {
prop: string;
}
`,
errors: [
{
line: 3,
},
],
},
{
code: `
abstract class AbsClass {
abstract prop: string;
abstract meth(): string;
}
`,
errors: [
{
line: 3,
},
{
line: 4,
},
],
},
{
code: `
class PanCamera extends FreeCamera {
public invertY: boolean = false;
}
`,
errors: [
{
line: 3,
},
],
},

Support for class properties was added in #409


This is not a bug within the plugin - something is misconfigured on your end.

You should try using the --print-config flag to help debug what the resolved config for the offending file is (it will print out the full json config, as it looks after all extensions are applied).

I'm going to close this for housekeeping purposes, as it's not an active bug within the plugin.
We'll ofc continue to help you in this thread with a bit more info!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants