Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:32
    mdjermanovic commented #16391
  • 09:29
    adamreisnz commented #16391
  • 09:26
    mdjermanovic commented #16391
  • 09:26
    mdjermanovic closed #16391
  • 07:57
    jonny64 edited #16392
  • 07:57
    eslint-github-bot[bot] labeled #16392
  • 07:57
    jonny64 opened #16392
  • 05:20
    adamreisnz opened #16391
  • 05:20
    adamreisnz labeled #16391
  • 05:20
    adamreisnz labeled #16391
  • 00:57
    eslint-github-bot[bot] labeled #15755
  • 00:57
    eslint-github-bot[bot] locked #15755
  • 00:57
    eslint-github-bot[bot] labeled #15768
  • 00:57
    eslint-github-bot[bot] locked #15768
  • 00:57
    drazisil commented #16295
  • 00:55
    drazisil closed #16296
  • Oct 05 22:22
    bertie-wheen edited #16390
  • Oct 05 22:17
    bertie-wheen edited #16390
  • Oct 05 21:39
    bertie-wheen labeled #16390
  • Oct 05 21:39
    bertie-wheen labeled #16390
Robert Butler
@lighth7015
No I'm not? At least I shouldn't be.
Robert Butler
@lighth7015
it's literally doing that on it's own, and I want it to stop
Robert Butler
@lighth7015
nevermind that, still broken
Robert Butler
@lighth7015
I guess I'm going to have to not use eslint because I can't make it ignore node_modules.
Jordan Harband
@ljharb
@lighth705 do you have a monorepo?
if so, add “**/node_modules” to your ignorePatterns array in your config
suhas
@suhas60798109_twitter

Hi All, I am new to eslint, I getting below error while trying to run eslint in github actions:

` steps:

  - uses: actions/checkout@v2
  - name: Install modules
    run: yarn
  - name: Run ESLint
    run: yarn run eslint . --ext .js,.jsx,.ts,.tsx`

ESLint couldn't find the plugin "eslint-plugin-@typescript-eslint"

Jordan Harband
@ljharb
you're probably using a too-old version of eslint. you also need @typescript-eslint/eslint-plugin installed.
Caroline Rozali
@hyfydistro
Hi, I've been using this eslint/typescript custom config npm package called "eslint-config-favoritemedium-typescript"
I'm not sure if a lot of things has changed, such as React 18, TypeScript or even eslint. I find myself running into this error
err-00.png

I was trying to run the script from my package.json file:

"lint": "eslint \"**/*.{ts,tsx}\""

But this logged out instead

$ npm run lint

> demo@1.0.0 lint
> eslint "**/*.{ts,tsx}"


Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "D:\UserFile2\Documents\aa-codingplayground\temp\trial-react-chrome-extension\app".)

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

    npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in ".eslintrc.json » eslint-config-favoritemedium-typescript/config/react » D:\UserFile2\Documents\aa-codingplayground\temp\trial-react-chrome-extension\app\node_modules\eslint-config-favoritemedium-typescript\config\react\rules\react-hooks.js".
