Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:23
    mdjermanovic edited #14011
  • Jan 23 23:46
    mdjermanovic commented #14030
  • Jan 23 23:46
    mdjermanovic converted_to_draft #14030
  • Jan 23 23:42
    mdjermanovic labeled #14030
  • Jan 23 23:42
    mdjermanovic labeled #14030
  • Jan 23 23:42
    mdjermanovic labeled #14030
  • Jan 23 23:42
    mdjermanovic labeled #14030
  • Jan 23 23:42
    mdjermanovic unlabeled #14030
  • Jan 23 23:40
    eslint[bot] labeled #14031
  • Jan 23 23:40
    nvuillam opened #14031
  • Jan 23 22:46
    JoakimoNilsson synchronize #14030
  • Jan 23 22:45
    eslint[bot] commented #14030
  • Jan 23 22:44
    JoakimoNilsson synchronize #14030
  • Jan 23 22:40
    eslint[bot] commented #14030
  • Jan 23 22:40
    JoakimoNilsson synchronize #14030
  • Jan 23 22:36
    eslint[bot] commented #14030
  • Jan 23 22:36
    eslint[bot] labeled #14030
  • Jan 23 22:36
    JoakimoNilsson opened #14030
  • Jan 23 21:40
    mdjermanovic commented #14029
  • Jan 23 21:22
    mdjermanovic labeled #14029
Hamid
@hamidyfine

Hi,
Is anyone getting into this error?

No files matching the pattern "" were found.

eslint: 7.16.0

Matthew
@MatthewS2077
Hi... is there any way to have eslint catch the missing () ie, if the programmer forgets to add () to a function it is never called.
function foo() { return false; }
if (!foo()) { console.log('foo is false'); }
if (!foo) { console.log('foo is defined, so this then clause is never executed'); }
Matthew
@MatthewS2077
so I'm talking about this line, if (!foo) { console.log('foo is defined, so this then clause is never executed'); } ie, !foo instead of !foo() the programmer forgot the ()
Jordan Harband
@ljharb
no, because that’s not necessarily a mistake
functions are first-class values, and are often used as one.
Matthew
@MatthewS2077

no, because that’s not necessarily a mistake

hmm... but TS since 3.7 will warn if i use if (foo) with a warning like "did you mean foo()" but not warn with if (!foo).... seems to me TS should also warn in both cases

Jordan Harband
@ljharb
TS can choose to warn on whatever it likes, but TS not being a superset of JS means that TS already doesn't map nicely to JS
if you want TS to warn in different cases, you'd need to file an issue on their repo
Matthew
@MatthewS2077
yes thanks... do you know if eslint has a rule for this? i couldn't find one... can u see how it's difficult bug to catch? if the dev forgets the () ie if (!foo) instead of if (!foo())
Jordan Harband
@ljharb
i see how it's a difficult bug if you're in the bad habit of avoiding intermediate variables :-)
but also no, it's not possible for an eslint rule to catch this, except with type information.
since there's no way to statically know foo is a function without type information
Matthew
@MatthewS2077

i see how it's a difficult bug if you're in the bad habit of avoiding intermediate variables :-)

so like this?

function foo() { console.log('in foo'); return false; }
const x = foo;
if (!x) { console.log('this is never executed'); }

same problem... but thanks for your witticism 🤦‍♂️

Jordan Harband
@ljharb
const x = foo()
Matthew
@MatthewS2077

const x = foo()

yes, yes i get it... my point is what if the dev forgets the () and writes const x=foo then if (!x) fails because TS doesn't warn This condition will always return true since the function is always defined. Did you mean to call it instead?(2774)

with if (x) TS does issue the warning... that's great... BUT with if (!x) TS does NOT issue the warning.... surely this is a TS bug? it should warn in both cases

so anyway.... does eslint have a rule to catch this... i guess not?

Jordan Harband
@ljharb
it's not possible for eslint to catch it, unless TS is used
and most JS devs don't write TS.
so perhaps the typescript eslint plugin could have a rule for it, but otherwise TS itself would have to.
Aaron Ponce
@amponce
Does anyone know if nvm causes issues with eslint? My team has a custom file and it was working recently but yesterday I switched over to node 14 and now I can't get eslint to work for the life of me
Jordan Harband
@ljharb
@ampomce it shouldn’t (i maintain nvm)
how are you running eslint?
make sure it works on the command line, editors are always a different beast
Aaron Ponce
@amponce
we use vs code at work, I use the intergrated terminal and it's always worked fine with npm run lint filename.js
but now it fails every time
Aaron Ponce
@amponce

