Live data from Hacker News

ESLint 7.0

eslint.org

21–30 of 93 posts

Re: ESLint 7.0

#21
post #10

I have been waiting for this release for the new possibility to include a comment in eslint-disable-{next-}line: // eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. console.log('hello'); https://eslint.org/docs/user-guide/configuring#disabling-rul...

Yo dawg, heard you like comments

Re: ESLint 7.0

#22
post #12
post #10

I have been waiting for this release for the new possibility to include a comment in eslint-disable-{next-}line: // eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. console.log('hello'); https://eslint.org/docs/user-guide/configuring#disabling-rul...

How is that different than: // Here's a description about why this configuration is necessary. // eslint-disable-next-line no-console console.log('hello');

You could be commenting functions too (day JSDoc it TSDoc) but also want to do an eslint-ignore. It looks better then, IMO.

Re: ESLint 7.0

#23
post #12
post #10

I have been waiting for this release for the new possibility to include a comment in eslint-disable-{next-}line: // eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. console.log('hello'); https://eslint.org/docs/user-guide/configuring#disabling-rul...

How is that different than: // Here's a description about why this configuration is necessary. // eslint-disable-next-line no-console console.log('hello');

Well, it's on one line for starters ;)

Looking at one suppression in one place it doesn't make a big difference.

It will help a lot with whole-project search results, though, if you're trying to e.g. fix all the places you had to suppress X because of Y.

Re: ESLint 7.0

#24
post #7

There is a rule in eslint that warns you when a promise is dangling and hasn't been handled. Please use that rule . So many bugs in the JS world is because of dangling promises.

I can't speak to the front-end, but there are plenty of situations in dealing with node where the correct thing to do is to throw a fatal error. If you have properly setup handlers for the end of the process lifecycle I don't see what the problem is.

Re: ESLint 7.0

#25
post #4

I haven't done TypeScript/JavaScript in a while. What's the status of ESLint taking over from TSLint (for both the tool itself and the vscode extensions)?

Have exclusively used ESLint for TypeScript over the past year. It works great, no issues. The only slight problem is some rules conflict, but that only comes into play if using a comprehensive preset like airbnb.

Re: ESLint 7.0

#26
post #12
post #10

I have been waiting for this release for the new possibility to include a comment in eslint-disable-{next-}line: // eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. console.log('hello'); https://eslint.org/docs/user-guide/configuring#disabling-rul...

How is that different than: // Here's a description about why this configuration is necessary. // eslint-disable-next-line no-console console.log('hello');

In short: it's more comfortable and more versatile.

1. Sometimes there's already a comment on the preceding line commenting the logic, and the new comment explaining ESLint would have to go awkwardly in-between.

2. Sometimes it's just complicated to word the comment if it can't be on the same line.

3. Sometimes eslint-disable-line is in a place where it would be ugly to have a comment above. Here are two examples from my current project, both from cases where the disable is right after a closing curly brace:

  } as any // eslint-disable-line @typescript-eslint/no-explicit-any

  }, [map]); // eslint-disable-line react-hooks/exhaustive-deps
Other cases can be found in the issues:

Feature request #1: https://github.com/eslint/eslint/issues/11298

Feature request #2: https://github.com/eslint/eslint/issues/11806

RFC: https://github.com/eslint/rfcs/tree/master/designs/2019-desc...

Next up: an ESLint rule that makes the comment obligatory for disable directives.

Re: ESLint 7.0

#27
post #7

There is a rule in eslint that warns you when a promise is dangling and hasn't been handled. Please use that rule . So many bugs in the JS world is because of dangling promises.

I can't speak to the front-end, but there are plenty of situations in dealing with node where the correct thing to do is to throw a fatal error. If you have properly setup handlers for the end of the process lifecycle I don't see what the problem is.

But until recently an unhandled promise failure was NOT a thrown error, and when it is it's not the error you want.

Re: ESLint 7.0

#28

Ah ESLint, the most necessary bane of my existence. Good work to the team for the update.

I just could not deal with such an opinionated tool. ESLint would not let us adjust settings to accept some of our normal convection's and company code style guidelines.

I switched to jshint and have lived a much happier life.

Re: ESLint 7.0

#30
post #7

There is a rule in eslint that warns you when a promise is dangling and hasn't been handled. Please use that rule . So many bugs in the JS world is because of dangling promises.

If you add a catch block it will be even worse, all errors inside a promise callback will then become soft errors. Only add the catch if you actually plan to handle the error.
Post reply on HN