Skip to content

Commit

Permalink
Use TS shared config from eslint-config-hypothesis
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Oct 18, 2024
1 parent 751db0f commit 50d4d41
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1,031 deletions.
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(
},
},
},
);
];
4 changes: 1 addition & 3 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 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

0 comments on commit 50d4d41

Please sign in to comment.