• xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!


    Typescript & React & optional parameters & default parameters

    Typescript & optional parameters

    https://www.typescriptlang.org/docs/handbook/functions.html#optional-and-default-parameters


    ESLint warning bug & Typescript & optional parameters

    typescript optional parameters warnings

    https://stackoverflow.com/questions/tagged/visual-studio-code

    https://github.com/microsoft/vscode/issues/83056

    vscode ts 的error信息可以去掉;settings.json 加上这句 "javascript.implicitProjectConfig.experimentalDecorators": true

    
    {
      "resource": "/Users/xgqfrms/ubt/src/pages/ManagePage/PointCheck/CheckDetail/index.js",
      "owner": "typescript",
      "code": "1219",
      "severity": 8,
      "message": "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.",
      "source": "ts",
      "startLineNumber": 27,
      "startColumn": 7,
      "endLineNumber": 27,
      "endColumn": 18
    }
    
    

    ESLint & max-lines

    https://eslint.org/docs/rules/max-lines

    /* eslint-disable */
    
    
        "max-lines": [
          "error",
          {
            "max": 500,
            "skipBlankLines": true ,
            "skipComments": true
          }
        ],
    
    

    .eslintrc

    
    {
      "extends": ["eslint-config-umi", "standard", "standard-jsx", "standard-react"],
      "rules": {
        "no-console": 2, //0,1,2
        /**
         * 禁止使用 debugger
         */
        "no-debugger": "error",
        // 禁止使用var
        "no-var": "error",
        // 使用分号
        "semi": ["error", "always"],
        "space-before-function-paren": [
          "error",
          { "anonymous": "always", "named": "never", "asyncArrow": "always" }
        ],
        "comma-dangle": ["error", "always-multiline"],
        "generator-star-spacing": ["error", { "before": true, "after": false }],
        "standard/no-callback-literal": "off",
        /**
         * 禁止函数的循环复杂度超过 20
         * @reason https://en.wikipedia.org/wiki/Cyclomatic_complexity
         */
        "complexity": [
          "error",
          {
            "max": 20
          }
        ],
        /**
         * getter 必须有返回值,并且禁止返回空
         */
        "getter-return": "error",
        /**
         * 代码块嵌套的深度禁止超过 5 层
         */
        "max-depth": ["error", 5],
        /**
         * 回调函数嵌套禁止超过 3 层,多了请用 async await 替代
         */
        "max-nested-callbacks": ["error", 3],
        /**
         * 函数的参数禁止超过 7 个
         */
        "max-params": ["error", 7],
        /**
         * 禁止直接使用 Buffer
         * @reason Buffer 构造函数是已废弃的语法
         */
        "no-buffer-constructor": "error",
        /**
         * 禁止重复导入模块
         */
        "no-duplicate-imports": "error",
        /**
         * 禁止出现空代码块,允许 catch 为空代码块
         */
        "no-empty": [
          "error",
          {
            "allowEmptyCatch": true
          }
        ],
        /**
         * 禁止使用 foo == null,必须使用 foo === null
         */
        "no-eq-null": "error",
        /**
         * 禁止使用特殊空白符(比如全角空格),除非是出现在字符串、正则表达式或模版字符串中
         */
        "no-irregular-whitespace": [
          "error",
          {
            "skipStrings": true,
            "skipComments": false,
            "skipRegExps": true,
            "skipTemplates": true
          }
        ],
        /**
         * 禁止对函数的参数重新赋值
         */
        "no-param-reassign": "error",
    
        /**
         * 必须使用 ... 而不是 Object.assign,除非 Object.assign 的第一个参数是一个变量
         */
        "prefer-object-spread": "error",
        /**
         * generator 函数内必须有 yield
         */
        "require-yield": "error",
        /**
         * 必须使用 if (foo === 5) 而不是 if (5 === foo)
         */
        "yoda": [
          "error",
          "never",
          {
            "onlyEquality": true
          }
        ],
        /**
         * 数组中的 jsx 必须有 key
         */
        "react/jsx-key": [
          "error",
          {
            "checkFragmentShorthand": true
          }
        ],
    
        /**
         * 禁止将 children 作为一个 prop
         */
        "react/no-children-prop": "error",
        /**
         * 禁止在使用了 dangerouslySetInnerHTML 的组件内添加 children
         */
        "react/no-danger-with-children": "error",
    
        /**
         * 禁止直接修改 this.state
         */
        "react/no-direct-mutation-state": "error",
        /**
         * 禁止使用 findDOMNode
         */
        "react/no-find-dom-node": "error",
        /**
         * 禁止使用 isMounted
         * @reason 它是已废弃的语法
         */
        "react/no-is-mounted": "error",
        /**
         * 禁止使用 ReactDOM.render 的返回值
         */
        "react/no-render-return-value": "error",
        /**
         * 禁止使用字符串 ref
         */
        "react/no-string-refs": "error",
        /**
         * 禁止在函数组件中使用 this
         */
        "react/no-this-in-sfc": "error",
        /**
         * 禁止组件的属性或生命周期大小写错误
         */
        "react/no-typos": "error",
        /**
         * render 方法中必须有返回值
         */
        "react/require-render-return": "error",
        /**
         * style 属性的取值必须是 object
         */
        "react/style-prop-object": "error",
        /**
         * img, br 标签中禁止有 children
         */
        "react/void-dom-elements-no-children": "error",
        // 如果你要用 state refs, 最好用 class extends React.Component 而不是 React.createClass
        "react/prefer-stateless-function": 2,
        // 将多行的JSX标签写在 ()里
        "react/jsx-wrap-multilines": 2,
        // 禁止xml tag has empty body
        "react/self-closing-comp": [
          "error",
          {
            "component": true,
            "html": true
          }
        ],
        // 没有引入React,报错
        "react/react-in-jsx-scope": "error",
        "react/prop-types": "off",
        "react/jsx-fragments": "off",
        "react/jsx-handler-names": "off",
        "react/no-unused-prop-types": "off"
    
    
    //    "react/jsx-curly-brace-presence": "off",
    //    "jsx-quotes": "off"
      }
    }
    

    vscode

    "eslint.autoFixOnSave": true,

    {
      "eslint.alwaysShowStatus": true,
      "eslint.packageManager": "yarn",
    //   "eslint.parserOptions": {
    //     "parser": "babel-eslint"
    //   },
    //   "eslint.validate":[
    //     "javascript",
    //     "javascriptreact"
    //   ],
      "eslint.autoFixOnSave": true,
      "typescript.validate.enable": false,
      "editor.tabSize": 2,
      "eslint.trace.server": "messages",
      "files.exclude": {
          "**/.git": true,
          "**/.DS_Store": true,
          "**/jspm_packages": true,
          "**/node_modules": true,
          "**/.zip": true,
          "**/.sh": true
      },
      "search.exclude": {
          "**/node_modules": true,
          "**/bower_components": true
      },
      "files.watcherExclude": {
          "**/.git/objects/**": true,
          "**/.git/subtree-cache/**": true,
          "**/node_modules/*/**": true
      },
      "editor.formatOnSave": false,
      "editor.formatOnPaste": false,
      "editor.renderWhitespace": "all",
      "editor.fontSize": 16,
        //   "editor.tabSize": 4,
      "editor.multiCursorModifier": "alt",
      "editor.wordWrap": "on",
      "editor.insertSpaces": true,
      "files.encoding": "utf8",
      "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
      "[typescript]": {
          "editor.formatOnSave": false,
          "editor.formatOnPaste": false
      },
      "[javascript]": {
          "editor.formatOnSave": false,
          "editor.formatOnPaste": false,
          "editor.renderWhitespace": "all",
          "editor.foldingStrategy": "indentation",
          // "editor.foldingStrategy": "auto"
          "editor.getOutliningSpans": ""
      },
      "[javascriptreact]": {
          "editor.formatOnSave": false,
          "editor.formatOnPaste": false,
          "editor.renderWhitespace": "all",
          "editor.foldingStrategy": "indentation"
      },
      "[markdown]": {
          "editor.formatOnSave": true,
          "editor.renderWhitespace": "all",
          "editor.acceptSuggestionOnEnter": "off"
      },
      "[html]": {
          "editor.formatOnSave": false,
          "editor.formatOnPaste": false,
          "editor.renderWhitespace": "all",
          "editor.acceptSuggestionOnEnter": "off"
      },
      "files.associations": {
          "*.jsx": "javascriptreact",
          "*.js": "javascriptreact"
      },
      "editor.snippetSuggestions": "top",
      // When enabled, typing /** triggers documentation automatically.
      "docthis.automaticForBlockComments": true,
      // When enabled, type information is added to comment tags.
      "docthis.includeTypes": true,
      // When enabled, memberOf information is added to comment tags on class members.
      "docthis.includeMemberOfOnClassMembers": true,
      // When enabled, memberOf information is added to comment tags on interface members.
      "docthis.includeMemberOfOnInterfaceMembers": true,
      // When enabled, JSDoc comments for functions and methods will include @description.
      "docthis.includeDescriptionTag": true,
      // When enabled, hungarian notation will be used as a type hint.
      "docthis.enableHungarianNotationEvaluation": true,
      // When enabled, will use names of params & methods as type hints.
      "docthis.inferTypesFromNames": true,
      // When enabled, will add the @author tag.
      "docthis.includeAuthorTag": true,
      // When docthis.includeAuthorTag is enabled, will add @author tag with this value.
      "docthis.authorName": "xgqfrms",
      // HTML & overwrite User settings.json
      "html.format.extraLiners": "",
      "html.format.enable": false,
      "html.format.contentUnformatted": "body, div, section, script, pre,code,textarea"
    }
    
    
    



    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    转载:javaweb学习总结(二十九)——EL表达式
    转载:javaweb学习总结(二十八)——JSTL标签库之核心标签
    转载:javaweb学习总结(二十七)——jsp简单标签开发案例和打包
    空指针异常
    转载:javaweb学习总结(二十六)——jsp简单标签标签库开发(二)
    转载:javaweb学习总结(二十五)——jsp简单标签开发(一)
    转载:javaweb学习总结(二十四)——jsp传统标签开发
    线性代数的本质-05-行列式
    线性代数的本质-04补充-三维空间中的线性变换
    线性代数的本质-04-矩阵乘法与线性变换复合
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/11722254.html
Copyright © 2020-2023  润新知