ES Lint in Visual Studio Code

298 views
Skip to first unread message

Alan Wells

unread,
Apr 22, 2019, 10:46:07 AM4/22/19
to Google Apps Script Community
If you use the Visual Studio Code editor to write JavaScript, you can install ES Lint.  ES Lint will find errors in your JavaScript code.  Visual Studio Code has it's own marketplace, and you can install ES Lint from the Visual Studio Code Marketplace.  The link is:


You will need to install ES Lint globally using 'npm install -g eslint' from the command line.  If you nave not installed npm, then you will need to do that.  Inside of the Visual Studio Code editor, you can get the command line by clicking the "Terminal" menu and "New Terminal"  If you open a JavaScript file, and the terminal opens automatically with an error stating that you need to install ES Lint globally using 'npm install -g eslint' from the command line, then just click on the "Terminal" tab.

If you have not set up an npm package.json file, then from the command line type: npm init and answer the questions.  If you don't have a GitHub account, or don't want to make a setting for that, then for the GitHub questions you can just ignore those and hit enter.

When that process is done, type: eslint --init
on the command line and hit enter

For Apps Script, you might not be using npm packages or modules, so you can answer "None of these"
Where does your code run?  I chose browser

If you did not set up GitHub as a repository, then you will get an error message:

npm WARN ***Your json file name*** No repository field.

You can ignore that.  What you want to see in the message is:
Successfully created .eslintrc.js file

If ES Lint is working, you will see a red squiggly line under the problem.  It's the same as a spelling error.

I'm a novice user of VS Code, and node.js.  I took these notes while going through the process.  All I know is, is that it's working for me.




oshliaer

unread,
May 1, 2019, 1:46:02 AM5/1/19
to Google Apps Script Community
There is my scaffolding for the fast run a gas code.


For an example (npm && curl are required)

$> npm init -y
$> npm i -D @google/clasp @types/google-apps-script eslint eslint-config-google eslint-config-prettier eslint-plugin-googleappsscript eslint-plugin-prettier prettier
$> npx clasp clone AAAAAAAAAAAAAAAA --rootDir src
Reply all
Reply to author
Forward
0 new messages