Skip to content

Commit

Permalink
chore: update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Nov 30, 2024
1 parent 6f375e9 commit 607a470
Show file tree
Hide file tree
Showing 66 changed files with 706 additions and 546 deletions.
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

32 changes: 0 additions & 32 deletions .eslintrc

This file was deleted.

72 changes: 72 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import pluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
import vitest from "eslint-plugin-vitest";
import pluginWorkspaces from "eslint-plugin-workspaces";
import globals from "globals";
import {join} from "node:path";

export default [
{
ignores: ["**/coverage", "**/lib", "**/dist", "processes.config.js", "**/snapshots", "**/templates", "**/docs/**", "**/docs-references/**"]
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: typescriptParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: join(import.meta.dirname, "tsconfig.eslint.json")
},
globals: {
...globals.node
}
},
plugins: {
"@typescript-eslint": typescriptEslint
},
rules: {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-non-null-assertion": 0
}
},
{
files: ["**/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], // or any other pattern
ignores: ["docs/**", "docs-references/**"],
plugins: {
vitest
},
rules: {
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
"vitest/consistent-test-it": ["error", {fn: "it", withinDescribe: "it"}],
"vitest/no-alias-methods": "error",
"vitest/expect-expect": "off"
}
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
languageOptions: {
parserOptions: {}
},
plugins: {
"simple-import-sort": pluginSimpleImportSort,
workspaces: pluginWorkspaces
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"workspaces/no-absolute-imports": "error"
}
},
pluginPrettierRecommended
];
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,25 @@
"@tsed/monorepo-utils": "2.3.10",
"@tsed/ts-doc": "^4.1.0",
"@types/node": "20.11.26",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@typescript-eslint/eslint-plugin": "8.16.0",
"@typescript-eslint/parser": "8.16.0",
"@vitest/coverage-v8": "2.1.6",
"barrelsby": "2.8.1",
"concurrently": "^8.2.2",
"coveralls": "^3.1.1",
"cross-env": "7.0.3",
"entities": "4.5.0",
"eslint": "^8.57.0",
"eslint": "9.12.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "27.9.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-vitest": "0.5.4",
"eslint-plugin-workspaces": "0.10.1",
"gflow": "^5.1.4",
"husky": "^9.0.11",
"is-ci": "^3.0.1",
"lint-staged": "^15.2.2",
"prettier": "3.2.5",
"prettier": "3.4.1",
"semantic-release": "^23.0.2",
"semantic-release-slack-bot": "^4.0.2",
"ts-node": "^10.9.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"peerDependencies": {
"@tsed/logger": "6.7.8"
}
}
}
3 changes: 2 additions & 1 deletion packages/connect/src/ConnectAppender.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {vi} from "vitest";
import {Logger} from "@tsed/logger";
import {vi} from "vitest";

import {ConnectAppender} from "./ConnectAppender.js";

describe("ConnectAppender", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
"peerDependencies": {
"@tsed/logger": "6.7.8"
}
}
}
1 change: 1 addition & 0 deletions packages/file/src/FileAppender.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {levels, LogEvent} from "@tsed/logger";

import {FileAppender} from "./index.js";

describe("FileAppender", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/file/src/FileAppender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Appender, BaseAppender, LogEvent} from "@tsed/logger";
import {normalize} from "path";
import * as Os from "os";
import {normalize} from "path";
// @ts-ignore
import streams from "streamroller";

Expand Down
2 changes: 1 addition & 1 deletion packages/insight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"peerDependencies": {
"@tsed/logger": "6.7.8"
}
}
}
2 changes: 1 addition & 1 deletion packages/insight/src/InsightAppender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$log, Appender, LogEvent, BaseAppender} from "@tsed/logger";
import {$log, Appender, BaseAppender, LogEvent} from "@tsed/logger";
import Insight from "r7insight_node";

@Appender({name: "insight"})
Expand Down
2 changes: 1 addition & 1 deletion packages/logentries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"peerDependencies": {
"@tsed/logger": "6.7.8"
}
}
}
2 changes: 1 addition & 1 deletion packages/logentries/src/LogEntriesAppender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$log, Appender, LogEvent, BaseAppender} from "@tsed/logger";
import {$log, Appender, BaseAppender, LogEvent} from "@tsed/logger";
// @ts-ignore
import LogEntries from "le_node";

Expand Down
5 changes: 2 additions & 3 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@
"typescript": "5.7.2",
"vite": "5.4.11",
"vitest": "^2.1.6"
},
"peerDependencies": {}
}
}
}
2 changes: 1 addition & 1 deletion packages/logger/src/browser/exports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Logger, PatternLayout} from "../common/index.js";
import {StringUtils} from "../common/layouts/utils/StringUtils.js";
import {LayoutReplacer} from "./layouts/LayoutReplacer.js";
import {format} from "./utils/format.js";
import {StringUtils} from "../common/layouts/utils/StringUtils.js";

export * from "../common/index.js";
export const $log: Logger = new Logger("default");
Expand Down
5 changes: 3 additions & 2 deletions packages/logger/src/browser/layouts/LayoutReplacer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// @ts-ignore
import * as dateFormat from "date-format";

import {LogEvent} from "../../common/core/LogEvent.js";
import {LOG_COLORS} from "../../common/layouts/constants/logColors.js";
import {colorizeEnd, colorizeStart} from "../../common/layouts/utils/colorizeUtils.js";
import {IReplacers} from "../../common/layouts/interfaces/Replacers.js";
import {TokensHandlers} from "../../common/layouts/interfaces/BasicLayoutConfiguration.js";
import {IReplacers} from "../../common/layouts/interfaces/Replacers.js";
import {colorizeEnd, colorizeStart} from "../../common/layouts/utils/colorizeUtils.js";
import {format} from "../utils/format.js";

