Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:07

    platinumazure on issue12080

    (compare)

  • 04:07

    platinumazure on master

    Update: Report '\08' and '\09' … (compare)

  • 04:07
    platinumazure closed #12526
  • 04:07
    platinumazure closed #12080
  • 03:46
    Gaafar synchronize #12191
  • 03:41
    Gaafar commented #12191
  • 03:39
    Gaafar synchronize #12191
  • 03:38
    Gaafar commented #12191
  • 03:36
    Gaafar synchronize #12191
  • 02:46
    mdjermanovic commented #12559
  • 01:59
    mdjermanovic commented #12546
  • 00:21
    ljharb commented #12556
  • 00:14
    mdjermanovic synchronize #12504
  • 00:14

    mdjermanovic on no-dupe-else-if

    Rename variables (compare)

  • 00:11
    josephfrazier commented #12556
  • Nov 12 23:44
    ilyavolodin commented #12558
  • Nov 12 23:21
    ljharb commented #12042
  • Nov 12 23:01
    mdjermanovic commented #12042
  • Nov 12 22:57
    platinumazure commented #12492
  • Nov 12 22:43
    ljharb commented #12042
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

Derek Leung
@drkstersetweets_twitter

Where would I normally have control over how eslint finds definitions for enabled rules? I'm getting errors looking like

ERROR in /Users/.../actions.ts(1,1):
@typescript-eslint/no-triple-slash-reference: Definition for rule '@typescript-eslint/no-triple-slash-reference' was not found.

The setup of the repo I'm contributing to displays errors like this on compile as part of their webpack setup, which uses fork-ts-checker-webpack-plugin, which on version ^1.4.0 supports @typescript-eslint.
When I run ./node_modules/.bin/eslint a-file on the command line, it gives me around 5 rules it can't find definitions for, so for now I've turned them off. Most of them turned out deprecated, but one was an eslint rule that should still exist, no-param-resassign.

Derek Leung
@drkstersetweets_twitter
This might be a really basic question too - I'm wondering, is there a way to turn all errors on enabled rules into warnings, that's faster than manually writing out each rule you want to downgrade? Right now if there's an error, the compiler seems to exit and show only the one error. It'd be far more useful if I could see all errors and warnings so I could fix more together.
Sebastien Guillemot
@SebastienGllmt
Ah I just realized Flow has its own linter called flowlint so maybe better it gets implemented there instead of ontop of ESLint
Jordan Harband
@ljharb
@sebastiengllmt just like tslint, eslint is the best place to do it - it was a mistake for tslint to ever exist in the first place, and it's probably a mistake for flowlint just the same.
PradheepGit
@PradheepGit
@platinumazure Thanks for your response!!
Kai Böse
@Kagu-chan

Hi. we're using eslint@^6.2.0 eslint-config-airbnb-base@^14.0.0 eslint-plugin-import@^2.18.2 in our project. However, setting up automated pipelines with installing modules every time takes time, so we build a docker image which installed the stuff and copy node_modules to our project scope. This works and is faster then using npm i for every pipeline, but still very slow since our packahe.json contains a bit more (framework etc)

Now we tried a docker image, which installs only this three packages globally. So we wont need to have extra node_modules at all for the pure linting in pipeline. But now we're getting errors regarding the airbnb-base config:

Config: extends: 'eslint-config-airbnb-base', (was extends: 'airbnb-base', before, which works both locally)
Error: ESLint couldn't find the config "eslint-config-airbnb-base" to extend from

Why is it complaining / not working, when locally it does? I remember a few versions earlier this worked (but i dont remember which versions we used) - some change i missed?

Nico
@nicoayala

Hello there! First of all, thanks for this great tool
Second, I'm having a weird issue when running the linter:

> eslint .

Oops! Something went wrong! :(

ESLint: 4.19.1.
ESLint couldn't find the plugin "eslint-plugin-ie11". This can happen for a couple different reasons:
...

My eslint dependencies:

    "eslint": "4.19.1",
    "eslint-config-airbnb-base": "13.0.0",
    "eslint-plugin-import": "2.12.0",

npm@6.1.0
node@8.11.3

This began to happen recently
Do you guys have any idea why this could be happening?

Jordan Harband
@ljharb
@nicoayala i don't see that eslint plugin installed locally.
eslint 6 changed resolution rules; so if you were relying on that, best to install it locally intead.
Philip Johnson
@philipmjohnson

Hi all, after upgrading to ESLint 6.4.0, I am getting the error "ESLint couldn't find the config "airbnb-base" to extend from." Running "eslint --debug --ext .js ." yields (in part):

eslint:config-array-factory Loading legacy config file: /Users/philipjohnson/Desktop/hellojavascript/.eslintrc +0ms
  eslint:config-array-factory Config file found: /Users/philipjohnson/Desktop/hellojavascript/.eslintrc +23ms
  eslint:config-array-factory Loading {extends:"airbnb-base"} relative to /Users/philipjohnson/Desktop/hellojavascript/.eslintrc +15ms

Oops! Something went wrong! :(

ESLint: 6.4.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 "/Users/philipjohnson/Desktop/hellojavascript/.eslintrc".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.

So here I am! What do I do next to debug this? Thanks!

Further configuration info:
 $ eslint --version
v6.4.0
~/D/hellojavascript $ sudo npm install -g eslint-plugin-import
npm WARN eslint-plugin-import@2.18.2 requires a peer of eslint@2.x - 6.x but none is installed. You must install peer dependencies yourself.

+ eslint-plugin-import@2.18.2
added 15 packages from 9 contributors, removed 7 packages and updated 20 packages in 4.946s
~/D/hellojavascript $ sudo npm install -g eslint-config-airbnb-base
npm WARN eslint-config-airbnb-base@14.0.0 requires a peer of eslint@^5.16.0 || ^6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb-base@14.0.0 requires a peer of eslint-plugin-import@^2.18.2 but none is installed. You must install peer dependencies yourself.

+ eslint-config-airbnb-base@14.0.0
added 17 packages from 10 contributors, removed 1 package and updated 1 package in 2.315s
Ilya Volodin
@ilyavolodin
ESLint resolves plugins based on the location of the config file. You are installing plugins globally, so they are not found in relationship to your config file. Please install them without -g flag
Philip Johnson
@philipmjohnson
Oh goodness. thanks.
Sebastien Guillemot
@SebastienGllmt
Good news! I finished writing my ESLint rules that provides the no-floating-promise functionality that TSLint implemented. It works both on vanilla Javascript (if your function is marked async) and on Flow (if your function is annotated to return a Promise)
do people think this is an important enough check to submit as a PR to the main ESLint repo or should I make this a one-rule plugin?
the documentation asks me to find a "champion" for the inclusion of this rule so I'm asking here to see if anybody else is passionate about this
Jordan Harband
@ljharb
does it work if you have a non-async function that returns a promise?
Sebastien Guillemot
@SebastienGllmt
only if you can specify the type using Flow