Browse Source

chore: use lint-staged

master
Hans Chan 4 years ago
parent
commit
ec2371730e
  1. 1
      .gitignore
  2. 13
      package.json
  3. 3
      packages/cli/package.json
  4. 11
      packages/cli/src/cmd/editor/build.js

1
.gitignore

@ -2,6 +2,7 @@
.vscode .vscode
.eslintcache .eslintcache
.size-snapshot.json .size-snapshot.json
.husky
npm-debug.log* npm-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log lerna-debug.log

13
package.json

@ -2,17 +2,14 @@
"name": "root", "name": "root",
"private": true, "private": true,
"scripts": { "scripts": {
"lint": "eslint --cache --fix --ext .ts,tsx,js,jsx ./packages/**/src > ./.eslint-error.log; exit 0",
"test": "jest --coverage", "test": "jest --coverage",
"e2e": "cypress open", "e2e": "cypress open",
"doc": "dumi dev", "doc": "dumi dev",
"start": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\"", "start": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\"",
"example": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\" \"imove -d\"", "example": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\" \"imove -d\"",
"postinstall": "lerna init && lerna bootstrap && npm link packages/cli" "postinstall": "lerna init && lerna bootstrap && npm link packages/cli",
"prepare": "husky install"
}, },
"pre-commit": [
"lint"
],
"jest": { "jest": {
"projects": [ "projects": [
"config/cli.jest.config.js", "config/cli.jest.config.js",
@ -37,12 +34,13 @@
"eslint-config-prettier": "^7.2.0", "eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1", "eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0", "eslint-plugin-react": "^7.22.0",
"husky": "^7.0.1",
"lerna": "^3.22.1", "lerna": "^3.22.1",
"less": "^3.12.2", "less": "^3.12.2",
"lint-staged": "^11.0.1",
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"ora": "^4.1.1", "ora": "^4.1.1",
"postcss": "^8.2.1", "postcss": "^8.2.1",
"pre-commit": "^1.2.2",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"rollup": "^2.6.1", "rollup": "^2.6.1",
"rollup-plugin-postcss": "^4.0.0", "rollup-plugin-postcss": "^4.0.0",
@ -53,5 +51,8 @@
"typescript": "^4.1.3", "typescript": "^4.1.3",
"umi": "^3.3.3", "umi": "^3.3.3",
"watch": "^1.0.2" "watch": "^1.0.2"
},
"lint-staged": {
"packages/**/*.{ts,tsx,js,jsx}": "eslint --cache --fix"
} }
} }

3
packages/cli/package.json

@ -11,7 +11,8 @@
"compile" "compile"
], ],
"scripts": { "scripts": {
"build:editor": "node src/cmd/editor/build.js" "build:editor": "node src/cmd/editor/build.js",
"prepare": "npm run build:editor"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

11
packages/cli/src/cmd/editor/build.js

@ -1,12 +1,21 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path'); const path = require('path');
const fs = require('fs-extra');
const { lessLoader } = require('esbuild-plugin-less'); const { lessLoader } = require('esbuild-plugin-less');
const outfile = path.join(__dirname, 'template/dist/app.bundle.js');
// if builded and NOT force re-build, exit
if (fs.existsSync(outfile) && process.argv.indexOf('--force') < 0) {
console.log('imove editor alredy builded');
return;
}
require('esbuild') require('esbuild')
.build({ .build({
bundle: true, bundle: true,
entryPoints: [path.join(__dirname, 'template/app.jsx')], entryPoints: [path.join(__dirname, 'template/app.jsx')],
outfile: path.join(__dirname, 'template/dist/app.bundle.js'), outfile,
plugins: [ plugins: [
// fix import('antd/dist/antd.less') // fix import('antd/dist/antd.less')
{ {

Loading…
Cancel
Save