Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:18
    eslint[bot] labeled #11508
  • 22:18
    eslint[bot] locked #11508
  • 21:13
    mdjermanovic labeled #12414
  • 21:13
    mdjermanovic labeled #12414
  • 21:13
    mdjermanovic labeled #12414
  • 21:13
    mdjermanovic unlabeled #12414
  • 21:12
    mdjermanovic labeled #12163
  • 21:12
    mdjermanovic unlabeled #12163
  • 21:11
    mdjermanovic labeled #12410
  • 21:11
    mdjermanovic labeled #12410
  • 21:11
    mdjermanovic labeled #12410
  • 21:11
    mdjermanovic unlabeled #12410
  • 20:46
    mdjermanovic commented #12419
  • 19:19
    fabiospampinato edited #12424
  • 19:18
    fabiospampinato edited #12423
  • 19:18
    fabiospampinato edited #12423
  • 19:18
    fabiospampinato edited #12423
  • 19:18
    fabiospampinato edited #12423
  • 19:17
    fabiospampinato edited #12422
  • 19:16
    fabiospampinato edited #12421
Jordan Harband
@ljharb
so what i'd prefer to do is pursue better autofixes in eslint rules so that prettier can become 100% unnecessary ¯\_(ツ)_/¯
prettier-eslint is a good hack, but as you said, it's not supported anymore anyways
Jesse Jackson
@jsejcksn_gitlab

I agree with all of this. Is there a project which exists to aid with formatting based on eslint rules? Like a shared config that duplicates the prettier functionality with as much coverage as possible?

There are just certain ESLint rules that can definitely auto-fix my code given some criteria, but I don't really know where to begin to write a plugin in order to make that happen. I'm happy with the way prettier-eslint did it.

Without the input preferences, ESLint can't auto-fix and I'm left with manually having to format my code.
Jordan Harband
@ljharb
@jsejcksn_gitlab i mean, https://npmjs.com/eslint-config-airbnb is the most used one by any metric
both are based off the same style guide, which reflects the most common conventions in the overall ecosystem.
or at least, almost entirely reflects :-)
Jesse Jackson
@jsejcksn_gitlab
@ljharb Thanks. Peripherally-related: Is there a "serial auto-fix" feature for ESLint? In VS Code, I often have to hit cmd-S multiple times to get to the end of the auto-fixes.
Jordan Harband
@ljharb
not that i know of. it just takes multiple passes sometimes.
Ilya Volodin
@ilyavolodin
@jsejcksn_gitlab I think that's vscode implementation issue. ESLint does multipass autofix (i.e. it will keep fixing issues until either none are left, or the number of errors doesn't decrease).
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".