Giter VIP home page Giter VIP logo

eslint-plugin-tsc's Introduction

eslint-plugin-tsc

Wraps a TypeScript compiler checks

INSTALL

npm install --save-dev eslint-plugin-tsc

USAGE

Configure it in your configuration file:

  1. Add to plugins section:
tsc
  1. Add rule to rules section, e.g.
"tsc/config": [1, {
    configFile: "tsconfig.json"
}]

RULES

  • tsc/config Wraps a TypeScript compiler checks
    Configuration { configFile: string, compilerOptions?: ts.CompilerOptions }
    configFile path to tsconfig.json file (it's better to specify an absolute path)
    compilerOptions ability to override compilerOptions defined in config file

CHANGELOG

See CHANGELOG.md

TODO

TypeScript Compiler has various linting options

  • allowUnreachableCode
  • allowUnusedLabels
  • forceConsistentCasingInFileNames
  • noFallthroughCasesInSwitch
  • noImplicitAny
  • noImplicitReturns
  • noImplicitThis
  • noStrictGenericChecks
  • noUnusedLocals
  • noUnusedParameters
  • strictFunctionTypes
  • strictPropertyInitialization
  • strictNullChecks
  • suppressExcessPropertyErrors
  • suppressImplicitAnyIndexErrors

USEFUL LINKS

eslint-plugin-tsc's People

Contributors

rumanhuq avatar semantic-release-bot avatar unlight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rumanhuq

eslint-plugin-tsc's Issues

unable to use in vue file

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true,
    "jest": true
  },
  "plugins": [
    "import",
    "html",
    "typescript",
    "tslint",
    "tsc"
  ],
  "parser": "vue-eslint-parser",
  "parserOptions": {
    "parser": "typescript-eslint-parser",
    "ecmaFeatures": {
      "jsx": true,
      "useJSXTextNode": true,
      "classes": true
    },
    "sourceType": "module"
  },
  "root": true,
  "extends": [
    "airbnb-base",
    "plugin:prettier/recommended",
    "plugin:vue/recommended"
  ],
  "settings": {
    "html/indent": "+2",
    "import/resolver": {
      "node": true,
      "eslint-import-resolver-typescript": true,
      "webpack": {
        "config": {
          "resolve": {
            "extensions": [
              ".vue",
              ".ts",
              ".js",
              ".yml"
            ]
          }
        }
      }
    }
  },
  "rules": {
    "max-len": [
      "error",
      {
        "code": 160
      }
    ],
    "no-multi-spaces": 2,
    "camelcase": 0,
    "no-param-reassign": 0,
    "no-underscore-dangle": 0,
    "no-unused-vars": 0,
    "import/no-named-as-default": 0,
    "import/no-unresolved": 0,
    "prettier/prettier": {
      "trailingComma": "all",
      "printWidth": 160
    },
    "comma-dangle": 2,
    "vue/html-closing-bracket-newline": [
      "error",
      {
        "singleline": "never",
        "multiline": "always"
      }
    ],
    "vue/max-attributes-per-line": [
      "error",
      {
        "singleline": 4,
        "multiline": {
          "max": 1,
          "allowFirstLine": false
        }
      }
    ],
    "vue/require-default-prop": false,
    "indent": [
      "error",
      2
    ],
    "linebreak-style": "error",
    "no-multiple-empty-lines": [
      "error",
      {
        "max": 1,
        "maxEOF": 0
      }
    ],
    "object-curly-newline": [
      "error",
      {
        "multiline": true
      }
    ],
    "comma-spacing": [
      "error",
      {
        "before": false,
        "after": true
      }
    ],
    "no-trailing-spaces": "error",
    "no-console": "warn",
    "semi": "error",
    "quotes": [
      "error",
      "double"
    ],
    "object-curly-spacing": [
      "error",
      "always"
    ],
    "space-before-blocks": [
      "error",
      {
        "functions": "always",
        "keywords": "always",
        "classes": "never"
      }
    ],
    "typescript/no-unused-vars": "error",
    "require-jsdoc": [
      "error",
      {
        "require": {
          "FunctionDeclaration": true,
          "MethodDefinition": true,
          "ClassDeclaration": true,
          "ArrowFunctionExpression": true,
          "FunctionExpression": false
        }
      }
    ],
    "tsc/config": [1, {
      "configFile": "tsconfig.json"
  }]
  }
}

if I move the typescript-eslint-parser from parserOptions to top level, it works as intended. But then vue file breaks

TSC does not run when adding plugin and rule to .eslintrc.js

When following the README to add the package:

Add to plugins section:

tsc

Add rule to rules section, e.g.

"tsc/config": [1, {
    configFile: "tsconfig.json"
}]

When running eslint the tsc does not catch any errors.

However, if I remove this configuration and pass it inline with the command it works:

eslint --fix --plugin tsc --rule 'tsc/config: [2, {configFile: \"tsconfig.json\"}]'

Here is my eslint config:

module.exports = {
  "extends": ["prettier", "react-app", "plugin:import/typescript"],
  "plugins": ["tsc", "prettier", "react", "react-hooks", "@typescript-eslint"],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jest": true
  },
  "rules": {
    "tsc/config": [1, {
      configFile: "tsconfig.json"
    }],
    "array-callback-return": "off",
    "arrow-parens": "off",
    "comma-dangle": "off",
    "consistent-return": "off",
    "eqeqeq": "off",
    "function-paren-newline": "off",
    "import/extensions": "error",
    "import/first": "error",
    "import/order": "error",
    "import/no-deprecated": "error",
    "import/no-duplicates": "error",
    "import/no-extraneous-dependencies": "off",
    "import/no-named-as-default": "off",
    "import/no-unresolved": "error",
    "import/prefer-default-export": "off",
    "indent": "off", // in conflict with prettier
    "jsx-a11y/anchor-is-valid": "off",
    "jsx-a11y/no-redundant-roles": "off",
    "max-len": 0, // in conflict with prettier
    "no-confusing-arrow": "off",
    "no-else-return": "error",
    "no-nested-ternary": "off",
    "no-return-assign": "off",
    "no-param-reassign": "off",
    "no-undef": "error",
    "no-unused-vars": "error",
    "no-use-before-define": "error",
    "object-curly-newline": "off",
    "prefer-const": "error",
    "prefer-destructuring": "error",
    "prefer-rest-params": "off",
    "prettier/prettier": "error",
    "react/default-props-match-prop-types": "off",
    "react/forbid-prop-types": "off",
    "react/jsx-boolean-value": 2,
    "react/jsx-filename-extension": "off",
    "react/jsx-uses-react": 2,
    "react/jsx-uses-vars": 2,
    "react/no-array-index-key": 2,
    "react/no-unescaped-entities": "off",
    "react/no-unused-state": "off",
    "react/prefer-stateless-function": "error",
    "react/prop-types": "error",
    "react/require-default-props": 2,
    "react/sort-comp": 2,
    "semi": "off",
    "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
    "react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
  },
  overrides: [
    {
      files: ['**/*.ts', '**/*.tsx'],
      rules: {
        "react/prop-types": "off",
        '@typescript-eslint/no-unused-vars': [
          'error',
          {
            args: 'none',
            ignoreRestSiblings: true,
          },
        ],
      },
      parser: '@typescript-eslint/parser',
      parserOptions: {
        ecmaVersion: 2018,
        sourceType: 'module',
        ecmaFeatures: { jsx: true },
        warnOnUnsupportedTypeScriptVersion: true,
      },
    },
  ],
  settings: {
    'import/resolver': {
      node: {
          extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    },
  },
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.