chore: Replace tslint with eslint (#2555)

This commit is contained in:
inferrinizzard
2024-04-29 20:23:42 -07:00
committed by GitHub
parent bc0608f14e
commit e50d5a05fb
17 changed files with 9855 additions and 997 deletions

8
.eslintignore Normal file
View File

@ -0,0 +1,8 @@
dist
node_modules
packages/*/dist
packages/*/node_modules
test/runs
test/input
license

104
.eslintrc.json Normal file
View File

@ -0,0 +1,104 @@
{
"overrides": [
{
"extends": ["canonical/json"],
"files": "*.json"
},
{
"extends": [
"eslint:recommended",
"canonical/typescript",
"canonical/typescript-type-checking",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"plugins": ["canonical"],
"parserOptions": {
"tsconfigRootDir": "./",
"project": ["./tsconfig.json", "./packages/*/tsconfig.json"]
},
"settings": {
"import/resolver": {
"typescript": true,
"node": true
}
},
"rules": {
"comma-dangle": "off",
"no-extra-parens": "off",
"no-case-declarations": "warn",
"no-duplicate-imports": "error",
"canonical/prefer-inline-type-import": "error",
"typescript-sort-keys/string-enum": "off",
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true
}
],
"import/first": "error",
"import/order": [
"error",
{
"newlines-between": "always",
"groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
"pathGroups": [
{
"pattern": "@/**",
"group": "internal",
"position": "before"
}
],
"alphabetize": {
"order": "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
"caseInsensitive": true /* ignore case. Options: [true, false] */
}
}
],
"import/no-absolute-path": "error",
"import/no-cycle": "error",
"import/no-duplicates": "error",
"import/no-extraneous-dependencies": "error",
"import/no-named-as-default": "off",
"import/no-useless-path-segments": "error",
"@typescript-eslint/class-literal-property-style": "off",
"@typescript-eslint/comma-dangle": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-imports": ["error", { "prefer": "type-imports" }],
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/indent": "off",
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true }],
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-loop-func": "warn",
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
"@typescript-eslint/no-unused-vars": ["error", { "vars": "local", "args": "none" }],
"@typescript-eslint/no-use-before-define": "warn",
"@typescript-eslint/no-useless-empty-export": "error",
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/prefer-reduce-type-parameter": "off",
"@typescript-eslint/require-array-sort-compare": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/unbound-method": "warn",
"@typescript-eslint/unified-signatures": "error"
},
"overrides": [
{
"files": "*.d.ts",
"rules": {
"no-var": "off"
}
}
],
"files": "*.ts"
}
],
"root": true
}

1
.gitignore vendored
View File

@ -36,4 +36,3 @@ test/fixtures/objective-c/quicktype
/.bsp
.metals
.scala-build
.vscode

76
.vscode/launch.json vendored
View File

@ -1,40 +1,40 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "quicktype",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"runtimeArgs": ["--nolazy"],
"args": [
"--project",
"src/cli/tsconfig.json",
"src/cli/index.ts",
"--lang",
"dart",
"--src-lang",
"json",
"./test/inputs/json/priority/blns-object.json"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
},
{
"name": "test",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"args": ["--project", "test/tsconfig.json", "test/test.ts"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"env": {
"CPUs": "1",
"FIXTURE": "golang"
}
}
]
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "quicktype",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"runtimeArgs": ["--nolazy"],
"args": [
"--project",
"src/cli/tsconfig.json",
"src/cli/index.ts",
"--lang",
"dart",
"--src-lang",
"json",
"./test/inputs/json/priority/blns-object.json"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
},
{
"name": "test",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"args": ["--project", "test/tsconfig.json", "test/test.ts"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"env": {
"CPUs": "1",
"FIXTURE": "golang"
}
}
]
}

62
.vscode/settings.json vendored
View File

@ -1,25 +1,39 @@
{
// Place your settings in this file to overwrite default and user settings.
"editor.formatOnSave": true,
"spellright.ignoreFiles": [
"**/.gitignore",
"**/.spellignore"
],
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/tmp": true,
"output": true,
"**/obj": true,
"**/bin": true,
"test/inputs": true,
"test/runs": true,
"app/build": true,
"elm-stuff": true,
"dist": true
},
"explorer.excludeGitIgnore": false,
"spellright.documentTypes": [],
"java.configuration.updateBuildConfiguration": "automatic"
}
// Place your settings in this file to overwrite default and user settings.
"editor.formatOnSave": true,
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/tmp": true,
"output": true,
"**/obj": true,
"**/bin": true,
"test/inputs": true,
"test/runs": true,
"app/build": true,
"elm-stuff": true,
"dist": true
},
"explorer.excludeGitIgnore": false,
"java.configuration.updateBuildConfiguration": "automatic",
"files.associations": {
"*.schema": "jsonc"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.wordWrap": "on",
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.detectIndentation": false
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.wordWrap": "on",
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.detectIndentation": false
}
}

15
.vscode/tasks.json vendored
View File

@ -1,15 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "tslint",
"group": "build",
"problemMatcher": [
"$tslint5"
]
}
]
}

