diff --git a/superset-frontend/temporary_superset_ui/superset-ui/package.json b/superset-frontend/temporary_superset_ui/superset-ui/package.json index f52207405d..b2379924e6 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/package.json @@ -51,7 +51,7 @@ "vx" ], "license": "Apache-2.0", - "devDependencies": { + "dependencies": { "@airbnb/config-babel": "^3.1.0", "@airbnb/config-eslint": "^3.1.0", "@airbnb/config-jest": "^3.0.1", @@ -204,12 +204,16 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "lint-staged", + "commit-msg": "./scripts/commitlint.js HUSKY_GIT_PARAMS" } }, "lint-staged": { "./{packages,plugins}/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx,json,md}": [ - "yarn prettier --write" + "yarn prettier" + ], + "./{packages,plugins}/*.md": [ + "yarn prettier" ] } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/README.md b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/README.md index 626660e901..22ccd2b5ff 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/README.md +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/README.md @@ -98,3 +98,4 @@ Coming soon. `@data-ui/build-config` is used to manage the build configuration for this package including babel builds, jest testing, eslint, and prettier. + diff --git a/superset-frontend/temporary_superset_ui/superset-ui/scripts/commitlint.js b/superset-frontend/temporary_superset_ui/superset-ui/scripts/commitlint.js new file mode 100755 index 0000000000..cef3392e21 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/scripts/commitlint.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node +/** + * Check commit messages only for the first commit in branch. + */ +const { execSync, spawnSync } = require('child_process'); + +const envVariable = process.argv[2] || 'GIT_PARAMS'; + +if (!envVariable || !process.env[envVariable]) { + process.stdout.write(`Please provide a commit message via \`${envVariable}={Your Message}\`.\n`); + process.exit(0); +} +if (execSync('git rev-list --count HEAD ^master', { encoding: 'utf-8' }).trim() === '0') { + const { status } = spawnSync(`commitlint`, ['-E', envVariable], { stdio: 'inherit' }); + process.exit(status); +}