Unverified Commit cc970b00 authored by 陈帅's avatar 陈帅 Committed by GitHub

add lint prettier in Ci (#3262)

* add lint prettier in Ci

* .circleci use version =2

* remove jest in package

* update package.json

* add enzyme

* fix appveyor error

* use check-prettier script
parent 2441f753
...@@ -6,6 +6,7 @@ jobs: ...@@ -6,6 +6,7 @@ jobs:
steps: steps:
- checkout - checkout
- run: npm install - run: npm install
- run: npm run lint
- run: npm run build - run: npm run build
test: test:
docker: docker:
...@@ -13,12 +14,12 @@ jobs: ...@@ -13,12 +14,12 @@ jobs:
steps: steps:
- checkout - checkout
- run: npm install - run: npm install
- run: - run:
command : npm run test:all command: npm run test:all
no_output_timeout : 30m no_output_timeout: 30m
workflows: workflows:
version: 2 version: 2
build_and_test: build_and_test:
jobs: jobs:
- build - build
- test - test
\ No newline at end of file
# Test against the latest version of this Node.js version # Test against the latest version of this Node.js version
environment: environment:
nodejs_version: "8" nodejs_version: '10'
# this is how to allow failing jobs in the matrix # this is how to allow failing jobs in the matrix
matrix: matrix:
fast_finish: true # set this flag to immediately finish build once one of the jobs fails. fast_finish: true # set this flag to immediately finish build once one of the jobs fails.
# Install scripts. (runs after repo cloning) # Install scripts. (runs after repo cloning)
install: install:
......
// ps https://github.com/GoogleChrome/puppeteer/issues/3120 // ps https://github.com/GoogleChrome/puppeteer/issues/3120
module.exports = { module.exports = {
launch: { launch: {
headless: false, headless: true,
args: [ args: [
'--disable-gpu', '--disable-gpu',
'--disable-dev-shm-usage', '--disable-dev-shm-usage',
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push", "site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push",
"analyze": "cross-env ANALYZE=1 umi build", "analyze": "cross-env ANALYZE=1 umi build",
"lint:style": "stylelint \"src/**/*.less\" --syntax less", "lint:style": "stylelint \"src/**/*.less\" --syntax less",
"lint": "eslint --ext .js src mock tests && npm run lint:style", "lint:prettier": "check-prettier lint",
"lint": "eslint --ext .js src mock tests && npm run lint:style && npm run lint:prettier",
"lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js", "lint-staged:js": "eslint --ext .js",
...@@ -30,11 +31,12 @@ ...@@ -30,11 +31,12 @@
"docker:push": "npm run docker-hub:build && npm run docker:tag && docker push chenshuai2144/ant-design-pro" "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push chenshuai2144/ant-design-pro"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.1.5",
"antd": "^3.10.9",
"bizcharts": "^3.4.0",
"bizcharts-plugin-slider": "^2.1.1-beta.1",
"@antv/data-set": "^0.10.0", "@antv/data-set": "^0.10.0",
"@babel/runtime": "^7.2.0",
"antd": "^3.11.6",
"bizcharts": "^3.4.2",
"bizcharts-plugin-slider": "^2.1.1-beta.1",
"check-prettier": "^1.0.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"dva": "^2.4.0", "dva": "^2.4.0",
"enquire-js": "^0.2.1", "enquire-js": "^0.2.1",
...@@ -67,7 +69,7 @@ ...@@ -67,7 +69,7 @@
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"cross-env": "^5.1.1", "cross-env": "^5.1.1",
"cross-port-killer": "^1.0.1", "cross-port-killer": "^1.0.1",
"enzyme": "^3.7.0", "enzyme": "3.7.0",
"eslint": "^5.4.0", "eslint": "^5.4.0",
"eslint-config-airbnb": "^17.0.0", "eslint-config-airbnb": "^17.0.0",
"eslint-config-prettier": "^3.0.1", "eslint-config-prettier": "^3.0.1",
...@@ -85,16 +87,16 @@ ...@@ -85,16 +87,16 @@
"mockjs": "^1.0.1-beta3", "mockjs": "^1.0.1-beta3",
"prettier": "1.15.2", "prettier": "1.15.2",
"pro-download": "^1.0.1", "pro-download": "^1.0.1",
"slash2": "^2.0.0",
"stylelint": "^9.8.0", "stylelint": "^9.8.0",
"stylelint-config-prettier": "^4.0.0", "stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.0.0", "stylelint-config-standard": "^18.0.0",
"tslint": "^5.10.0", "tslint": "^5.10.0",
"tslint-config-prettier": "^1.10.0", "tslint-config-prettier": "^1.10.0",
"tslint-react": "^3.6.0", "tslint-react": "^3.6.0",
"umi": "^2.2.7", "umi": "^2.3.1",
"umi-plugin-ga": "^1.1.3", "umi-plugin-ga": "^1.1.3",
"umi-plugin-react": "^1.2.0", "umi-plugin-react": "^1.2.0"
"slash2": "^2.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"puppeteer": "^1.10.0" "puppeteer": "^1.10.0"
...@@ -115,6 +117,13 @@ ...@@ -115,6 +117,13 @@
"last 2 versions", "last 2 versions",
"not ie <= 10" "not ie <= 10"
], ],
"checkFiles": [
"src/**/*.js*",
"src/**/*.ts*",
"src/**/*.less",
"config/**/*.js*",
"scripts/**/*.js"
],
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "npm run lint-staged" "pre-commit": "npm run lint-staged"
......
const glob = require('glob');
const getPrettierFiles = () => {
let files = [];
const jsFiles = glob.sync('src/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const tsFiles = glob.sync('src/**/*.ts*', { ignore: ['**/node_modules/**', 'build/**'] });
const configFiles = glob.sync('config/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const scriptFiles = glob.sync('scripts/**/*.js');
const lessFiles = glob.sync('src/**/*.less*', { ignore: ['**/node_modules/**', 'build/**'] });
files = files.concat(jsFiles);
files = files.concat(tsFiles);
files = files.concat(configFiles);
files = files.concat(scriptFiles);
files = files.concat(lessFiles);
if (!files.length) {
return;
}
return files;
};
module.exports = getPrettierFiles;
...@@ -9,24 +9,12 @@ ...@@ -9,24 +9,12 @@
const glob = require('glob'); const glob = require('glob');
const prettier = require('prettier'); const prettier = require('prettier');
const fs = require('fs'); const fs = require('fs');
const getPrettierFiles = require('./getPrettierFiles');
const prettierConfigPath = require.resolve('../.prettierrc'); const prettierConfigPath = require.resolve('../.prettierrc');
let didError = false; let didError = false;
let files = []; const files = getPrettierFiles();
const jsFiles = glob.sync('src/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const tsFiles = glob.sync('src/**/*.ts*', { ignore: ['**/node_modules/**', 'build/**'] });
const configFiles = glob.sync('config/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const scriptFiles = glob.sync('scripts/**/*.js');
const lessFiles = glob.sync('src/**/*.less*', { ignore: ['**/node_modules/**', 'build/**'] });
files = files.concat(jsFiles);
files = files.concat(tsFiles);
files = files.concat(configFiles);
files = files.concat(scriptFiles);
files = files.concat(lessFiles);
if (!files.length) {
return;
}
files.forEach(file => { files.forEach(file => {
const options = prettier.resolveConfig.sync(file, { const options = prettier.resolveConfig.sync(file, {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment