Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Questions #726

Closed
hasezoey opened this issue Aug 8, 2019 · 24 comments
Closed

Some Questions #726

hasezoey opened this issue Aug 8, 2019 · 24 comments
Labels
info-needed Issue requires more information from poster

Comments

@hasezoey
Copy link

hasezoey commented Aug 8, 2019

Context: i wanted to upgrade from "tslint" (& vscode-tslint(deprecated version)) to eslint & vscode-eslint, but came to these errors

after using https://github.com/typescript-eslint/typescript-eslint i got some errors:

  1. "cannot find .eslintrc.json" - fixed by "eslint.options": {"useEslintrc": false}
  2. Invalid ecmaVersion #725 - i didnt got it fixed
  3. "cannot find /home/hasezoey/tsconfig.json" - somehow, the vscode-eslint version tries to resolve "parserOptions": {"project": "tsconfig.json"} in the home directory, and not the work directory...

so i wanted to ask if someone knows how to fix all these errors...

PS: sorry if this is some duplicates of some issues, just couldnt find any fix for these

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

I created a test workspace myself and I can't reproduce any of the problems you described.

Here is what works for me:

capture

Any additional information you can provide to make this reproducible for me. Best would be a GitHub repository to clone.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Aug 8, 2019
@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

Best would be a GitHub repository to clone.

https://github.com/hasezoey/typegoose/tree/r6/eslint

vscode global settings for eslint

{
"eslint.alwaysShowStatus": true,
    "eslint.autoFixOnSave": true,
    "eslint.provideLintTask": true,
    "eslint.options": {
        // "useEslintrc": false,
        "configFile": "eslintrc.js", // needed otherwise it dosnt find the config
        "extensions": [
            ".ts"
        ]
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript"
    ],
    "eslint.workingDirectories": [ // needed otherwise it just dosnt work
        "."
    ]
}

images:

if

"useEslintrc": false,
// "configFile": "eslintrc.js",

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Just to ensure: the eslintrc.js needs to be named .eslintrc.js.

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

renamed the file to .eslintrc.js and removed "configFile": "eslintrc.js", and set "useEslintrc": true, but still "Parsing error: File '/home/hasezoey/tsconfig.json' not found."

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

I clone the repository, checked out r6/eslint and did the following modifications:

  • renamed eslintrc.js
  • added the following settings:
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
    ]
  • no working directory setting

I don't get a parsing error but

[Error - 7:03:46 PM] FatalError: Error while loading rule '@typescript-eslint/tslint/config': Could not find custom rule directory: /projects/typegoose/node_modules/tslint-eslint-rules/dist/rules
Occurred while linting C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\src\data.ts
    at new FatalError (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\error.js:27:28)
    at C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:306:23
    at Array.map (<anonymous>)
    at getRulesDirectories (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:296:42)
    at parse (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:418:30)
    at Object.parseConfigFile (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:394:16)
    at lodash_memoize_1.default (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:20:35)
    at memoized (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\lodash.memoize\index.js:575:23)
    at create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:89:31)
    at Object.create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\experimental-utils\dist\eslint-utils\RuleCreator.js:12:24)

which I also get when exectuing eslint directly in the terminal

bugs\eslint\typegoose [r6/eslint ≡ +1 ~1 -1 !]> .\node_modules\.bin\eslint .\src\data.ts
FatalError: Error while loading rule '@typescript-eslint/tslint/config': Could not find custom rule directory: /projects/typegoose/node_modules/tslint-eslint-rules/dist/rules
Occurred while linting C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\src\data.ts
    at new FatalError (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\error.js:27:28)
    at C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:306:23
    at Array.map (<anonymous>)
    at getRulesDirectories (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:296:42)
    at parse (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:418:30)
    at Object.parseConfigFile (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:394:16)
    at lodash_memoize_1.default (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:20:35)
    at memoized (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\lodash.memoize\index.js:575:23)
    at create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:89:31)
    at Object.create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\experimental-utils\dist\eslint-utils\RuleCreator.js:12:24)

When you executing eslint in the terminal do you also see the parsing error. If so, please talk to the eslint / typescript eslint people directly since your problems seem independent of the ESLint extension.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Some as above with

    "eslint.workingDirectories": [
        "."
    ]

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

