How to output the list of problems that vscode shows when opening a JS file, by using only the terminal:?

To see the errors that //@ts-check would generate, you can use the TypeScript compiler (tsc) with the --noEmit and --allowJs flags:

npm install -g typescript
tsc --noEmit --allowJs fileToCheck.js

noEmit means that no code will be generated but errors will still be output.

To run this for every file in your project, the best approach is to create a very simple jsconfig.json at the root of your workspace that defines your project and basic settings. The docs have more details on creating these, but here's a starting jsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve"
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ]
}

Then run:

tsc --noEmit -p jsconfig.json 

Alternatively, if you do not wish to create a jsconfig.json, you can try running tsc with every js file in your workspace using find:

tsc --noEmit --allowJs `find . ! -path '*/node_modules/*' -name "*.js"`

The above handles errors from TypeScript itself. However VS Code may show errors from multiple sources—such as typescript and tslint and a code spell checker—in a single file. There is no general way to get this from the command line.

Tools such as TSLint and eslint provide their own CLIs that you can use. This is what most open source project use for validation as it means that developers can use whatever editor they like. For example, your continuous integration script would run tsc --noEmit -p jsconfig.json && eslint ... && ...

However if you really, really want to get the exact same errors that VS Code shows in the editor, I believe you could use an approach similar to vscode-test to run a script that controls a VS Code instance. The VS Code API you'd want to use to get the errors is getDiagnostics(resource: Uri)