Skip to content

Commit

Permalink
Update to latest eslint (#479)
Browse files Browse the repository at this point in the history
* Use depcheck to remove unused dependencies

* Remove eslint-plugin-sort-destructure-keys

* eslint packages minor version updates

* typescript-eslint major version updates

* eslint-plugin-unicorn major version updates

* Fix js file lint

* Update base tslint structure

* Update to latest eslint major version

* Revert usage of structuredClone

* Restore missing react import

* Remove all instances of structureClone

* Update for compatibility with latest JBrowse
  • Loading branch information
garrettjstevens authored Nov 26, 2024
1 parent 1433542 commit aa3aab9
Show file tree
Hide file tree
Showing 85 changed files with 1,561 additions and 1,022 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

155 changes: 0 additions & 155 deletions .eslintrc.js

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ jobs:
run: yarn build
working-directory: packages/apollo-shared
- name: Lint codebase
run:
yarn eslint --report-unused-disable-directives --max-warnings 0 --ext
.js,.ts,.jsx,.tsx .
run: yarn eslint --max-warnings 0
- name: Run Jest tests
run: yarn test
- name: Get latest JBrowse
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: yarn build
working-directory: packages/apollo-shared
- name: Lint codebase
run: yarn eslint --ext .js,.ts,.jsx,.tsx .
run: yarn eslint
docker:
if: ${{ github.ref == 'refs/heads/main' }}
uses: ./.github/workflows/docker.yml
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* JS/TS files ignored since ESLint provides formatting feedback for those
*/

// eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef
// eslint-disable-next-line @typescript-eslint/no-require-imports
const spawn = require('cross-spawn')

function main() {
Expand Down
127 changes: 127 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import js from '@eslint/js'
import pluginCypress from 'eslint-plugin-cypress/flat'
import pluginImport from 'eslint-plugin-import'
import pluginJSXA11y from 'eslint-plugin-jsx-a11y'
import pluginReact from 'eslint-plugin-react'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import pluginTSDoc from 'eslint-plugin-tsdoc'
import pluginUnicorn from 'eslint-plugin-unicorn'
import globals from 'globals'
import tseslint from 'typescript-eslint'

/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: [
'.pnp.*',
'.yarn/',
'**/bin/',
'**/build/',
'**/coverage/',
'**/dist/',
'packages/website/.docusaurus/',
'packages/jbrowse-plugin-apollo/.jbrowse/',
],
},
js.configs.recommended,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
pluginUnicorn.configs['flat/recommended'],
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
pluginImport.flatConfigs.typescript,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
pluginReact.configs.flat.recommended,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
pluginJSXA11y.flatConfigs.recommended,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
pluginCypress.configs.recommended,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
parserOptions: {
projectService: {
allowDefaultProject: ['packages/jbrowse-plugin-apollo/*.js'],
},
defaultProject: 'tsconfig.json',
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
tsconfigRootDir: import.meta.dirname,
},
},
settings: { react: { version: 'detect' } },
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
plugins: { tsdoc: pluginTSDoc, import: pluginImport },
rules: {
// eslint built-in rules (override recommended)
curly: 'warn',
'new-cap': [
'error',
{
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: [
'Immutable.Map',
'Immutable.Set',
'Immutable.List',
],
},
],
'no-console': ['warn', { allow: ['error', 'warn', 'debug'] }],
'no-else-return': ['error', { allowElseIf: false }],
'no-extra-semi': 'off',
'object-shorthand': 'warn',
'prefer-destructuring': 'warn',
'prefer-template': 'warn',
radix: 'error',
// @typescript-eslint/eslint-plugin rules (override recommended)
'@typescript-eslint/no-extraneous-class': [
'error',
{ allowWithDecorator: true },
],
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'@typescript-eslint/restrict-template-expressions': [
'warn',
{ allowNumber: true },
],
'@typescript-eslint/return-await': 'error',
// eslint-plugin-import rules
'import/export': 'error',
'import/no-duplicates': 'warn',
'import/no-extraneous-dependencies': 'error',
'import/no-named-as-default': 'warn',
// eslint-plugin-tsdoc rules
'tsdoc/syntax': 'warn',
// eslint-plugin-unicorn rules (override recommended)
'unicorn/filename-case': 'off', // Doesn't match our file naming, maybe can be configured later
'unicorn/no-empty-file': 'off', // False positives
'unicorn/no-null': 'off', // A lot of null in React and other libraries
'unicorn/prefer-module': 'off', // Cypress and apollo-collaboration-server need this
'unicorn/prevent-abbreviations': 'off', // Doesn't guess a lot of abbreviations correctly
},
},
{
name: 'eslint-plugin-react-hooks/recommended',
files: [
'packages/jbrowse-plugin-apollo/src/**/*.{jsx,tsx}',
'packages/website/src/**/*.{jsx,tsx}',
],
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
plugins: { 'react-hooks': pluginReactHooks },
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
rules: { ...pluginReactHooks.configs.recommended.rules },
},
// Don't enforce tsdoc syntax in JS files
{
files: ['*.{c,m,}js', '**/*.{c,m,}js'],
rules: {
'tsdoc/syntax': 'off',
},
},
{
files: ['packages/apollo-cli/src/**/*.ts'],
rules: { '@typescript-eslint/no-deprecated': 'off' },
},
]
31 changes: 14 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packages/*"
],
"scripts": {
"lint": "cross-env NODE_OPTIONS='--max-old-space-size=4096' yarn eslint --report-unused-disable-directives --max-warnings 0 --ext .js,.ts,.jsx,.tsx .",
"lint": "cross-env NODE_OPTIONS='--max-old-space-size=4096' yarn eslint --max-warnings 0",
"build:shared": "yarn workspace @apollo-annotation/shared run build",
"release": "tsx scripts/makeGitTag.ts",
"start:shared": "yarn workspace @apollo-annotation/shared run start",
Expand All @@ -17,30 +17,26 @@
"postinstall": "husky"
},
"devDependencies": {
"@eslint/js": "^9.14.0",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^18.14.2",
"@types/semver": "^7",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/parser": "^8.14.0",
"@yarnpkg/types": "^4.0.0",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unicorn": "^48.0.0",
"eslint": "9.14.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "5.1.0-rc-4beb1fd8-20241118",
"eslint-plugin-tsdoc": "^0.3.0",
"eslint-plugin-unicorn": "^50.0.0",
"globals": "^15.12.0",
"husky": "^9.0.11",
"import-sort-parser-typescript": "^6.0.0",
"import-sort-style-module": "^6.0.0",
"jest": "^29.6.2",
"lint-staged": "^15.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
Expand All @@ -50,6 +46,7 @@
"tslib": "^2.3.1",
"tsx": "^4.6.2",
"typescript": "^5.5.3",
"typescript-eslint": "^8.14.0",
"yargs": "^17.7.2"
},
"packageManager": "yarn@4.3.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import * as fs from 'node:fs'
import * as path from 'node:path'
import path from 'node:path'
import { Args, Flags } from '@oclif/core'
import { ObjectId } from 'bson'

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-cli/src/commands/assembly/add-from-gff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'node:fs'
import * as path from 'node:path'
import path from 'node:path'

import { Args, Flags } from '@oclif/core'
import { ObjectId } from 'bson'
Expand Down
Loading

0 comments on commit aa3aab9

Please sign in to comment.