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

feat: update to eslint 9, switch to esm #1922

Merged
merged 6 commits into from
Apr 16, 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
23 changes: 0 additions & 23 deletions .editorconfig

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .eslintrc.js

This file was deleted.

9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Place your settings in this file to overwrite default and user settings.
{
"search.exclude": {
"dist": true,
"bin": true
"dist": true
},
"files.trimTrailingWhitespace": true,
"typescript.tsdk": "node_modules/typescript/lib",
"files.insertFinalNewline": true,
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.validate": ["javascript", "javascriptreact", "typescript"],
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"jest.autoRun": "off"
"eslint.experimental.useFlatConfig": true,
"jest.runMode": "on-demand",
"javascript.preferences.importModuleSpecifierEnding": "js"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/ts-json-schema-generator
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../dist/ts-json-schema-generator');
import("../dist/ts-json-schema-generator.js");
78 changes: 78 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import eslint from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

/** @type {import('@types/eslint').Linter.FlatConfig[]} */
export default tseslint.config(
{
ignores: ["dist"],
},
eslint.configs.recommended,
{
files: [
"ts-json-schema-generator.ts",
"index.ts",
"src/**/*.ts",
"factory/**/*.ts",
"bin/**",
"test/**/*.test.ts",
"test/utils.ts",
],
extends: tseslint.configs.recommendedTypeChecked,
languageOptions: {
sourceType: "module",
parserOptions: {
project: "tsconfig.eslint.json",
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-parameter-properties": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "none",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"no-alert": "error",
"prefer-const": "error",
"no-return-assign": "error",
"no-useless-call": "error",
"no-shadow": "error",
"no-useless-concat": "error",
"no-undef": "off",
"no-prototype-builtins": "off",
},
},
{
files: ["*.js"],
...tseslint.configs.disableTypeChecked,
},
{
files: ["test/**/*.test.ts"],
languageOptions: {
globals: {
...globals.jest,
},
},
},
eslintPluginPrettierRecommended
);
66 changes: 33 additions & 33 deletions factory/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { ChainTypeFormatter } from "../src/ChainTypeFormatter";
import { CircularReferenceTypeFormatter } from "../src/CircularReferenceTypeFormatter";
import { CompletedConfig } from "../src/Config";
import { MutableTypeFormatter } from "../src/MutableTypeFormatter";
import { TypeFormatter } from "../src/TypeFormatter";
import { AliasTypeFormatter } from "../src/TypeFormatter/AliasTypeFormatter";
import { AnnotatedTypeFormatter } from "../src/TypeFormatter/AnnotatedTypeFormatter";
import { AnyTypeFormatter } from "../src/TypeFormatter/AnyTypeFormatter";
import { ArrayTypeFormatter } from "../src/TypeFormatter/ArrayTypeFormatter";
import { BooleanTypeFormatter } from "../src/TypeFormatter/BooleanTypeFormatter";
import { ConstructorTypeFormatter } from "../src/TypeFormatter/ConstructorTypeFormatter";
import { DefinitionTypeFormatter } from "../src/TypeFormatter/DefinitionTypeFormatter";
import { EnumTypeFormatter } from "../src/TypeFormatter/EnumTypeFormatter";
import { FunctionTypeFormatter } from "../src/TypeFormatter/FunctionTypeFormatter";
import { HiddenTypeFormatter } from "../src/TypeFormatter/HiddenTypeFormatter";
import { IntersectionTypeFormatter } from "../src/TypeFormatter/IntersectionTypeFormatter";
import { LiteralTypeFormatter } from "../src/TypeFormatter/LiteralTypeFormatter";
import { LiteralUnionTypeFormatter } from "../src/TypeFormatter/LiteralUnionTypeFormatter";
import { NeverTypeFormatter } from "../src/TypeFormatter/NeverTypeFormatter";
import { NullTypeFormatter } from "../src/TypeFormatter/NullTypeFormatter";
import { NumberTypeFormatter } from "../src/TypeFormatter/NumberTypeFormatter";
import { ObjectTypeFormatter } from "../src/TypeFormatter/ObjectTypeFormatter";
import { OptionalTypeFormatter } from "../src/TypeFormatter/OptionalTypeFormatter";
import { PrimitiveUnionTypeFormatter } from "../src/TypeFormatter/PrimitiveUnionTypeFormatter";
import { ReferenceTypeFormatter } from "../src/TypeFormatter/ReferenceTypeFormatter";
import { RestTypeFormatter } from "../src/TypeFormatter/RestTypeFormatter";
import { StringTypeFormatter } from "../src/TypeFormatter/StringTypeFormatter";
import { SymbolTypeFormatter } from "../src/TypeFormatter/SymbolTypeFormatter";
import { TupleTypeFormatter } from "../src/TypeFormatter/TupleTypeFormatter";
import { UndefinedTypeFormatter } from "../src/TypeFormatter/UndefinedTypeFormatter";
import { UnionTypeFormatter } from "../src/TypeFormatter/UnionTypeFormatter";
import { UnknownTypeFormatter } from "../src/TypeFormatter/UnknownTypeFormatter";
import { VoidTypeFormatter } from "../src/TypeFormatter/VoidTypeFormatter";
import { ChainTypeFormatter } from "../src/ChainTypeFormatter.js";
import { CircularReferenceTypeFormatter } from "../src/CircularReferenceTypeFormatter.js";
import { CompletedConfig } from "../src/Config.js";
import { MutableTypeFormatter } from "../src/MutableTypeFormatter.js";
import { TypeFormatter } from "../src/TypeFormatter.js";
import { AliasTypeFormatter } from "../src/TypeFormatter/AliasTypeFormatter.js";
import { AnnotatedTypeFormatter } from "../src/TypeFormatter/AnnotatedTypeFormatter.js";
import { AnyTypeFormatter } from "../src/TypeFormatter/AnyTypeFormatter.js";
import { ArrayTypeFormatter } from "../src/TypeFormatter/ArrayTypeFormatter.js";
import { BooleanTypeFormatter } from "../src/TypeFormatter/BooleanTypeFormatter.js";
import { ConstructorTypeFormatter } from "../src/TypeFormatter/ConstructorTypeFormatter.js";
import { DefinitionTypeFormatter } from "../src/TypeFormatter/DefinitionTypeFormatter.js";
import { EnumTypeFormatter } from "../src/TypeFormatter/EnumTypeFormatter.js";
import { FunctionTypeFormatter } from "../src/TypeFormatter/FunctionTypeFormatter.js";
import { HiddenTypeFormatter } from "../src/TypeFormatter/HiddenTypeFormatter.js";
import { IntersectionTypeFormatter } from "../src/TypeFormatter/IntersectionTypeFormatter.js";
import { LiteralTypeFormatter } from "../src/TypeFormatter/LiteralTypeFormatter.js";
import { LiteralUnionTypeFormatter } from "../src/TypeFormatter/LiteralUnionTypeFormatter.js";
import { NeverTypeFormatter } from "../src/TypeFormatter/NeverTypeFormatter.js";
import { NullTypeFormatter } from "../src/TypeFormatter/NullTypeFormatter.js";
import { NumberTypeFormatter } from "../src/TypeFormatter/NumberTypeFormatter.js";
import { ObjectTypeFormatter } from "../src/TypeFormatter/ObjectTypeFormatter.js";
import { OptionalTypeFormatter } from "../src/TypeFormatter/OptionalTypeFormatter.js";
import { PrimitiveUnionTypeFormatter } from "../src/TypeFormatter/PrimitiveUnionTypeFormatter.js";
import { ReferenceTypeFormatter } from "../src/TypeFormatter/ReferenceTypeFormatter.js";
import { RestTypeFormatter } from "../src/TypeFormatter/RestTypeFormatter.js";
import { StringTypeFormatter } from "../src/TypeFormatter/StringTypeFormatter.js";
import { SymbolTypeFormatter } from "../src/TypeFormatter/SymbolTypeFormatter.js";
import { TupleTypeFormatter } from "../src/TypeFormatter/TupleTypeFormatter.js";
import { UndefinedTypeFormatter } from "../src/TypeFormatter/UndefinedTypeFormatter.js";
import { UnionTypeFormatter } from "../src/TypeFormatter/UnionTypeFormatter.js";
import { UnknownTypeFormatter } from "../src/TypeFormatter/UnknownTypeFormatter.js";
import { VoidTypeFormatter } from "../src/TypeFormatter/VoidTypeFormatter.js";

export type FormatterAugmentor = (
formatter: MutableTypeFormatter,
Expand Down
10 changes: 5 additions & 5 deletions factory/generator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Config, DEFAULT_CONFIG } from "../src/Config";
import { SchemaGenerator } from "../src/SchemaGenerator";
import { createFormatter } from "./formatter";
import { createParser } from "./parser";
import { createProgram } from "./program";
import { Config, DEFAULT_CONFIG } from "../src/Config.js";
import { SchemaGenerator } from "../src/SchemaGenerator.js";
import { createFormatter } from "./formatter.js";
import { createParser } from "./parser.js";
import { createProgram } from "./program.js";

export function createGenerator(config: Config): SchemaGenerator {
const completedConfig = { ...DEFAULT_CONFIG, ...config };
Expand Down
8 changes: 4 additions & 4 deletions factory/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./formatter";
export * from "./generator";
export * from "./parser";
export * from "./program";
export * from "./formatter.js";
export * from "./generator.js";
export * from "./parser.js";
export * from "./program.js";
Loading
Loading