From 48ceb4032f0b4d716a6f738ad855ad64e09ec0d5 Mon Sep 17 00:00:00 2001 From: zhichen Date: Wed, 14 Nov 2018 19:38:13 +0800 Subject: [PATCH] add eslint prettier --- .../src/main/resources/static/.editorconfig | 16 ++++++++ .../src/main/resources/static/.eslintignore | 2 + console/src/main/resources/static/.eslintrc | 33 +++++++++++++++ .../src/main/resources/static/.prettierignore | 3 ++ console/src/main/resources/static/.prettierrc | 9 ++++ .../resources/static/.vscode/settings.json | 41 +++++++++---------- .../src/main/resources/static/package.json | 29 +++++++++---- .../src/main/resources/static/tsconfig.json | 21 ++++++++++ 8 files changed, 125 insertions(+), 29 deletions(-) create mode 100644 console/src/main/resources/static/.editorconfig create mode 100644 console/src/main/resources/static/.eslintignore create mode 100644 console/src/main/resources/static/.eslintrc create mode 100644 console/src/main/resources/static/.prettierignore create mode 100644 console/src/main/resources/static/.prettierrc create mode 100644 console/src/main/resources/static/tsconfig.json diff --git a/console/src/main/resources/static/.editorconfig b/console/src/main/resources/static/.editorconfig new file mode 100644 index 000000000..3331d7049 --- /dev/null +++ b/console/src/main/resources/static/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab \ No newline at end of file diff --git a/console/src/main/resources/static/.eslintignore b/console/src/main/resources/static/.eslintignore new file mode 100644 index 000000000..dd87e2d73 --- /dev/null +++ b/console/src/main/resources/static/.eslintignore @@ -0,0 +1,2 @@ +node_modules +build diff --git a/console/src/main/resources/static/.eslintrc b/console/src/main/resources/static/.eslintrc new file mode 100644 index 000000000..99651eab0 --- /dev/null +++ b/console/src/main/resources/static/.eslintrc @@ -0,0 +1,33 @@ +{ + "extends": "eslint-config-ali/react", + "parser": "babel-eslint", + "env": {}, + "globals": { + "window": true + }, + "rules": { + "no-shadow": "off", + "no-empty": "off", + "no-useless-escape": "off", + "no-template-curly-in-string": "off", + "no-unused-vars": "off", + "no-tabs": "off", + "react/no-string-refs": "off", + "react/no-unused-state": "off", + "no-return-assign": "off", + "no-plusplus": "off", + "no-script-url": "off", + "no-mixed-operators": "off", + "react/jsx-indent": "off", + "react/jsx-no-bind": "off", + "react/forbid-prop-types": "off", + "react/no-array-index-key": "off", + "react/sort-comp": "off", + "implicit-arrow-linebreak": "off", + "prefer-const": "off", + "space-before-function-paren": "off", + "wrap-iife": "off", + "arrow-parens": "off", + "indent": "off" + } +} diff --git a/console/src/main/resources/static/.prettierignore b/console/src/main/resources/static/.prettierignore new file mode 100644 index 000000000..966f12d8b --- /dev/null +++ b/console/src/main/resources/static/.prettierignore @@ -0,0 +1,3 @@ +*.svg +*.ejs +.DS_Store \ No newline at end of file diff --git a/console/src/main/resources/static/.prettierrc b/console/src/main/resources/static/.prettierrc new file mode 100644 index 000000000..0f6921f61 --- /dev/null +++ b/console/src/main/resources/static/.prettierrc @@ -0,0 +1,9 @@ +{ + "tabWidth": 2, + "printWidth": 100, + "semi": true, + "useTabs": false, + "bracketSpacing": true, + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/console/src/main/resources/static/.vscode/settings.json b/console/src/main/resources/static/.vscode/settings.json index 5be0642f2..42d168d92 100644 --- a/console/src/main/resources/static/.vscode/settings.json +++ b/console/src/main/resources/static/.vscode/settings.json @@ -1,24 +1,23 @@ { - "editor.tabSize": 2, + "editor.tabSize": 2, + "editor.formatOnSave": true, + "[javascript]": { "editor.formatOnSave": true, - "[javascript]": { - "editor.formatOnSave": true, - "editor.formatOnPaste": false - }, - "[javascriptreact]": { - "editor.formatOnSave": true, - "editor.formatOnPaste": false - }, - "[typescript]": { - "editor.formatOnSave": true, - "editor.formatOnPaste": false - }, - "[typescriptreact]": { - "editor.formatOnSave": true, - "editor.formatOnPaste": false - }, - "[html]": { - "editor.formatOnSave": true - } + "editor.formatOnPaste": false + }, + "[javascriptreact]": { + "editor.formatOnSave": true, + "editor.formatOnPaste": false + }, + "[typescript]": { + "editor.formatOnSave": true, + "editor.formatOnPaste": false + }, + "[typescriptreact]": { + "editor.formatOnSave": true, + "editor.formatOnPaste": false + }, + "[html]": { + "editor.formatOnSave": false } - \ No newline at end of file +} diff --git a/console/src/main/resources/static/package.json b/console/src/main/resources/static/package.json index 18c65ddc3..129f34d47 100644 --- a/console/src/main/resources/static/package.json +++ b/console/src/main/resources/static/package.json @@ -1,10 +1,22 @@ { "private": true, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.js": [ + "eslint --fix", + "git add" + ] + }, "scripts": { "start": "roadhog dev", "build": "node build.js", "dist": "roadhog build", - "lint": "eslint --ext .js src test" + "eslint": "eslint --ext .js src/", + "eslint-fix": "eslint --ext .js --fix src/" }, "dependencies": { "@alifd/next": "^1.7.6", @@ -17,17 +29,18 @@ }, "devDependencies": { "babel-core": "^6.26.3", + "babel-eslint": "^10.0.1", "babel-plugin-dva-hmr": "^0.3.2", + "babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", - "babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-preset-stage-2": "^6.24.1", - "eslint": "^4.14.0", - "eslint-config-umi": "^0.1.1", - "eslint-plugin-flowtype": "^2.34.1", - "eslint-plugin-import": "^2.6.0", - "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-react": "^7.1.0", + "eslint": "^5.9.0", + "eslint-config-ali": "^4.0.0", + "eslint-config-prettier": "^3.3.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-prettier": "^3.0.0", + "eslint-plugin-react": "^7.11.1", "husky": "^0.12.0", "roadhog": "^2.0.0" } diff --git a/console/src/main/resources/static/tsconfig.json b/console/src/main/resources/static/tsconfig.json new file mode 100644 index 000000000..fe31a6a82 --- /dev/null +++ b/console/src/main/resources/static/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "strictNullChecks": true, + "moduleResolution": "node", + "experimentalDecorators": true, + "jsx": "preserve", + "noUnusedParameters": true, + "noUnusedLocals": true, + "noImplicitAny": true, + "target": "es6", + "lib": [ + "dom", + "es7" + ] + }, + "exclude": [ + "node_modules", + "lib", + "es" + ] +} \ No newline at end of file