Caroline Rozali
@hyfydistro
maucou
@maucou
In the eslint configuration of the style guide, the airbnb option does not appear.
does anyone know why this happens?
Levin Keller
@levino
Hey there, I would like to disallow Array.protype.map, Array.prototype.filter etc(). So [1,2].map(x => x + 1) should error. Can this be done without a plugin? Thanks for any tipps.
Jordan Harband
@ljharb
why on earth would you want to disallow those insanely useful methods?
and no, it can't be done reliably because there's no static way to know for sure it's an array
Levin Keller
@levino
I use TS
I want people to use R.map instead
Jordan Harband
@ljharb
then sure, with the type information you could
but also forcing wildly unidiomatic fantasyland FP patterns is not likely to encourage contributors :-)
Levin Keller
@levino
Point taken. The "contributors" are paid however...
I mean, there is 'eslint-plugin-functional'
switch that on and you cannot do anything anymore
that is "over the top" if you ask me :)
whatever, lets call it an "academic exercise"
how would I do it?
Jordan Harband
@ljharb
You could base a rule on that, but also use the TS type info that the TS parser provides to ignore non-array receivers
Jordan Harband
@ljharb
to be clear tho calling it an "academic exercise" doesn't make it not a terrible idea :-)
looks like maybe that rule already uses TS, so it might be really easy
Levin Keller
@levino
So I just copy - paste this code and adjust it a bit?
Jordan Harband
@ljharb
sure, that'd work
Levin Keller
@levino
I kinda get your point really. But on the other hand it is also funny what weird rulesets are out there. "Disallow ECMAScript syntax"... Right, thats the spirit... So I would say: "Whatever works"...
Jordan Harband
@ljharb
right. but .map and friends work. the best.
and sure, there's a bunch of great rules out there and 10 times as many terrible ones
Levin Keller
@levino
I respect your opinion on this. However I find code with chaining (Array.map().filter().map()...) very difficult to test and to refactor so I always have to reorder and rewrite the chains to pipes etc. It is just a nuisance. If one uses a rule like no class then also obviously one prefers functions over methods.
Jordan Harband
@ljharb
i love functional styles, but that just doesn't match my experience. i'm not sure why testing comes into play - the way you produce a function's return value has no bearing on how you assert on that value, and you don't need to test inline callbacks like that.
Levin Keller
@levino

A fellow developer wrote this:

    const fields = [
        locationName(tomTomLocation),
        address.streetName,
        address.streetNumber,
        address.postalCode,
        address.municipality,
        address.countryCode,
    ]
    return fields
        .filter((value, index) => fields.indexOf(value) === index)

What does this code do?

After I while I understood that this is

R.uniq([
        locationName(tomTomLocation),
        address.streetName,
        address.streetNumber,
        address.postalCode,
        address.municipality,
        address.countryCode,
    ])

I am pretty done with these riddles

Actually the original code went on:

    const address = tomTomLocation.address
    const fields = [
        locationName(tomTomLocation),
        address.streetName,
        address.streetNumber,
        address.postalCode,
        address.municipality,
        address.countryCode,
    ]
    return fields
        .filter((value, index) => fields.indexOf(value) === index)
        .filter(RA.isNotNilOrEmpty)
        .join('+')

Here you cannot extract .filter((value, index) => fields.indexOf(value) === index) to investigate it further and add a test or so. (Never mind that it should actually have been .filter((value, index, array) => array.indexOf(value) === index) be context free...) If it were R.filter((value, index, array) => array.indexOf(value) === index) this would have been very simple.

Levin Keller
@levino
Needs to be R.addIndex(R.filter)((value, index, array) => array.indexOf(value) === index)
Jordan Harband
@ljharb
i mean for the first question, it's super obvious - it's trying to do Array.from(new Set(fields)), just badly
so that shouldn't be using R or filter
iow, changing it to your R jumble isn't making it clearer to read, it's obfuscating it.
Levin Keller
@levino
So you see, this is unidiomatic to me, requires "new" (which is forbidden here) and is difficult to put into a pipe. Everybody has their way to think about code...
Jordan Harband
@ljharb
requiring new isn't a problem when an API forces it.
forbidding new outright is foolishness, even though inheritance is trash and should be avoided
Levin Keller
@levino
Now I am struggling to make a no-stream-usage rule which should prevent the usage of Stream.prototype.on because we only want to consume it as an async iterator. I started here https://github.com/brandturbo/eslint-plugin/blob/0c6edd7ecd6be01731bcadb5abe9740831728898/lib/rules/noStreamUsage.ts I am narrowing the event to the method name being "on" but now I need to check whether or not the objects prototype is "ReadableStream" (or any of the other streams, I guess). How can I do this with eslint / typescript-eslint ?