Using the VS Code editor
ArchivesSpace provides a VS Code settings file that makes it easy for contributors using VS Code to follow the code style of the project and work with the end-to-end tests. Using this tool chain in your editor helps fix code format and lint errors before committing files or running tests. In many cases such errors will be fixed automatically when the file being worked on is saved. Errors that can’t be fixed automatically will be highlighted with squiggly lines. Hovering your cursor over these lines will display a description of the error to help reach a solution.
Prerequisites
Section titled “Prerequisites”Set up VS Code
Section titled “Set up VS Code”Add system dependencies
Section titled “Add system dependencies”Rubocop
Section titled “Rubocop”gem install rubocopSee https://docs.rubocop.org/rubocop/installation.html for further information, including using Bundler.
ESLint, Prettier, Stylelint
Section titled “ESLint, Prettier, Stylelint”Run the following command from the ArchivesSpace root directory.
npm installSee package.json for further details on how these tools are used in ArchivesSpace.
Add VS Code extensions
Section titled “Add VS Code extensions”Add the following extensions via the VS Code command palette or the Extensions panel. (See this documentation for installing and managing extensions).
- ESLint (dbaeumer.vscode-eslint)
- Prettier (esbenp.prettier-vscode)
- Ruby Rubocop Revised (LoranKloeze.ruby-rubocop-revived)
- Stylelint (stylelint.vscode-stylelint)
Optional — for enhancing work with the end-to-end tests:
- Cucumber (CucumberOpen.cucumber-official) — see End-to-end test integration, especially step-definition navigation.
It’s important to note that since these extensions work in tandem with the VS Code settings file, these settings only impact your ArchivesSpace VS Code Workspace, not your global VS Code User settings.
The extensions should now work out of the box at this point providing error messages and autocorrecting fixable errors on file save!
End-to-end test integration
Section titled “End-to-end test integration”The ArchivesSpace repository includes optional VS Code workspace configuration that integrates the Cucumber end-to-end test suite with the editor. The files .vscode/example.tasks.json and .vscode/example.settings.json are not enabled by default, so they do not override your personal editor configuration.
Enable the tasks
Copy the example tasks file to .vscode/tasks.json. This adds a task that runs the e2e test suite with the correct working directory, Ruby environment, and environment variables. Run it via Terminal → Run Task… → Cucumber: Run e2e-test (the same command as in the e2e test documentation). You may optionally supply a feature file path, file.feature:line.
Step-definition navigation
Integrate the contents of example.settings.json into your existing .vscode/settings.json (do not replace the existing file, but merge the Cucumber-related settings if you desire to use them so your current workspace settings are preserved).
This configures the Cucumber extension for e2e-tests/**/*.feature and shared Ruby step definitions, enabling jump-to-definition, undefined-step detection, and discovery of shared steps. This simplifies contributing new end-to-end tests.