when i execute npm run lint (also eslint in cli), i only get the linting errors i should get (also yes, it works in the terminal)

-> did you install the devDependencies too? npm i -D

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Same

bugs\eslint\typegoose [r6/eslint ≡ +1 ~2 -1 !]> npm i -D
npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin-tslint@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.

audited 1329 packages in 9.07s
found 0 vulnerabilities

bugs\eslint\typegoose [r6/eslint ≡ +1 ~2 -1 !]> npm run lint

> typegoose@6.0.0-14 lint C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose
> eslint . --ignore-path .gitignore -c .eslintrc.js --ext ts

FatalError: Error while loading rule '@typescript-eslint/tslint/config': Could not find custom rule directory: /projects/typegoose/node_modules/tslint-eslint-rules/dist/rules
Occurred while linting C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\src\data.ts
    at new FatalError (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\error.js:27:28)
    at C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:306:23
    at Array.map (<anonymous>)
    at getRulesDirectories (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:296:42)
    at parse (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:418:30)
    at Object.parseConfigFile (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\tslint\lib\configuration.js:394:16)
    at lodash_memoize_1.default (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:20:35)
    at memoized (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\lodash.memoize\index.js:575:23)
    at create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\eslint-plugin-tslint\dist\rules\config.js:89:31)
    at Object.create (C:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\typegoose\node_modules\@typescript-eslint\experimental-utils\dist\eslint-utils\RuleCreator.js:12:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! typegoose@6.0.0-14 lint: `eslint . --ignore-path .gitignore -c .eslintrc.js --ext ts`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the typegoose@6.0.0-14 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dirkb\AppData\Roaming\npm-cache\_logs\2019-08-08T17_26_43_128Z-debug.log

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

try pulling again... (modified something)

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Same outcome

capture

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

oops the npm run lint script is still targeted at eslintrc and not .eslintrc

-> fixed it, pull again...

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

Note #722 (comment) didnt fix it for me

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Now it works for me in code and the terminal

capture

The only setting I have is:

    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
    ]

I think this is caused by prettier. Do you have it installed. See the comments here #696 (comment) and below

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

I think this is caused by prettier. Do you have it installed. See the comments here #696 (comment) and below

yes i have prettier installed, but for typescript until now i used tslint to auto fix it and disabled prettier (for ts files)

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

yes removing every option except eslint.validate fixed it, but somehow it only lints the opened files, is this intended?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Yes, this is intended. The is a lint task which lints the whole project "eslint.provideLintTask": true. Or you run the npm script you already have and assicate the eslint problem matcher with it.

I will close the issue.

@dbaeumer dbaeumer closed this as completed Aug 8, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

And great to see it is working now

@hasezoey

This comment has been minimized.

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

found how provideLintTask works, but why does it lint everything even when the following is supplied?

"eslint.options": {
        "ignorePath": ".gitignore"
    },

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2019

Actually I don't know. According to https://eslint.org/docs/developer-guide/nodejs-api#cliengine this seems to be correct. Does a full path make a difference?

@hasezoey
Copy link
Author

hasezoey commented Aug 8, 2019

no it dosnt make a difference

@ghost
Copy link

ghost commented Aug 9, 2019

I was having this issue using eslint-config-airbnb-base, so I installed it using npx install-peerdeps --dev eslint-config-airbnb-base, and it worked...

In my case, this issue was due to a ESLint version conflict with eslint-config-airbnb-base, the peerdeps lowed the ESLint version to 5.3...

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2019

@hasezoey which is actually good since it is my fault. The eslint.options don't have any impact on the task :-).

But since you have npm script to validate you can simply add the following to the tasks.json file in the .vscode folder:

        {
            "type": "npm",
            "script": "lint",
            "problemMatcher": [
                "$eslint-stylish"
            ]
        }

@hasezoey
Copy link
Author

hasezoey commented Aug 9, 2019

But since you have npm script to validate you can simply add the following to the tasks.json file in the .vscode folder:

already done it, just wanted to know and test "eslint.provideLintTask": true so i though it might be worth noting this

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants