Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 22 23:53
    nzakas commented #11536
  • Oct 22 23:51
    nzakas commented #12475
  • Oct 22 23:50
    yeonjuan commented #12462
  • Oct 22 23:42
    yeonjuan synchronize #12462
  • Oct 22 22:43
    eslint[bot] labeled #11556
  • Oct 22 22:43
    eslint[bot] locked #11556
  • Oct 22 22:43
    eslint[bot] labeled #11632
  • Oct 22 22:43
    eslint[bot] locked #11632
  • Oct 22 22:43
    eslint[bot] labeled #11642
  • Oct 22 22:43
    eslint[bot] locked #11642
  • Oct 22 21:51
    mdjermanovic labeled #12480
  • Oct 22 21:51
    mdjermanovic labeled #12480
  • Oct 22 21:51
    mdjermanovic opened #12480
  • Oct 22 21:51
    mdjermanovic labeled #12480
  • Oct 22 21:35

    mdjermanovic on issue12479

    Update: no-trailing-spaces fals… (compare)

  • Oct 22 20:39
    mdjermanovic unlabeled #12378
  • Oct 22 20:39
    mdjermanovic unlabeled #12280
  • Oct 22 19:06
    mdjermanovic commented #12479
  • Oct 22 17:35
    platinumazure labeled #12477
  • Oct 22 17:35
    platinumazure unlabeled #12477
