Skip to content

Commit

Permalink
Install and setup lint-staged
Browse files Browse the repository at this point in the history
Installed "lint-staged" to run linters against staged Git files to
prevent to add code that violates any style guide into the code base.

The configuration file `lint-staged.config.js` (1) has been placed in
the project root and includes the commands that should be run for
matching file extensions (globs). It includes at least the three
following entries with the same order as listed here:

1. `prettier --list-different` - Run Prettier against
   `*.{js,json,mdx,yml}` to ensure all files are formatted
   correctly. The `--list-different` flag prints the found files that
   are not conform to the Prettier configuration.
2. `eslint` - Run ESLint against `*.{js,json}` to ensure all
   JavaScript files are compliant to the style guide after being
   formatted with Prettier.
3. `remark --no-stdout` - Run remark-lint against `*.md` to ensure
   all Markdown files are compliant to the style guide. The
   `--no-stdout` flag suppresses the output of the parsed file content.

References:

  (1) https://github.com/okonet/lint-staged

Resolves GH-133
  • Loading branch information
arcticicestudio committed May 25, 2019
1 parent 84f2938 commit 80dee6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
assets/*
**/node_modules/*
*.vsix
!lint-staged.config.js
!.eslintrc.js
21 changes: 21 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2017-present Arctic Ice Studio <development@arcticicestudio.com>
* Copyright (C) 2017-present Sven Greb <development@svengreb.de>
*
* Project: Nord Visual Studio Code
* Repository: https://github.com/arcticicestudio/nord-visual-studio-code
* License: MIT
*/

/**
* @file The lint-staged configuration.
* @author Arctic Ice Studio <development@arcticicestudio.com>
* @author Sven Greb <development@svengreb.de>
* @see https://github.com/okonet/lint-staged#configuration
*/

module.exports = {
"*.{js,json,md,yml}": "prettier --list-different",
"*.{js,json}": "eslint --ext .js,.json",
"*.md": "remark --no-stdout"
};

0 comments on commit 80dee6a

Please sign in to comment.