Skip to content

Commit

Permalink
Update eslint to version 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jul 20, 2024
1 parent d575a5c commit ee84b3d
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 137 deletions.
7 changes: 7 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
exclude_paths:
- "eslint.config.mjs"
include_paths:
- "src/**/*.ts"
- "test/**/*.ts"
- "example/**/*"
7 changes: 0 additions & 7 deletions .mocharc.json

This file was deleted.

254 changes: 254 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
import _import from "eslint-plugin-import";
import jsdoc from "eslint-plugin-jsdoc";
import node from "eslint-plugin-node";
import unicorn from "eslint-plugin-unicorn";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import { fixupPluginRules } from "@eslint/compat";
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
});

export default [...compat.extends("prettier"), {
plugins: {
import: fixupPluginRules(_import),
jsdoc,
node,
unicorn,
"@typescript-eslint": typescriptEslint
},

files: ["**/*.ts"],

ignores: ["**/*.d.ts", "example/**"],

languageOptions: {
globals: {
...globals.browser,
...globals.node
},

parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
project: "./tsconfig.json"
}
},

settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},

"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: ["lib/tsconfig.json", "test/tsconfig.json", "doc-gen/tsconfig.json"]
}
}
},

rules: {
"@typescript-eslint/adjacent-overload-signatures": "error",

"@typescript-eslint/array-type": ["error", {
default: "array"
}],

"@typescript-eslint/ban-types": ["error", {
types: {
Object: {
message: "Avoid using the `Object` type. Did you mean `object`?"
},

Function: {
message: "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
},

Boolean: {
message: "Avoid using the `Boolean` type. Did you mean `boolean`?"
},

Number: {
message: "Avoid using the `Number` type. Did you mean `number`?"
},

String: {
message: "Avoid using the `String` type. Did you mean `string`?"
},

Symbol: {
message: "Avoid using the `Symbol` type. Did you mean `symbol`?"
},

Buffer: {
message: "Do not use Node.js specific Buffer type, use Uint8Array"
}
}
}],

"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "error",

"@typescript-eslint/indent": ["error", 2, {
ObjectExpression: "first",

FunctionDeclaration: {
parameters: "first"
},

FunctionExpression: {
parameters: "first"
},

SwitchCase: 1
}],

"@typescript-eslint/naming-convention": "off",

"@typescript-eslint/no-empty-function": ["error", {
allow: ["constructors"]
}],

"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",

"@typescript-eslint/no-shadow": ["error", {
hoist: "all"
}],

"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": ["error", "always"],

"@typescript-eslint/triple-slash-reference": ["error", {
path: "always",
types: "prefer-import",
lib: "always"
}],

"@typescript-eslint/unified-signatures": "error",
"arrow-parens": ["error", "as-needed"],
"comma-dangle": "error",
complexity: "off",
"constructor-super": "error",
curly: "off",
"default-case": "off",
"dot-notation": "error",
eqeqeq: ["error", "smart"],
"guard-for-in": "off",

"id-denylist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],

"id-match": "error",

"import/no-extraneous-dependencies": ["error", {
devDependencies: true
}],

"import/no-internal-modules": "off",
"import/order": "off",

"import/no-unresolved": ["error", {
caseSensitiveStrict: true
}],

indent: "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "error",
"jsdoc/newline-after-description": "off",
"max-classes-per-file": "off",

"max-len": ["error", {
code: 200
}],

"new-parens": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "error",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-empty-function": "off",
"no-eval": "error",
"no-extra-bind": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-restricted-globals": ["error", "Buffer"],
"no-restricted-imports": ["error", {
paths: ["node:buffer"]
}],
"no-sequences": "error",
"no-shadow": "off",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-use-before-define": "off",
"no-var": "error",
"node/file-extension-in-import": ["error", "always"],
"node/no-extraneous-import": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": ["error", "as-needed"],
quotes: "off",
radix: "error",
semi: "error",
"space-in-parens": ["error", "never"],

"spaced-comment": ["error", "always", {
markers: ["/"]
}],

"unicorn/prefer-ternary": "error",
"use-isnan": "error",
"valid-typeof": "off"
}
}];
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"compile-test": "tsc -p test",
"compile-doc": "tsc -p doc-gen",
"compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
"eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
"eslint": "eslint lib test doc-gen",
"lint-md": "remark -u preset-lint-markdown-style-guide .",
"lint": "npm run lint-md && npm run eslint",
"test": "mocha",
Expand All @@ -105,25 +105,29 @@
"uint8array-extras": "^1.4.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@types/chai": "^4.3.16",
"@types/chai-as-promised": "^7.1.8",
"@types/debug": "^4.1.12",
"@types/file-type": "^10.9.1",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.11",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"c8": "^10.1.2",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"del-cli": "^5.1.0",
"eslint": "^8.57.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.7.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^54.0.0",
"globals": "^15.8.0",
"mime": "^4.0.4",
"mocha": "^10.6.0",
"npm-run-all": "^4.1.5",
Expand Down
Loading

0 comments on commit ee84b3d

Please sign in to comment.