How to set .eslintrc to recognize 'require'?

后端 未结 4 1623
孤独总比滥情好
孤独总比滥情好 2021-02-02 05:02

I am new to ESLint, and I have successfully integrated ESLint with IntelliJ.

Out of the box, my integration of ESLint did not recognize node, but basic revi

4条回答
  •  灰色年华
    2021-02-02 05:41

    On a Mac ... global solution. (2021)

    If you are using the amazing ESLint in the amazing VS Code on Mac,

    Simply go to ~ (ie /users/your-name)

    edit .eslintrc.json (you can edit it in VSCode of course!)

    You'll likely add

    "node": true
    

    if you're working with node, or perhaps "amd" as stated in the answers here. ("amd" gives specifically and only require and define).

    This is a global solution for all workspaces you open.

    Importantly, this also works if you are using VS Code "remotely", so, with no workspace. For example, you may open a file on a server just using sftp, and work on the file in VSCode. Or you may be opening just a single local file on the Mac, not part of a workspace. In both these cases the setting (eg, node=true) will in fact work - it needn't be a workspace.

提交回复
热议问题