正在显示
11 个修改的文件
包含
304 行增加
和
0 行删除
.eslintignore
0 → 100644
.eslintrc.js
0 → 100644
1 | +module.exports = { | ||
2 | + parser: 'babel-eslint', | ||
3 | + extends: ['airbnb', 'prettier', 'plugin:compat/recommended'], | ||
4 | + env: { | ||
5 | + browser: true, | ||
6 | + node: true, | ||
7 | + es6: true, | ||
8 | + mocha: true, | ||
9 | + jest: true, | ||
10 | + jasmine: true, | ||
11 | + }, | ||
12 | + globals: { | ||
13 | + APP_TYPE: true, | ||
14 | + page: true, | ||
15 | + }, | ||
16 | + rules: { | ||
17 | + 'react/jsx-filename-extension': [1, { extensions: ['.js'] }], | ||
18 | + 'react/jsx-wrap-multilines': 0, | ||
19 | + 'react/prop-types': 0, | ||
20 | + 'react/forbid-prop-types': 0, | ||
21 | + 'react/jsx-one-expression-per-line': 0, | ||
22 | + 'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }], | ||
23 | + 'import/no-extraneous-dependencies': [ | ||
24 | + 2, | ||
25 | + { | ||
26 | + optionalDependencies: true, | ||
27 | + devDependencies: ['**/tests/**.js', '/mock/**.js', '**/**.test.js'], | ||
28 | + }, | ||
29 | + ], | ||
30 | + 'jsx-a11y/no-noninteractive-element-interactions': 0, | ||
31 | + 'jsx-a11y/click-events-have-key-events': 0, | ||
32 | + 'jsx-a11y/no-static-element-interactions': 0, | ||
33 | + 'jsx-a11y/anchor-is-valid': 0, | ||
34 | + 'linebreak-style': 0, | ||
35 | + }, | ||
36 | + settings: { | ||
37 | + polyfills: ['fetch', 'promises', 'url'], | ||
38 | + }, | ||
39 | +}; |
.prettierignore
0 → 100644
.prettierrc
0 → 100644
.stylelintrc.json
0 → 100644
jsconfig.json
0 → 100644
package.json
0 → 100644
1 | +{ | ||
2 | + "name": "ant-design-pro", | ||
3 | + "version": "2.1.1", | ||
4 | + "description": "An out-of-box UI solution for enterprise applications", | ||
5 | + "private": true, | ||
6 | + "scripts": { | ||
7 | + "lint:style": "stylelint \"src/**/*.less\" --syntax less", | ||
8 | + "lint": "eslint --ext .js src mock tests && npm run lint:style", | ||
9 | + "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", | ||
10 | + "lint-staged": "lint-staged", | ||
11 | + "lint-staged:js": "eslint --ext .js", | ||
12 | + "tslint": "npm run tslint:fix", | ||
13 | + "tslint:fix": "tslint --fix 'src/**/*.ts*'", | ||
14 | + "test": "umi test", | ||
15 | + "test:component": "umi test ./src/components", | ||
16 | + "test:all": "node ./tests/run-tests.js", | ||
17 | + "prettier": "node ./scripts/prettier.js" | ||
18 | + }, | ||
19 | + "dependencies": { | ||
20 | + | ||
21 | + }, | ||
22 | + "devDependencies": { | ||
23 | + "@types/react": "^16.7.7", | ||
24 | + "@types/react-dom": "^16.0.10", | ||
25 | + "babel-eslint": "^10.0.1", | ||
26 | + "cross-env": "^5.1.1", | ||
27 | + "cross-port-killer": "^1.0.1", | ||
28 | + "enzyme": "^3.7.0", | ||
29 | + "eslint": "^5.4.0", | ||
30 | + "eslint-config-airbnb": "^17.0.0", | ||
31 | + "eslint-config-prettier": "^3.0.1", | ||
32 | + "eslint-plugin-babel": "^5.3.0", | ||
33 | + "eslint-plugin-compat": "^2.6.2", | ||
34 | + "eslint-plugin-import": "^2.14.0", | ||
35 | + "eslint-plugin-jsx-a11y": "^6.1.2", | ||
36 | + "eslint-plugin-markdown": "^1.0.0-beta.6", | ||
37 | + "eslint-plugin-react": "^7.11.1", | ||
38 | + "gh-pages": "^2.0.1", | ||
39 | + "husky": "^1.2.0", | ||
40 | + "jest-puppeteer": "^3.5.1", | ||
41 | + "lint-staged": "^8.1.0", | ||
42 | + "merge-umi-mock-data": "^0.0.3", | ||
43 | + "mockjs": "^1.0.1-beta3", | ||
44 | + "prettier": "1.15.2", | ||
45 | + "pro-download": "^1.0.1", | ||
46 | + "stylelint": "^9.8.0", | ||
47 | + "stylelint-config-prettier": "^4.0.0", | ||
48 | + "stylelint-config-standard": "^18.0.0", | ||
49 | + "tslint": "^5.10.0", | ||
50 | + "tslint-config-prettier": "^1.10.0", | ||
51 | + "tslint-react": "^3.6.0" | ||
52 | + }, | ||
53 | + "optionalDependencies": { | ||
54 | + "puppeteer": "^1.10.0" | ||
55 | + }, | ||
56 | + "lint-staged": { | ||
57 | + "**/*.{js,ts,tsx,json,jsx,less}": [ | ||
58 | + "node ./scripts/lint-prettier.js", | ||
59 | + "git add" | ||
60 | + ], | ||
61 | + "**/*.{js,jsx}": "npm run lint-staged:js", | ||
62 | + "**/*.less": "stylelint --syntax less" | ||
63 | + }, | ||
64 | + "engines": { | ||
65 | + "node": ">=8.0.0" | ||
66 | + }, | ||
67 | + "browserslist": [ | ||
68 | + "> 1%", | ||
69 | + "last 2 versions", | ||
70 | + "not ie <= 10" | ||
71 | + ], | ||
72 | + "husky": { | ||
73 | + "hooks": { | ||
74 | + "pre-commit": "npm run lint-staged" | ||
75 | + } | ||
76 | + } | ||
77 | +} |
scripts/lint-prettier.js
0 → 100644
1 | +/** | ||
2 | + * copy to https://github.com/facebook/react/blob/master/scripts/prettier/index.js | ||
3 | + * prettier api doc https://prettier.io/docs/en/api.html | ||
4 | + *----------*****-------------- | ||
5 | + * lint file is prettier | ||
6 | + *----------*****-------------- | ||
7 | + */ | ||
8 | + | ||
9 | +const glob = require('glob'); | ||
10 | +const prettier = require('prettier'); | ||
11 | +const fs = require('fs'); | ||
12 | +const prettierConfigPath = require.resolve('../.prettierrc'); | ||
13 | + | ||
14 | +const files = process.argv.slice(2); | ||
15 | + | ||
16 | +let didError = false; | ||
17 | +let didWarn = false; | ||
18 | + | ||
19 | +files.forEach(file => { | ||
20 | + const options = prettier.resolveConfig.sync(file, { | ||
21 | + config: prettierConfigPath, | ||
22 | + }); | ||
23 | + try { | ||
24 | + const fileInfo = prettier.getFileInfo.sync(file); | ||
25 | + if (fileInfo.ignored) { | ||
26 | + return; | ||
27 | + } | ||
28 | + const input = fs.readFileSync(file, 'utf8'); | ||
29 | + const withParserOptions = { | ||
30 | + ...options, | ||
31 | + parser: fileInfo.inferredParser, | ||
32 | + }; | ||
33 | + const isPrettier = prettier.check(input, withParserOptions); | ||
34 | + if (!isPrettier) { | ||
35 | + console.log(`\x1b[31m ${file} is no prettier, please use npm run prettier and git add !\x1b[0m`); | ||
36 | + didWarn = true; | ||
37 | + } | ||
38 | + } catch (e) { | ||
39 | + didError = true; | ||
40 | + } | ||
41 | +}); | ||
42 | + | ||
43 | +if (didWarn || didError) { | ||
44 | + process.exit(1); | ||
45 | +} | ||
46 | +console.log('\x1b[32m lint prettier success!\x1b[0m'); |
scripts/prettier.js
0 → 100644
1 | +/** | ||
2 | + * copy to https://github.com/facebook/react/blob/master/scripts/prettier/index.js | ||
3 | + * prettier api doc https://prettier.io/docs/en/api.html | ||
4 | + *----------*****-------------- | ||
5 | + * prettier all js and all ts. | ||
6 | + *----------*****-------------- | ||
7 | + */ | ||
8 | + | ||
9 | +const glob = require('glob'); | ||
10 | +const prettier = require('prettier'); | ||
11 | +const fs = require('fs'); | ||
12 | +const prettierConfigPath = require.resolve('../.prettierrc'); | ||
13 | + | ||
14 | +let didError = false; | ||
15 | + | ||
16 | +let files = []; | ||
17 | +const jsFiles = glob.sync('ant-design-pro/**/*.js*', { | ||
18 | + ignore: ['**/node_modules/**', 'build/**'], | ||
19 | +}); | ||
20 | +const tsFiles = glob.sync('ant-design-pro/**/*.ts*', { | ||
21 | + ignore: ['**/node_modules/**', 'build/**'], | ||
22 | +}); | ||
23 | +files = files.concat(jsFiles); | ||
24 | +files = files.concat(tsFiles); | ||
25 | +if (!files.length) { | ||
26 | + return; | ||
27 | +} | ||
28 | + | ||
29 | +files.forEach(file => { | ||
30 | + const options = prettier.resolveConfig.sync(file, { | ||
31 | + config: prettierConfigPath, | ||
32 | + }); | ||
33 | + const fileInfo = prettier.getFileInfo.sync(file); | ||
34 | + if (fileInfo.ignored) { | ||
35 | + return; | ||
36 | + } | ||
37 | + try { | ||
38 | + const input = fs.readFileSync(file, 'utf8'); | ||
39 | + const withParserOptions = { | ||
40 | + ...options, | ||
41 | + parser: fileInfo.inferredParser, | ||
42 | + }; | ||
43 | + const output = prettier.format(input, withParserOptions); | ||
44 | + if (output !== input) { | ||
45 | + fs.writeFileSync(file, output, 'utf8'); | ||
46 | + console.log(`\x1b[34m ${file} is prettier`); | ||
47 | + } | ||
48 | + } catch (e) { | ||
49 | + didError = true; | ||
50 | + } | ||
51 | +}); | ||
52 | + | ||
53 | +if (didError) { | ||
54 | + process.exit(1); | ||
55 | +} | ||
56 | +console.log('\x1b[32m prettier success!'); |
tsconfig.json
0 → 100644
1 | +{ | ||
2 | + "compilerOptions": { | ||
3 | + "outDir": "build/dist", | ||
4 | + "module": "esnext", | ||
5 | + "target": "es2016", | ||
6 | + "lib": ["es6", "dom"], | ||
7 | + "sourceMap": true, | ||
8 | + "baseUrl": ".", | ||
9 | + "jsx": "react", | ||
10 | + "allowSyntheticDefaultImports": true, | ||
11 | + "moduleResolution": "node", | ||
12 | + "rootDirs": ["/src", "/test", "/mock","./typings"], | ||
13 | + "forceConsistentCasingInFileNames": true, | ||
14 | + "noImplicitReturns": true, | ||
15 | + "suppressImplicitAnyIndexErrors": true, | ||
16 | + "noUnusedLocals": true, | ||
17 | + "allowJs": true, | ||
18 | + "experimentalDecorators": true, | ||
19 | + "paths": { | ||
20 | + "@/*": ["./src/*"] | ||
21 | + } | ||
22 | + }, | ||
23 | + "include": ["./src"], | ||
24 | + "exclude": [ | ||
25 | + "node_modules", | ||
26 | + "build", | ||
27 | + "scripts", | ||
28 | + "acceptance-tests", | ||
29 | + "webpack", | ||
30 | + "jest", | ||
31 | + "src/setupTests.ts", | ||
32 | + "tslint:latest", | ||
33 | + "tslint-config-prettier" | ||
34 | + ] | ||
35 | +} |
tslint.json
0 → 100644
1 | +{ | ||
2 | + "extends": ["tslint:latest", "tslint-react", "tslint-config-prettier"], | ||
3 | + "rules": { | ||
4 | + "no-var-requires": false, | ||
5 | + "no-submodule-imports": false, | ||
6 | + "object-literal-sort-keys": false, | ||
7 | + "jsx-no-lambda": false, | ||
8 | + "no-implicit-dependencies": false, | ||
9 | + "no-console": false | ||
10 | + } | ||
11 | +} |
请
注册
或
登录
后发表评论