Skip to content

Commit

Permalink
chore(eslint): migrate config file
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Oct 22, 2024
1 parent d8bb67a commit e6d14e5
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 58 deletions.
30 changes: 0 additions & 30 deletions .eslintrc.json

This file was deleted.

11 changes: 0 additions & 11 deletions __tests__/.eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion editor/js/editable-wat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ import {
// using an async function since WebAssembly.instantiate is async and
// we need to await in order to capture errors
const AsyncFunction = Object.getPrototypeOf(
// eslint-disable-next-line @typescript-eslint/no-empty-function
async function () {},
).constructor;
await new AsyncFunction(exampleCode)();
Expand Down
3 changes: 1 addition & 2 deletions editor/js/editor-libs/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function (targetWindow?: Window & typeof globalThis) {
/* Getting reference to console, either from current window or from the iframe window */
const console = targetWindow ? targetWindow.console : window.console;

const originalConsoleLogger = console.log; // eslint-disable-line no-console
const originalConsoleLogger = console.log;
const originalConsoleError = console.error;

console.error = function (loggedItem: any, ...otherArgs: any[]) {
Expand All @@ -14,7 +14,6 @@ export default function (targetWindow?: Window & typeof globalThis) {
originalConsoleError.apply(console, [loggedItem, ...otherArgs]);
};

// eslint-disable-next-line no-console
console.log = function (...args) {
const formattedList = [];
for (let i = 0, l = args.length; i < l; i++) {
Expand Down
67 changes: 67 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {
fixupConfigRules,
fixupPluginRules,
includeIgnoreFile,
} from "@eslint/compat";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import _import from "eslint-plugin-import";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
const prettierignorePath = path.resolve(__dirname, ".prettierignore");

export default [
includeIgnoreFile(prettierignorePath),
...fixupConfigRules(
compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:jest/recommended",
"prettier",
),
),
{
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
page: true,
},

parser: tsParser,
ecmaVersion: 2020,
sourceType: "module",
},

settings: {
"import/resolver": {
typescript: true,
node: true,
},
},

rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-expressions": "error",
},
},
];
62 changes: 55 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"start-server": "http-server -p 4444 ./docs",
"format": "prettier --ignore-unknown --check \"**/*\"",
"format:fix": "prettier --ignore-unknown --write \"**/*\"",
"lint": "eslint --ignore-path .prettierignore .",
"lint:fix": "eslint --ignore-path .prettierignore --fix .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"fix": "npm run format:fix && npm run lint:fix",
"test": "npm run prepack && npm run format && npm run lint && npm run jest",
"jest": "cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS=--experimental-vm-modules jest",
Expand All @@ -86,6 +86,7 @@
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@eslint/compat": "^1.2.1",
"@swc/core": "^1.3.38",
"@types/clean-css": "^4.2.9",
"@types/fs-extra": "^11.0.3",
Expand All @@ -98,7 +99,8 @@
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^28.2.0",
"eslint-plugin-jest": "^28.8.3",
"globals": "^15.11.0",
"http-server": "14.1.1",
"husky": "^9.0.11",
"jest": "29.7.0",
Expand Down
2 changes: 0 additions & 2 deletions watify/pkg/watify.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {string} text
* @returns {Uint8Array}
Expand Down
2 changes: 0 additions & 2 deletions watify/pkg/watify_bg.wasm.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function watify(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
Expand Down

0 comments on commit e6d14e5

Please sign in to comment.