make sure it works on the command line, editors are always a different beast

I'll give that try, thank you

Jordan Harband
@ljharb
meaning if you can get it working on the real CLI, then it's an issue with your editor
for vscode, i think by default it ships with its own copy of node, so you might need to configure it to point to nvm's node
Martin Törnqvist
@toerndev
I'm trying to understand the anatomy of vue-eslint-parser + @typescript-eslint/parser, is there typically a way to print human-readable ASTs from anywhere in the plugin code so one can see what's going on?
Martin Törnqvist
@toerndev
Alternative question, or the reason I'm asking: Does anyone know whether vue-eslint-parser strips TypeScript from the AST returned by @typescript-eslint/parser for parseForESLint(vueScriptTag), before processing Vue rules? Trying to understand the best approach for dealing with TypeScript inside a non-standard file format.
2 replies
Adam Eisenreich
@Akxe
Hi, I would like to ask. After syncing my settings in VS Code, I don't know what changed, but now ESLint cannot find C:\.eslintrc.json (stakctrace: C:\Users\akxe\Documents\programming\rita\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:172:35) . The config is at C:\Users\akxe\Documents\programming\rita\.eslintrc.js.
The log is from the VS Code extension output, I don't know how to pass it arguments, not I don't know what argument to pass to it...
Karan Ganesan
@karanganesan
Hi I am trying to write a eslint rule
so what I am trying to do is
the rule make sure the number of times a dependency is used for say X number
is it possible to do something like this?
Jordan Harband
@ljharb
what's the value in limiting it to an arbitrary number?
Jordan Harband
@ljharb
that seems right to me
Dheeraj
@dheerajsh

Hi @here, gettting this strange issue on a Nestjs project I am working on
ESLint: 7.18.0

TypeError: Cannot read property 'range' of null Occurred while linting /Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/src/modules/elastic-sync/elastic-sync.module.ts:15 at SourceCode.getTokenBefore (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/source-code/token-store/index.js:298:18) at Object.isParenthesised (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/rules/utils/ast-utils.js:511:38) at findClosingParen (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/rules/arrow-body-style.js:97:30) at Object.fix (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/rules/arrow-body-style.js:250:57) at normalizeFixes (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/linter/report-translator.js:178:28) at /Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/linter/report-translator.js:347:49 at Object.report (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/linter/linter.js:920:41) at validate (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/rules/arrow-body-style.js:220:29) at ArrowFunctionExpression:exit (/Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/rules/arrow-body-style.js:281:17) at /Users/dheeraj/code/propertyguru/prefix-search/prefix-search-sync/node_modules/eslint/lib/linter/safe-emitter.js:45:58

elstic-sync.module.ts at line 15 looks like this

Screen Shot 2021-01-22 at 11.16.16 AM.png
any help is appreciated
Alex Van Liew
@snoozbuster
hey guys. I have eslint set up in a monorepo, but a few of the projects use different eslint configurations with packages that aren't installed at the repo root. These packages have their own eslintrc files with root: true and the paths are ignored with --ignore-pattern, but eslint still attempts to load the eslintrc files and then complains that the rules aren't found (even though all the lintable files in that directory are ignored). is there a way to avoid letting eslint parse these files in this case?
I'd like to avoid having to install linting plugins at the repo root that aren't ever actually used.
Jordan Harband
@ljharb
@snoozbuster why would the plugins not be present in those projects package.jsons?
they should be there relative to the config file, even if not in the root
Alex Van Liew
@snoozbuster
they are present relative to their config file but they don't get picked up
oh, actually... I could be wrong about that. I would need to look at our build config - it might not do an npm install for these projects with the different configuration. is the expectation that eslint will use packages from a node_modules/ in the same folder that it finds a eslintrc?
Jordan Harband
@ljharb
@snoozbuster it is expected that the entire tree is fully npm installed, yes
that’s how monorepos work.
Alex Van Liew
@snoozbuster
@ljharb and when the entire tree is installed, eslint will look in the node_modules/ relative to the root eslintrc for a given project to find the referenced
plugins?