Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial pass adding typescript-eslint
  • Loading branch information
ianschmitz committed Feb 24, 2019
commit f5f98a703361fa88af13e3e4728ce76d65dbc104
64 changes: 64 additions & 0 deletions packages/eslint-config-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,70 @@ module.exports = {
},
},

overrides: {
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},

// typescript-eslint specific options
// TODO: Get these paths from somewhere so the parser has type info
// project: './tsconfig.json',
// tsconfigRootDir: '../../',
// TODO: Do we want to warn if version is unsupported? This could be a source of pain as new versions of TS come out and users upgrade
warnOnUnsupportedTypeScriptVersion: true,
},
plugins: ['@typescript-eslint'],
rules: {
// These ESLint rules are known to cause issues with typescript-eslint
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json
camelcase: 'off',
indent: 'off',
'no-array-constructor': 'off',
'no-unused-vars': 'off',

// TODO: Strip out unused rules

// '@typescript-eslint/adjacent-overload-signatures': 'warn',
// '@typescript-eslint/array-type': 'warn',
// '@typescript-eslint/ban-types': 'warn',
// '@typescript-eslint/camelcase': 'error',
// '@typescript-eslint/class-name-casing': 'error',
// '@typescript-eslint/explicit-function-return-type': 'warn',
// '@typescript-eslint/explicit-member-accessibility': 'error',
// '@typescript-eslint/indent': 'error',
// '@typescript-eslint/interface-name-prefix': 'error',
// '@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
'@typescript-eslint/no-array-constructor': 'warn',
// '@typescript-eslint/no-empty-interface': 'error',
// '@typescript-eslint/no-explicit-any': 'warn',
// '@typescript-eslint/no-inferrable-types': 'error',
// '@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
// '@typescript-eslint/no-non-null-assertion': 'error',
// '@typescript-eslint/no-object-literal-type-assertion': 'error',
// '@typescript-eslint/no-parameter-properties': 'error',
// '@typescript-eslint/no-triple-slash-reference': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
ignoreRestSiblings: true,
},
],
// '@typescript-eslint/no-use-before-define': 'warn',
// '@typescript-eslint/no-var-requires': 'error',
// '@typescript-eslint/prefer-interface': 'error',
// '@typescript-eslint/prefer-namespace-keyword': 'error',
// '@typescript-eslint/type-annotation-spacing': 'error',
},
},

rules: {
// http://eslint.org/docs/rules/
'array-callback-return': 'warn',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"index.js"
],
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "1.x",
"@typescript-eslint/parser": "1.x",
"babel-eslint": "9.x",
"eslint": "5.x",
"eslint-plugin-flowtype": "2.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ module.exports = function(webpackEnv) {
// First, run the linter.
// It's important to do this before Babel processes the JS.
{
test: /\.(js|mjs|jsx)$/,
test: /\.(js|mjs|jsx|ts|tsx)$/,
enforce: 'pre',
use: [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"dependencies": {
"@babel/core": "7.2.2",
"@svgr/webpack": "4.1.0",
"@typescript-eslint/eslint-plugin": "1.4.1",
"@typescript-eslint/parser": "1.4.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.6.0",
Expand Down