Browse Source

feat: pre-commit & lint-staged

richard1015 5 years ago
parent
commit
2e19d31c3b
3 changed files with 3 additions and 90 deletions
  1. 0 71
      eslint-config.js
  2. 3 5
      package.json
  3. 0 14
      stylelint-config.js

+ 0 - 71
eslint-config.js

@@ -1,71 +0,0 @@
-module.exports = {
-  extends: ['plugin:vue/recommended'],
-
-  parserOptions: {
-    parser: '@typescript-eslint/parser',
-    ecmaVersion: 2018,
-    sourceType: 'module',
-    extraFileExtensions: ['.vue']
-  },
-
-  plugins: ['@typescript-eslint'],
-
-  env: {
-    es6: true,
-    node: true,
-    jest: true,
-    browser: true
-  },
-
-  globals: {
-    window: false,
-    document: false,
-    navigator: false
-  },
-
-  rules: {
-    'no-new': 0,
-    'no-shadow': 0,
-    camelcase: 1,
-    'no-bitwise': 0,
-    'func-names': 0,
-    'no-console': 0,
-    'no-plusplus': 0,
-    'arrow-parens': 0,
-    'comma-dangle': 0,
-    'default-case': 0,
-    'prefer-template': 0,
-    'consistent-return': 0,
-    'no-param-reassign': 0,
-    'no-nested-ternary': 0,
-    'operator-linebreak': 0,
-    'object-curly-newline': 0,
-    'no-underscore-dangle': 1,
-    'no-unused-expressions': 0,
-    'no-restricted-globals': 0,
-    'function-paren-newline': 0,
-    'class-methods-use-this': 0,
-    'implicit-arrow-linebreak': 0,
-    'space-before-function-paren': 0,
-    'max-len': ['error', { code: 150 }],
-    'prefer-destructuring': ['error', { object: true, array: false }],
-    'import/order': 0,
-    'import/extensions': 0,
-    'import/no-unresolved': 0,
-    'import/prefer-default-export': 0,
-    'import/no-extraneous-dependencies': 0,
-    'vue/no-v-html': 0,
-    'vue/attributes-order': 0,
-    'vue/require-v-for-key': 0,
-    'vue/require-default-prop': 0,
-    'vue/no-unused-components': 0,
-    'vue/max-attributes-per-line': 0,
-    'vue/singleline-html-element-content-newline': 0,
-    'vue/name-property-casing': ['error', 'kebab-case'],
-    'vue/component-name-in-template-casing': ['error', 'kebab-case'],
-    'vue/html-closing-bracket-newline': 2,
-    '@typescript-eslint/no-unused-vars': ['error'],
-    'vue/html-indent': 0,
-    'vue/html-self-closing': 0
-  }
-};

+ 3 - 5
package.json

@@ -21,7 +21,6 @@
     "test": "cross-env NODE_ENV=test nyc mocha-webpack --webpack-config node_modules/@nutui/cli/dist_cli/webpack/test.config.js  --require node_modules/@nutui/cli/dist_cli/test/setup.js src/packages/navbar/__test__/**.spec.js",
     "coveralls": "cat ./coverage/lcov.info | coveralls",
     "test:watch": "npm run test --watch",
-    "prettier:fix": "prettier --write src/**/*.{js,vue,scss}",
     "upload:test": "node test_script/upload.js"
   },
   "repository": {
@@ -36,14 +35,12 @@
   },
   "husky": {
     "hooks": {
+      "pre-commit": "lint-staged",
       "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
     }
   },
   "lint-staged": {
-    "src/**/*.{js,vue,scss}": [
-      "prettier --write src/**/*.{js,vue,scss}",
-      "git add"
-    ]
+    "*.{ts,js,vue,scss}": "prettier --write"
   },
   "stylelint": {
     "extends": [
@@ -89,6 +86,7 @@
     "husky": "^3.0.0",
     "mutation-observer": "^1.0.3",
     "prettier": "^2.0.5",
+    "lint-staged": "^10.2.11",
     "stylelint-config-standard": "^19.0.0"
   },
   "nyc": {

+ 0 - 14
stylelint-config.js

@@ -1,14 +0,0 @@
-module.exports = {
-  extends: ['stylelint-config-standard'],
-  rules: {
-    // 'order/properties-order': [],
-    // 'at-rule-no-unknown': null,
-    // 'number-leading-zero': null,
-    // 'no-descending-specificity': null,
-    // 'declaration-colon-newline-after': null,
-    // 'font-family-no-missing-generic-family-keyword': null
-    indentation: 'tab',
-    'number-leading-zero': null,
-    'no-empty-source': 0
-  }
-};