Skip to content

Commit

Permalink
TypeScript support (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwexler authored Nov 21, 2022
1 parent 0bae62b commit 6e00047
Show file tree
Hide file tree
Showing 4 changed files with 669 additions and 284 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v5.0.0 - 2022-11-21

Support for TypeScript, including switch to specify `parser: "@typescript-eslint/parser"` and minor modifications to
linting rules.

### 📚 Libraries

* @babel/* `7.18 -> 7.20`
* @typescript-eslint/* `added @ 5.44`
* eslint `8.20 -> 8.28`
* eslint-plugin-react `7.30 -> 7.31`
* typescript `added @ 4.9`

## v4.0.1 - 2022-07-18

Workaround for breaking ESLint v8 change to the `indent` rule when used with decorators / class properties.
Expand Down
25 changes: 19 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
plugins: ['react', 'react-hooks'],
plugins: ['react', 'react-hooks', "@typescript-eslint/eslint-plugin"],
extends: ['eslint:recommended'],

parser: "@babel/eslint-parser",
parser: "@typescript-eslint/parser",

parserOptions: {
sourceType: 'module',
babelOptions: {
configFile: "@xh/eslint-config/babel.config.js",
},
}
},

// Browser is deliberately set to false to catch errors where a missing import falls back
Expand All @@ -25,11 +25,22 @@ module.exports = {
// Setting to "false" here means "don't warn" - these are expected/valid globals.
AbortController: false,
Blob: false,
DOMRect: false,
Element: false,
Event: false,
File: false,
FileReader: false,
FocusEvent: false,
FormData: false,
Headers: false,
HTMLButtonElement: false,
HTMLElement: false,
HTMLDivElement: false,
HTMLInputElement: false,
HTMLTextAreaElement: true,
JSX: true,
KeyboardEvent: false,
MouseEvent: false,
WebSocket: false,
document: false,
fetch: false,
Expand Down Expand Up @@ -76,7 +87,6 @@ module.exports = {
args: 'none'
}],
'array-bracket-spacing': ['error', 'never'],
'consistent-this': ['error', 'me'],
'comma-dangle': 'error',
'comma-spacing': ['error', {
before: false,
Expand Down Expand Up @@ -125,7 +135,10 @@ module.exports = {
'block-scoped-var': 'error',
'semi': ['error', 'always', {
omitLastInOneLineBlock: true
}]
}],
// Allow for multiple method signatures in TS (which appear as dupe class members)
"no-dupe-class-members": "off",
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": ['error', {ignoreDeclarationMerge: true}]
}

};
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xh/eslint-config",
"version": "4.0.1",
"version": "5.0.0-SNAPSHOT.1666756809670",
"description": "Sharable base ESLint config for Hoist React applications",
"repository": "github:xh/eslint-config",
"homepage": "https://github.com/xh/eslint-config",
Expand All @@ -12,11 +12,14 @@
"babel.config.js"
],
"dependencies": {
"@babel/core": "^7.18.0",
"@babel/eslint-parser": "^7.18.0",
"@babel/eslint-plugin": "^7.17.7",
"eslint": "^8.20.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.6.0"
"@babel/core": "^7.20",
"@babel/eslint-parser": "^7.19",
"@babel/eslint-plugin": "^7.19",
"@typescript-eslint/eslint-plugin": "^5.44",
"@typescript-eslint/parser": "^5.44",
"eslint": "^8.28",
"eslint-plugin-react": "^7.31",
"eslint-plugin-react-hooks": "^4.6",
"typescript": "^4.9"
}
}
Loading

0 comments on commit 6e00047

Please sign in to comment.