Skip to content

Commit

Permalink
Chore: Add linting to git commit (#11556)
Browse files Browse the repository at this point in the history
* Chore: Add linting to git commit

* Use local ESLint

* Add support for Markdown linting

* Add markdown linting
  • Loading branch information
nzakas authored and aladdin-add committed Apr 24, 2019
1 parent 8684f46 commit 8b4dba6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
20 changes: 20 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: true

# Exclusions for deliberate/widespread violations
MD001: false # Header levels should only increment by one level at a time
MD002: false # First header should be a h1 header
MD007: # Unordered list indentation
indent: 4
MD012: false # Multiple consecutive blank lines
MD013: false # Line length
MD014: false # Dollar signs used before commands without showing output
MD019: false # Multiple spaces after hash on atx style header
MD021: false # Multiple spaces inside hashes on closed atx style header
MD024: false # Multiple headers with the same content
MD026: false # Trailing punctuation in header
MD029: false # Ordered list item prefix
MD030: false # Spaces after list markers
MD033: false # Allow inline HTML
MD034: false # Bare URL used
MD040: false # Fenced code blocks should have a language specified
MD041: false # First line in file should be a top level header
24 changes: 1 addition & 23 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,29 +385,7 @@ function getFirstVersionOfDeletion(filePath) {
* @private
*/
function lintMarkdown(files) {
const config = {
default: true,

// Exclusions for deliberate/widespread violations
MD001: false, // Header levels should only increment by one level at a time
MD002: false, // First header should be a h1 header
MD007: { // Unordered list indentation
indent: 4
},
MD012: false, // Multiple consecutive blank lines
MD013: false, // Line length
MD014: false, // Dollar signs used before commands without showing output
MD019: false, // Multiple spaces after hash on atx style header
MD021: false, // Multiple spaces inside hashes on closed atx style header
MD024: false, // Multiple headers with the same content
MD026: false, // Trailing punctuation in header
MD029: false, // Ordered list item prefix
MD030: false, // Spaces after list markers
MD033: false, // Allow inline HTML
MD034: false, // Bare URL used
MD040: false, // Fenced code blocks should have a language specified
MD041: false // First line in file should be a top level header
},
const config = yaml.safeLoad(fs.readFileSync(path.join(__dirname, "./.markdownlint.yml"), "utf8")),
result = markdownlint.sync({
files,
config,
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"profile": "beefy tests/bench/bench.js --open -- -t brfs -t ./tests/bench/xform-rules.js -r espree",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.js": [
"node ./bin/eslint.js --fix",
"git add"
],
"*.md": "markdownlint"
},
"files": [
"LICENSE",
"README.md",
Expand Down Expand Up @@ -98,6 +108,7 @@
"karma-mocha-reporter": "^2.2.3",
"karma-webpack": "^4.0.0-rc.6",
"leche": "^2.2.3",
"lint-staged": "^8.1.5",
"load-perf": "^0.2.0",
"markdownlint": "^0.13.0",
"mocha": "^6.1.2",
Expand All @@ -111,7 +122,8 @@
"temp": "^0.9.0",
"through": "^2.3.8",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
"webpack-cli": "^3.3.0",
"yorkie": "^2.0.0"
},
"keywords": [
"ast",
Expand Down

0 comments on commit 8b4dba6

Please sign in to comment.