From 9c99df922c0a21065f1e3764c77ae1973698da96 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 26 Oct 2017 11:19:45 +0200 Subject: update validate script, lint files on commit (#2756) --- server/sonar-web/package.json | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'server/sonar-web/package.json') diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 7d82399d2ad..070b2310f07 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -95,6 +95,7 @@ "handlebars-loader": "1.6.0", "html-webpack-plugin": "2.30.1", "jest": "21.2.1", + "lint-staged": "4.3.0", "postcss-custom-properties": "6.2.0", "postcss-loader": "2.0.8", "prettier": "1.7.4", @@ -117,8 +118,10 @@ "coverage": "npm test -- --coverage", "format": "prettier --write --list-different 'src/main/js/!(libs)/**/*.{js,ts,tsx,css}'", "lint": "eslint --ext js,ts,tsx --quiet src/main/js", - "typecheck": "flow src/main/js", - "validate": "eslint src/main/js && flow check src/main/js && NODE_ENV=test jest" + "flow-check": "flow check src/main/js", + "ts-check": "tsc --noEmit", + "validate": "yarn lint && yarn flow-check && yarn ts-check && NODE_ENV=test jest", + "precommit": "lint-staged" }, "engines": { "node": ">=6" @@ -132,28 +135,19 @@ ], "jest": { "coverageDirectory": "/target/coverage", - "coveragePathIgnorePatterns": [ - "/node_modules", - "/tests" - ], + "coveragePathIgnorePatterns": ["/node_modules", "/tests"], "mapCoverage": true, - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], + "moduleFileExtensions": ["ts", "tsx", "js", "json"], "moduleNameMapper": { - "^.+\\.(hbs|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/config/jest/FileStub.js", + "^.+\\.(hbs|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": + "/config/jest/FileStub.js", "^.+\\.css$": "/config/jest/CSSStub.js" }, "setupFiles": [ "/config/polyfills.js", "/config/jest/SetupTestEnvironment.js" ], - "snapshotSerializers": [ - "enzyme-to-json/serializer" - ], + "snapshotSerializers": ["enzyme-to-json/serializer"], "testPathIgnorePatterns": [ "/node_modules", "/src/main/webapp", @@ -169,5 +163,12 @@ "jsxBracketSameLine": true, "printWidth": 100, "singleQuote": true + }, + "lint-staged": { + "gitDir": "../../", + "linters": { + "*.{css,json}": ["prettier --write", "git add"], + "*.{js,ts,tsx}": ["eslint", "jest --bail --findRelatedTests", "prettier --write", "git add"] + } } } -- cgit v1.2.3