Home > database >  How do i get VSCODE to lint javascript without having to open all the files
How do i get VSCODE to lint javascript without having to open all the files

Time:09-16

it's linting php just fine. but when i try to work on javascript it only finds the definitions in open files. which would be less annoying if i could just click on all the files i might need to lint from. but unless you edit them they don't stay open.

with the php linter i didn't have to run any weird command line stuff. and i don't think i have whatever ESLint is expecting me to have installed for any of the npm or npx commands to actually work.

i want to be able to define a parent class in parent.js and then extend it with a child class in child.js and have it do the suggestion with the parent class functions when i type this. in child.js without having to keep parent.js open.

i'm not sure if this is called linting or intellisense.... whatever it's called how do i make this work for javascript in vscode? so it can be as nice to work on the javascript parts of my project as it is to work on the php parts.

and ESLint absolutely won't work for me. i tried it. i installed node.js and got ESLint installed into my project. and it trashed all of my js files and still couldn't find any of the definitions. only now it couldn't find them even when i had the file open. so ESLint made the issue i'm having worse!

CodePudding user response:

Which linter are you using? If you're using ESLint you can use the CLI to run the lint on multiple files or folders as shown in the docs:

# Run on two files
npx eslint file1.js file2.js

# Run on multiple files
npx eslint lib/**

I'm not sure if this is what you're looking for but I hope it helps.

CodePudding user response:

just need to add jsconfig.json to the project root with the following settings to make it see the whole project.

/jsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6"
    }
}

add this to your project root to get it to find all the js files in your project for nice code hinting.

  • Related