- It could take hours to add editor config
to a project and editor
or more likely just a minute or two.
Adding editor config support to an editor
is well-documented at editorconfig.org.
In fact, some editors already include native support,
so you might not need to do anything.
Others like vs code require
an open source plugin or extension.
Let's get started.
Switch over to vs code.
Launch vs code quick open by pressing control and P.
Type the following command E X T, space install
space editor, config dot editor, config
and press enter to install the extension.
After a moment, the extension should be installed
and listed within the extensions marketplace on the sidebar.
That's basically it.
If you click on the extension that you just installed,
you'll see some release notes and some supported properties.
No configuration is needed so click the Explorer icon
in the activity bar to return to our workspace.
Now that the extension is installed,
we'll need to add the editor config configuration
to the project.
The process is to just create or copy the file
to the root folder of the project.
It's best practice to update the read me.md
to tell other developers that it's available.
Make sure that the projects open.
From the Explorer, right click and go to new file.
The path of the file is dot editor Config,
no spaces or capitalization.
We'll need the source file to copy and paste from.
Navigate to the file menu.
Go to open file, then go to the desktop
or wherever you place the exercise files.
Go to solutions and go to oh two underscore oh two.
I named this version dot TXT to avoid hidden file issues.
Select the file, double-click to open.
We're going to copy and paste the contents.
Go to the selection menu and go to select all.
Then in the editor, right-click and go to copy.
We can now close the source file
by clicking the X in the tab.
In the fresh editor config file,
right-click and choose paste.
The contents should be shown.
Save the changes.
That's it.
We can test the configuration out.
Click on the last file in the editor config window,
if it isn't already and then press delete
or backspace on your keyboard to remove the final line.
Then press tab a few times to add some white space.
Save again.
Notice that there's a new line
added automatically to the file
and the cursor is on the line below the faults.
If I press left on my keyboard,
the cursor just goes to after faults
which demonstrates that there's no space there anymore.
Let's close the editor config tab
by clicking the X in the tab.
Now the editor config is configured.
Let's update the read me.
In the Explorer, click read me.md to open it.
Navigate to the development header.
Add some space then type,
this project uses editor can fig
to standardize text editor configuration.
Visit https//editorconfig.org for details.
Save the changes.
We can now close the read me file
by clicking X in the tab.
Now that we've set up a baseline coding standard,
how can we lint JavaScript files to find problems?