Jordan Harband
@ljharb
ah, gtk. best to file a vscode issue on that one (i've run into it too)
Ilya Volodin
@ilyavolodin
But that's done through CLI. And I think vscode plugin uses API, which doesn't do multipass by default
And in terms of prettier capabilities, ESLint doesn't accept autofixes that have potential of breaking user's code (or even potentially breaking code), but those are guidelines only for core rules, plugins can do whatever they want. So it would be entirely possible to create a plugin that will contain a set of rules that can be autofix to provide parity with prettier
The only one that might cause major trouble is line-wrapping
Jordan Harband
@ljharb
afaik prettier doesn't have that potential in any of its formatters
since the AST remains the same
Ilya Volodin
@ilyavolodin
Yeah, sorry, I don't know much about prettier, I find idea of somebody rewriting my code constantly unappealing
Jordan Harband
@ljharb
lol i mean, that's autofixing too
they're the same feature, it's just that eslint's autofixing is much slower since it's token-based, and prettier lacks a bunch of configurability
Ilya Volodin
@ilyavolodin
Yes, to a degree.
I mean I'm of the opinion that developers read code about 10x the amount of time they write it. So I never want to end up in a situation where I look at the code after I checked it in, and do not recognize it as mine at all. If I need to confirm to a specific style - that's fine, I'd rather learn how to write code in that style
I use autofix in ESLint when I'm migrating code. It's a one-time action that I'm expecting. I would never enable autofixing on save for any ESLint rule
Jordan Harband
@ljharb
yeah true, i'm similar
Jesse Jackson
@jsejcksn_gitlab

Here's an example of where I'd want an auto-fix for combinations of rules:

eslintrc

{
  "max-len": "warn",
  "object-curly-newline": ["error", {"multiline": true}],
  "object-property-newline": ["error", {"allowAllPropertiesOnSameLine": true}]
}
// 77 < 80: ok - no fix needed
const obj = {prop1: 'value', prop2: 'value', prop3: 'value', prop4: 'value'};

// 93 > 80: not ok - fix needed
const obj = {prop1: 'value', prop2: 'value', prop3: 'value', prop4: 'value', prop5: 'value'};

// auto-fixed
const obj = {
  prop1: 'value',
  prop2: 'value',
  prop3: 'value',
  prop4: 'value',
  prop5: 'value'
};
Perhaps in the future, there will be a way for rules to be aware of each other so that they can provide useful auto-fixes like this.
KathiresanRamkumar95
@KathiresanRamkumar95

Hi

anyone available ?

Wigga
@mshafex_twitter
Hi
need some help with airbnb/base config !
Oops! Something went wrong! :(
ESLint: 6.1.0.

ESLint couldn't find the config "airbnb/base" to extend from. Please check that the name of the config is correct.

The config "airbnb/base" was referenced from the config file in "/home/user/projects/.eslintrc".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
Henning Dieterichs
@hediet
Is there a way to enable autocomplete in .eslintrc files for rule configs?
it seems eslint already knows the schema for the rule, but this information is not forwarded to vscode or other editors.
Domvel
@Domvel

Howdy folks
Just a tiny question:

let hehe = 42;

I use ES3 settings for a very old JS-Engine. (No browser, no node). Whatever...
ESLINT says: Parsing error: Unexpected token hehe. The variable name is marked / underlined.
I expected something like: let is not supported in ES3. It's a ES6 feature. And mark the keyword let.
Or something like that. Why this behavior?

Ilya Volodin
@ilyavolodin
@Domvel This is just a guess, but in ES3, let was not a keyword as far as I remember, so when parser reads it, it assumes it's a variable name, so that's fine, and then it sees another one right after it, and crashes
PradheepGit
@PradheepGit

Oops! Something went wrong! :(

ESLint: 6.4.0.

ESLint couldn't find the plugin "eslint-plugin-myplugin".

(The package "eslint-plugin-myplugin" was not found when loaded as a Node module from the directory "/Users/pradheep-9009".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-myplugin@latest --save-dev

The plugin "eslint-plugin-myplugin" was referenced from the config file in ".eslintrc.js".

Installed my plugin globally. works fine with older version but not working in version 6.4.0
Ilya Volodin
@ilyavolodin
Newer version of ESLint changed the way plugins are resolved. They are not resolved based on the location of the config file
You can try to run eslint with --debug flag to see where it's trying to find your plugin
PradheepGit
@PradheepGit
eslint:config-array-factory Loading plugin "myplugin" from /Users/pradheep-9009/.eslintrc.js +13ms
eslint:config-array-factory Failed to load plugin 'myplugin' declared in '.eslintrc.js'. +0ms
Using --debug flag I got the above message
PradheepGit
@PradheepGit
The plugin works only when I run ESLint in my plugin's directory and not working in any other directory
Domvel
@Domvel
I just wondered because jshint recognized it as es6 feature. But ok, eslint uses parsing error. ... thanks.
Jordan Harband
@ljharb
jshint is many years obsolete at this point.
Kevin Partington
@platinumazure

@Domvel If you set parserOptions.ecmaVersion = 6 (or 2015), it will parse using ES6, but then you get all of the ES6 features.

If you wanted, you could try setting ecmaVersion=6, but then use no-restricted-syntax to lint on other syntax patterns such as rest/spread. Or you could try using eslint-plugin-es, which might or might not have rules to enable what you need.

If ecmaVersion=3, then let will not be parsed as a keyword, as standard ES3 did not specify that behavior (even if some browsers might have allowed it).

Roman
@moltar
Hi, what can go into the overrides section? I tried to find the docs for that, but cannot find anything. Can I override any value from the top level config?
E.g. can I set env for a specific pattern of files?
Can I setup a different parser for specific files? E.g. only use typescript parser for *.ts files?
Kevin Partington
@platinumazure
@moltar There are very few limits- all the cases you described should work
You can't nest overrides and I think there are one or two other config keys that aren't allowed in overrides, but pretty much everything should work.
PRs to improve the documentation here are welcome!
PradheepGit
@PradheepGit
Is it mandatory to provide "--resolve-plugins-relative-to" for my plugin to work?(I have installed my plugin globally)
Jordan Harband
@ljharb
don't install things globally :-)
PradheepGit
@PradheepGit

When I use eslint file.js the below error message appears:
ESLint: 6.4.0.

ESLint couldn't find the plugin "eslint-plugin-myplugin".

(The package "eslint-plugin-myplugin" was not found when loaded as a Node module from the directory "/Users/pradheep-9009".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-myplugin@latest --save-dev

The plugin "eslint-plugin-myplugin" was referenced from the config file in ".eslintrc.js".

Using --debug flag the below message appears:
eslint:config-array-factory Loading plugin "myplugin" from /Users/pradheep-9009/.eslintrc.js +12ms
eslint:config-array-factory Failed to load plugin 'myplugin' declared in '.eslintrc.js'. +1ms
It works only when eslint is run from plugin's directory. But earlier versions allows plugins to run from any CWD.
Dima Tisnek
@dimaqq

Hi channel, is there perhaps a canonical workaround for "unused" variables in for...of?
For example, I have code like this:

async function forever(x) {
  for await (const unused of x) {
    void unused;
  }
}

forever(monitor_network());

As far as I can tell, must have a variable in for...of
But the monitor_network doesn't yield anything useful, the generator style is so that it's easier to test
Up until recently void unused silenced ESLint, but no longer
Is there canonical way to do what I'm trying to?
Is there a known e.g. name for unused that ESLint automatically recognises?

Dima Tisnek
@dimaqq
OK, I've opened eslint/eslint#12287 for this.
Kevin Partington
@platinumazure
@PradheepGit Yes, you must use that flag if your plugins are globally installed and you are using ESLint 6.x
Andrei Neculau
@andreineculau
does anyone know of a rule that works based of another one? my goal is to model a situation where I don't want a rule to activate, unless another rule would report errors. specifically: take object-curly-newline, and imagine that ImportDeclaration would require multiline ONLY IF the line length would trigger a max-len error
I forgot to say that I want to enforce the reverse of that: given that an ImportDeclaration would not exceed x when inlined, I would like to enforce inlining
Kevin Partington
@platinumazure
@andreineculau You could use eslint-rule-composer to take a base rule and filter its reported messages based on any logic. (You won't be able to easily look at the max-len configuration from within the rule, but you could create a module containing configuration-related constants, and then have your ESLint configuration be a JS file that uses that module to generate the max-len rule options.)
Ghost
@ghost~5d7a58ccd73408ce4fcabf04
@ilyavolodin it does, but i couldn't make it work. Anyways thanks for your help friend, i switched to VsCode and it is working perfectly!
Andrei Neculau
@andreineculau
@platinumazure thanks! didn't know about the composer. afaics it would almost work
Sebastien Guillemot
@SebastienGllmt

Hello! I'm looking to try and write my own plugin that uses Flow to check for "floating" promises (promises which are never used or awaited on)
Example:

async function doSomething() { return 5; }
doSomething() // error: missing await

Such a plugin exists for Typescript: https://palantir.github.io/tslint/rules/no-floating-promises/
but no such plugin exists for Flow

I can leverage eslint-plugin-flowtype to get access to Flow type definitions from inside an ESLint plugin. However, (since I've never written an ESLint plugin before) I was wondering if anybody knows a similar existing plugin that I can look at

for example I couldn't find a plugin that simply checks if a function result is unused in the general case.

I think the logic would just be something like
1) Check if the function return is a Promise type
2) Pretend the whole function is one variable X
3) Use the eslint/no-unused-vars to check if X is used anywhere