Skip to content

Commit

Permalink
Migrate to ESLint 9 and ESLint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Oct 17, 2024
1 parent ea96ea6 commit 751db0f
Show file tree
Hide file tree
Showing 11 changed files with 737 additions and 999 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

51 changes: 0 additions & 51 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ dist/
node_modules/
coverage/

.eslintcache

# The client uses yarn rather than npm to manage the lockfile.
package-lock.json

Expand Down
94 changes: 94 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import hypothesis from 'eslint-config-hypothesis';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: [
'.yalc/**/*',
'.yarn/**/*',
'build/**/*',
'dist/**/*',
'**/vendor/**/*.js',
'**/coverage/**/*',
'docs/_build/*',
// TODO - Lint these files
'rollup*.config.js',
],
},
...hypothesis,
...tseslint.configs.recommended,
{
rules: {
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'object-shorthand': ['error', 'properties'],

// Upgrade TS rules from warning to error.
'@typescript-eslint/no-unused-vars': 'error',

// Disable TS rules that we dislike.
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'off',

// Enforce consistency in cases where TypeScript supports old and new
// syntaxes for the same thing.
//
// - Require `<var> as <type>` for casts
// - Require `import type` for type imports. The corresponding rule for
// exports is not enabled yet because that requires setting up type-aware
// linting.
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
},
languageOptions: {
globals: {
chrome: false,
},
},
},

// Entry points which get loaded as non-module scripts.
{
files: ['src/unload-client.js'],
rules: {
strict: ['error', 'global'],
},
languageOptions: {
parserOptions: {
sourceType: 'script',
},
},
},

// CommonJS scripts which run in Node
{
files: ['tests/karma.config.cjs'],
rules: {
strict: ['error', 'global'],
},
languageOptions: {
parserOptions: {
sourceType: 'script',
},
globals: {
...globals.node,
},
},
},

// ESM scripts which run in Node
{
files: ['tools/*.js'],
rules: {
'no-console': 'off',
},
languageOptions: {
globals: {
...globals.node,
},
},
},
);
2 changes: 0 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */
/* eslint-env node */
// @ts-nocheck

import { spawn } from 'node:child_process';
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
"@rollup/plugin-multi-entry": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@types/chrome": "^0.0.277",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-plugin-istanbul": "^7.0.0",
"babel-plugin-mockable-imports": "^2.0.1",
"chai": "^5.1.1",
"chrome-webstore-upload-cli": "^3.3.1",
"diff": "^7.0.0",
"eslint": "^8.57.0",
"eslint-config-hypothesis": "^2.6.0",
"eslint-plugin-mocha": "^10.4.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^9.12.0",
"eslint-config-hypothesis": "^3.0.0",
"eslint-plugin-mocha": "^10.5.0",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^5.0.0",
"git-describe": "^4.1.1",
"globals": "^15.11.0",
"gulp": "^5.0.0",
"hypothesis": "^1.1527.0",
"is-equal-shallow": "^0.1.3",
Expand All @@ -47,10 +46,12 @@
"rollup": "^4.24.0",
"sinon": "^19.0.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.9.0",
"web-ext": "^7.12.0"
},
"browserslist": "chrome 85, firefox 75",
"scripts": {
"lint": "eslint --cache .",
"test": "rollup -c rollup-tests.config.js && karma start tests/karma.config.cjs --single-run",
"typecheck": "tsc --build src/tsconfig.json"
},
Expand Down
5 changes: 0 additions & 5 deletions src/background/.eslintrc

This file was deleted.

5 changes: 0 additions & 5 deletions tests/background/.eslintrc

This file was deleted.

3 changes: 1 addition & 2 deletions tests/karma.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-require-imports */
'use strict';

/* global __dirname */

const path = require('path');

module.exports = function (config) {
Expand Down
9 changes: 0 additions & 9 deletions tools/.eslintrc

This file was deleted.

Loading

0 comments on commit 751db0f

Please sign in to comment.