export class LayoutReplacer {
Expand Down
10 changes: 6 additions & 4 deletions packages/logger/src/common/appenders/class/BaseAppender.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import "../../layouts/components/ColoredLayout.js";
import "../../layouts/components/DummyLayout.js";

import {vi} from "vitest";

import {LogEvent} from "../../core/LogEvent.js";
import {levels} from "../../core/LogLevel.js";
import {BaseAppender} from "./BaseAppender.js";
import {LogEvent} from "../../core/LogEvent.js";
import "../../layouts/components/ColoredLayout.js";
import "../../layouts/components/DummyLayout.js";

const buildStub = vi.fn();

Expand All @@ -25,7 +27,7 @@ describe("BaseAppender", () => {
testAppender.build();
testAppender.write(logEvent);

expect(buildStub).toBeCalledTimes(1);
expect(buildStub).toHaveBeenCalledTimes(1);
expect(testAppender.config).toEqual({type: "console", options: {}});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import "../../layouts/components/ColoredLayout";

import {format} from "node:util";

import {vi} from "vitest";
import {ConsoleAppender} from "./ConsoleAppender.js";

import {LogEvent} from "../../core/LogEvent.js";
import {levels} from "../../core/LogLevel.js";
import "../../layouts/components/ColoredLayout";
import {StringUtils} from "../../layouts/utils/StringUtils.js";
import {ConsoleAppender} from "./ConsoleAppender.js";

StringUtils.format = format;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LogEvent} from "../../core/LogEvent.js";
import {Appender} from "../decorators/appender.js";
import {BaseAppender} from "../class/BaseAppender.js";
import {Appender} from "../decorators/appender.js";

/**
* ## Console Appender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AppendersRegistry} from "../registries/AppendersRegistry.js";
import {AppenderOptions} from "../class/BaseAppender.js";
import {AppendersRegistry} from "../registries/AppendersRegistry.js";

export function Appender(options: AppenderOptions) {
return (target: any) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/common/core/LogEvent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LogContext} from "./LogContext.js";
import {LogEvent} from "./LogEvent.js";
import {levels} from "./LogLevel.js";
import {LogContext} from "./LogContext.js";

describe("LogEvent", () => {
it("should create a new logevent (data)", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/common/core/LogEvent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LogLevel} from "./LogLevel.js";
import {LogContext} from "./LogContext.js";
import {LogLevel} from "./LogLevel.js";

export class LogEvent {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/src/common/core/LogLevel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ describe("LogLevel", () => {
expect(LogLevel.getLevel(levels().ALL)).toEqual(levels().ALL);
});

it("should return level (1)", () => {
it("should return level (2)", () => {
expect(LogLevel.getLevel("all")).toEqual(levels().ALL);
});

it("should return level (2)", () => {
it("should return level (3)", () => {
expect(LogLevel.getLevel({toString: () => "all"})).toEqual(levels().ALL);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/common/layouts/class/Layouts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LayoutsRegistry} from "../registries/LayoutsRegistry.js";
import {BasicLayoutConfiguration} from "../interfaces/BasicLayoutConfiguration.js";
import {LayoutsRegistry} from "../registries/LayoutsRegistry.js";
import {BaseLayout} from "./BaseLayout.js";

export class Layouts {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {format} from "node:util";

import {LogEvent} from "../../core/LogEvent.js";
import {levels} from "../../core/LogLevel.js";
import {BasicLayout} from "./BasicLayout.js";
import {StringUtils} from "../utils/StringUtils.js";
import {format} from "node:util";
import {BasicLayout} from "./BasicLayout.js";

StringUtils.format = format;

Expand Down
4 changes: 2 additions & 2 deletions packages/logger/src/common/layouts/components/BasicLayout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {timestampLevelAndCategory} from "../utils/timestampLevelAndCategory.js";
import {BaseLayout} from "../class/BaseLayout.js";
import {LogEvent} from "../../core/LogEvent.js";
import {BaseLayout} from "../class/BaseLayout.js";
import {Layout} from "../decorators/layout.js";
import {StringUtils} from "../utils/StringUtils.js";
import {timestampLevelAndCategory} from "../utils/timestampLevelAndCategory.js";

@Layout({name: "basic"})
export class BasicLayout extends BaseLayout {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {format} from "node:util";

import {LogEvent} from "../../core/LogEvent.js";
import {levels} from "../../core/LogLevel.js";
import {ColoredLayout} from "./ColoredLayout.js";
import {StringUtils} from "../utils/StringUtils.js";
import {format} from "node:util";
import {ColoredLayout} from "./ColoredLayout.js";

StringUtils.format = format;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {LogEvent} from "../../core/LogEvent.js";
import {timestampLevelAndCategory} from "../utils/timestampLevelAndCategory.js";
import {BaseLayout} from "../class/BaseLayout.js";
import {LOG_COLORS} from "../constants/logColors.js";
import {Layout} from "../decorators/layout.js";
import {BaseLayout} from "../class/BaseLayout.js";
import {StringUtils} from "../utils/StringUtils.js";
import {timestampLevelAndCategory} from "../utils/timestampLevelAndCategory.js";

@Layout({name: "colored"})
export class ColoredLayout extends BaseLayout {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BaseLayout} from "../class/BaseLayout.js";
import {LogEvent} from "../../core/LogEvent.js";
import {BaseLayout} from "../class/BaseLayout.js";
import {Layout} from "../decorators/layout.js";

@Layout({name: "dummy"})
Expand Down
Loading

0 comments on commit 607a470

Please sign in to comment.