10458
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,9 @@
"test": "script/test",
"start": "script/watch",
"clean": "rm -rf dist node_modules *~ packages/*/{dist,node_modules,out}",
"debug": "node --inspect-brk --max-old-space-size=4096 ./dist/index.js"
"debug": "node --inspect-brk --max-old-space-size=4096 ./dist/index.js",
"lint": "eslint src/** packages/*/src/**",
"lint:fix": "eslint --fix src/** packages/*/src/**"
},
"workspaces": [
"./packages/quicktype-core",
@ -50,16 +52,25 @@
"@types/shelljs": "^0.8.15",
"@types/stream-json": "^1.7.3",
"@types/urijs": "^1.19.25",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"ajv": "^5.5.2",
"deep-equal": "^2.2.3",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-canonical": "^41.1.7",
"eslint-config-prettier": "^6.10.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-canonical": "^3.4.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"exit": "^0.1.2",
"prettier": "^3.2.5",
"promise-timeout": "^1.3.0",
"semver": "^7.5.4",
"shelljs": "^0.8.5",
"ts-node": "^10.9.2",
"tslint": "^6.1.3",
"watch": "^1.0.2"
},
"files": [

View File

@ -8,8 +8,7 @@
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"clean": "rm -rf dist node_modules *~",
"build": "tsc",
"tslint": "tslint --project ."
"build": "tsc"
},
"dependencies": {
"@glideapps/ts-necessities": "2.2.3",
@ -35,7 +34,6 @@
"@types/pluralize": "0.0.30",
"@types/readable-stream": "4.0.10",
"@types/unicode-properties": "^1.3.0",
"tslint": "^6.1.3",
"typescript": "4.9.5"
},
"files": [

View File

@ -290,7 +290,6 @@ export function matchType<U>(
return panic(`Unsupported type ${t.kind} in non-exhaustive match`);
}
/* tslint:disable:strict-boolean-expressions */
return matchTypeExhaustive(
type,
typeNotSupported,
@ -308,7 +307,6 @@ export function matchType<U>(
unionType,
transformedStringType || typeNotSupported
);
/* tslint:enable */
}
export function matchCompoundType(

View File

@ -60,7 +60,6 @@ export class JSONInput<T> implements Input<JSONSourceData<T>> {
private readonly _topLevels: Map<string, JSONTopLevel> = new Map();
/* tslint:disable:no-unused-variable */
constructor(private readonly _compressedJSON: CompressedJSON<T>) {}
private addSample(topLevelName: string, sample: Value): void {

View File

@ -8,8 +8,7 @@
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"clean": "rm -rf dist node_modules *~",
"build": "tsc",
"tslint": "tslint --project ."
"build": "tsc"
},
"dependencies": {
"quicktype-core": "file:../quicktype-core",
@ -19,8 +18,7 @@
"devDependencies": {
"@types/node": "18.19.31",
"@types/graphql": "^0.11.7",
"typescript": "4.9.5",
"tslint": "^6.1.3"
"typescript": "4.9.5"
},
"files": [
"dist"

View File

@ -1,4 +1,4 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.

View File

@ -1,5 +1,3 @@
/* tslint:disable:strict-boolean-expressions */
import {
DocumentNode,
SelectionSetNode,

View File

@ -8,8 +8,7 @@
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"clean": "rm -rf dist node_modules *~",
"build": "tsc",
"tslint": "tslint --project ."
"build": "tsc"
},
"dependencies": {
"quicktype-core": "file:../quicktype-core",
@ -17,8 +16,7 @@
"@mark.probst/typescript-json-schema": "0.55.0"
},
"devDependencies": {
"@types/node": "18.19.31",
"tslint": "^6.1.3"
"@types/node": "18.19.31"
},
"files": [
"dist"

View File

@ -271,7 +271,6 @@ function inferCLIOptions(opts: Partial<CLIOptions>, targetLanguage: TargetLangua
language = maybeLanguage;
}
/* tslint:disable:strict-boolean-expressions */
const options: CLIOptions = {
src: opts.src || [],
srcUrls: opts.srcUrls,
@ -295,7 +294,6 @@ function inferCLIOptions(opts: Partial<CLIOptions>, targetLanguage: TargetLangua
debug: opts.debug,
telemetry: opts.telemetry
};
/* tslint:enable */
for (const flagName of inferenceFlagNames) {
const cliName = negatedInferenceFlagName(flagName);
options[cliName] = !!opts[cliName];

View File

@ -1,88 +0,0 @@
{
"rules": {
"await-promise": true,
"promise-function-async": true,
"no-floating-promises": true,
"align": [true, "parameters", "statements"],
"ban": false,
"class-name": true,
"comment-format": [true, "check-space"],
"curly": false,
"eofline": false,
"forin": true,
"indent": [true, "spaces", 4],
"interface-name": [true, "never-prefix"],
"jsdoc-format": true,
"jsx-no-lambda": false,
"jsx-no-multiline-js": false,
"label-position": true,
"max-line-length": false,
"member-ordering": [true, "static-before-instance"],
"no-any": false,
"no-arg": true,
"no-bitwise": false,
"no-console": [
false,
"log",
"error",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": [true, "allow-empty-catch"],
"no-eval": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unsafe-any": false,
"no-unused-expression": true,
"no-use-before-declare": false,
"no-unused-variable": true,
"no-var-keyword": true,
"no-void-expression": false,
"strict-boolean-expressions": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-open-brace",
"check-whitespace"
],
"quotemark": [true, "double", "avoid-escape"],
"radix": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],
"switch-default": true,
"trailing-comma": false,
"triple-equals": [true, "allow-null-check"],
"typedef": [true, "parameter", "property-declaration"],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore",
"allow-pascal-case"
],
"whitespace": [false]
}
}