README
Silvermine Standardization Utilities
What?
This repo aggregates many of the standards we use when developing our software, including:
- Release process standardization
- Markdown linting
- SASS linting
- Commit message linting
- Editor configuration
Notably, we have extensive JavaScript and TypeScript linting that is not included in this repo. See @silvermine/eslint-config and @silvermine/eslint-plugin for those standards. They are not part of this repo because of specific naming requirements for providing Eslint config and plugins.
Why?
As a team, we value consistency and automated enforcement of standards. This makes it much easier for new developers on the team or individual external contributors to be able to write code that looks and feels like the rest of our codebases. It also plays into our automation since standardization is important when you're maintaining many dozens of repos.
Usage
SASS Linting
Add the following command to your Gruntfile.js, register the grunt-stylelint plugin, and
add the stylelint
command to the standards
task:
stylelint: {
options: {
configFile: './node_modules/@silvermine/standardization/.stylelintrc.yml',
},
src: './path/to/scss/source/**/*.scss',
},
// Register grunt-stylelint like so:
grunt.loadNpmTasks('grunt-stylelint');
// Then include the command along with `grunt standards`
grunt.registerTask('standards', [ 'stylelint' ]);
EditorConfig
EditorConfig provides a default set of editor configuration values to use in Silvermine projects.
Symlink the .editorconfig file to the root of your project and use the appropriate extension for your editor:
ln -s ./node_modules/@silvermine/standardization/.editorconfig
Commitlint
- Add a file called commitlint.config.js to your project root with the following content:
'use strict';
module.exports = {
extends: [ '@silvermine/standardization/commitlint.js' ],
};
- Use git log --oneline to find the short hash of the previous commit and take note of it
- Add the following NPM script to
package.json
:
"commitlint": "commitlint --from deadbeef"
(where deadbeef is the short hash from the
previous step)
- Configure
.gitlab-ci.yml
or.travis.yml
to runnpm run commitlint
before runningnpm test
markdownlint
Add the following configuration to your Gruntfile.js, register the task, and add
the markdownlint
task to the standards
command:
// Inside initConfig...
markdownlint: {
all: {
src: [ './path/to/markdown/file.md' ],
options: {
config: grunt.file.readJSON('.markdownlint.json'),
},
},
},
// Register the task:
grunt.loadNpmTasks('grunt-markdownlint');
// Add the command to `grunt standards`:
grunt.registerTask('standards', [ 'markdownlint' ]);
TODO: fill in details and examples here.
License
This software is released under the MIT license. See the license file for more details.