Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TS shared config from eslint-config-hypothesis #1618

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 7 additions & 29 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import hypothesis from 'eslint-config-hypothesis';
import hypothesisBase from 'eslint-config-hypothesis/base';
import hypothesisTS from 'eslint-config-hypothesis/ts';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
export default [
{
ignores: [
'.yalc/**/*',
Expand All @@ -16,33 +16,11 @@ export default tseslint.config(
'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',
...hypothesisBase,
...hypothesisTS,

// 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,
Expand Down Expand Up @@ -91,4 +69,4 @@ export default tseslint.config(
},
},
},
);
];
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
"chrome-webstore-upload-cli": "^3.3.1",
"diff": "^7.0.0",
"eslint": "^9.12.0",
"eslint-config-hypothesis": "^3.0.0",
"eslint-config-hypothesis": "^3.1.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",
Expand All @@ -46,7 +44,7 @@
"rollup": "^4.24.0",
"sinon": "^19.0.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.9.0",
"typescript-eslint": "^8.10.0",
"web-ext": "^7.12.0"
},
"browserslist": "chrome 85, firefox 75",
Expand Down
2 changes: 1 addition & 1 deletion tests/background/browser-action-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('BrowserAction', () => {

describe('build type', () => {
beforeEach(() => {
let fakeSettings = {
const fakeSettings = {
buildType: 'staging',
};
$imports.$mock({
Expand Down
6 changes: 3 additions & 3 deletions tests/background/chrome-api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('chrome-api', () => {

const chromeAPI = getChromeAPI(fakeChrome);

for (let namespace of Object.keys(fakeChrome)) {
for (let methodName of Object.keys(fakeChrome[namespace])) {
for (const namespace of Object.keys(fakeChrome)) {
for (const methodName of Object.keys(fakeChrome[namespace])) {
const method = fakeChrome[namespace][methodName];
if (typeof method !== 'function') {
// Skip listeners `on<Event>` and nested namespaces (eg. `storage.sync.get`).
Expand All @@ -78,7 +78,7 @@ describe('chrome-api', () => {
}

const arg = {};
let result = chromeAPI[namespace][methodName](arg);
const result = chromeAPI[namespace][methodName](arg);
assert.calledWith(method, arg);

if (!syncAPIs.has(method)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/background/extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function delay(ms) {
}

describe('Extension', () => {
let sandbox = sinon.createSandbox();
const sandbox = sinon.createSandbox();
let ext;
let fakeChromeAPI;
let fakeErrors;
Expand Down
2 changes: 1 addition & 1 deletion tools/template-context-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as fs from 'node:fs';
import * as path from 'node:path';

function appSettings(settings) {
let result = {};
const result = {};
result.apiUrl = settings.apiUrl;
result.assetRoot = '/client/';
result.authDomain = settings.authDomain;
Expand Down
Loading