Skip to content

Commit

Permalink
feat(eslint-config)!: bump ESLint to 8 and typescript-eslint to 5 (#4)
Browse files Browse the repository at this point in the history
* feat: bump ESLint to 8 and typescript-eslint to 5

* bumped eslint-plugin-jest-react

* Dedup eslint-plugin-jest-react

* Removed now-unnecessary resolutions

* Remove now-unnecessary rule

* also disable a react thing
  • Loading branch information
Josh Goldberg authored Nov 30, 2021
1 parent 06abdaa commit 64423d6
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 296 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"typescriptreact",
"html"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "downgrade" }],
"eslint.validate": [
"markdown",
"javascript",
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"@types/react": "^16.9",
"@types/react-dom": "^16.9",
"@types/stylis": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"@typescript-eslint/eslint-plugin": "^5.3.1",
"@typescript-eslint/parser": "^5.3.1",
"babel-jest": "26.6.3",
"babel-plugin-macros": "3.0.1",
"babel-preset-codecademy": "2.3.0",
Expand All @@ -75,16 +75,16 @@
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"enzyme-to-json": "3.3.5",
"eslint": "^7.19.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-jest-react": "^0.0.2",
"eslint": "^8.2.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.4",
"eslint-plugin-jest-react": "^0.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-react": "^7.25.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^1.1.4",
"eslint-plugin-unused-imports": "^1.1.5",
"husky": "4.2.5",
"identity-obj-proxy": "3.0.0",
"jest": "^26.6.3",
Expand Down
17 changes: 2 additions & 15 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
jest: true,
node: true,
},

extends: [
'eslint:recommended',
'plugin:import/errors',
Expand All @@ -21,14 +22,6 @@ module.exports = {
],

overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
// These off-by-default or configurable rules are good and we like having them on
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
},
},
// Stories generally have empty functions and other syntax shenanigans for code examples
{
files: ['*.stories.*'],
Expand Down Expand Up @@ -97,13 +90,6 @@ module.exports = {
'react/no-array-index-key': 'error',
'react/no-danger': 'error',
'react/no-unused-state': 'error',
'react/prop-types': [
'error',
{
ignore: ['children'],
skipUndeclared: true,
},
],
'simple-import-sort/imports': 'error',

// These functional rules are annoying and we generally don't want them on
Expand Down Expand Up @@ -148,6 +134,7 @@ module.exports = {
'no-use-before-define': 'off',
'no-useless-constructor': 'off',
'prefer-template': 'off',
'default-props-match-prop-types': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-filename-extension': 'off',
'react/jsx-no-bind': 'off',
Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
"eslint": "^7.32.0"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"@typescript-eslint/eslint-plugin": "^5.3.1",
"@typescript-eslint/parser": "^5.3.1",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-mdx": "^1.15.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-jest-react": "^0.0.2",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.4",
"eslint-plugin-jest-react": "^0.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-react": "^7.25.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^1.1.4",
"eslint-plugin-unused-imports": "^1.1.5",
"yargs": "^17.1.1"
},
"devDependencies": {
Expand Down
8 changes: 7 additions & 1 deletion packages/eslint-config/rules/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
*/
const tsConfig = {
extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
files: ['*.tsx', '*.ts'],
files: ['*.ts', '*.tsx'],
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
},

rules: {
// These off-by-default or configurable rules are good and we like having them on
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
},
};

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions packages/tracking/src/events/__tests__/track.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ describe('createTracker', () => {
`${apiBaseUrl}/analytics/user?utm_source=twitter`,
expect.any(FormData)
);
const formData = mockBeacon.mock.calls[0][1];
const formData = mockBeacon.mock.calls[0][1] as FormData;
expect(Object.fromEntries(formData)).toEqual(
expect.objectContaining({
category: 'user',
event,
gdpr_safe: 'undefined',
})
);
expect(JSON.parse(formData.get('properties'))).toEqual({
expect(JSON.parse(formData.get('properties') as string)).toEqual({
...expectedProps,
fullpath: window.location.pathname + window.location.search,
path: window.location.pathname,
Expand Down
Loading

0 comments on commit 64423d6

Please sign in to comment.