From c3eb365762c4ba49eef09e61edae46c2c59d3712 Mon Sep 17 00:00:00 2001 From: Brendan Dash <61053131+Debbl@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:47:36 +0800 Subject: [PATCH] feat(ts): add tsconfig.json order (#243) --- packages/eslint-config-ts/index.js | 119 +++++++++++++++++++++++++++++ tsconfig.json | 2 +- 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-ts/index.js b/packages/eslint-config-ts/index.js index ae4112f22b..f5a4e3dbaa 100644 --- a/packages/eslint-config-ts/index.js +++ b/packages/eslint-config-ts/index.js @@ -60,6 +60,125 @@ module.exports = { '@typescript-eslint/unbound-method': 'off', 'jest/unbound-method': 'error', }, + }, { + files: ['tsconfig.json', 'tsconfig.*.json'], + parser: 'jsonc-eslint-parser', + rules: { + 'jsonc/sort-keys': [ + 'error', + { + pathPattern: '^$', + order: [ + 'extends', + 'compilerOptions', + 'references', + 'files', + 'include', + 'exclude', + ], + }, + { + pathPattern: '^compilerOptions$', + order: [ + /* Projects */ + 'incremental', + 'composite', + 'tsBuildInfoFile', + 'disableSourceOfProjectReferenceRedirect', + 'disableSolutionSearching', + 'disableReferencedProjectLoad', + /* Language and Environment */ + 'target', + 'lib', + 'jsx', + 'experimentalDecorators', + 'emitDecoratorMetadata', + 'jsxFactory', + 'jsxFragmentFactory', + 'jsxImportSource', + 'reactNamespace', + 'noLib', + 'useDefineForClassFields', + 'moduleDetection', + /* Modules */ + 'module', + 'rootDirs', + 'moduleResolution', + 'baseUrl', + 'paths', + 'typeRoots', + 'types', + 'allowUmdGlobalAccess', + 'moduleSuffixes', + 'allowImportingTsExtensions', + 'resolvePackageJsonExports', + 'resolvePackageJsonImports', + 'customConditions', + 'resolveJsonModule', + 'allowArbitraryExtensions', + 'noResolve', + /* JavaScript Support */ + 'allowJs', + 'checkJs', + 'maxNodeModuleJsDepth', + /* Emit */ + 'declaration', + 'declarationMap', + 'emitDeclarationOnly', + 'sourceMap', + 'inlineSourceMap', + 'outFile', + 'outDir', + 'removeComments', + 'noEmit', + 'importHelpers', + 'importsNotUsedAsValues', + 'downlevelIteration', + 'sourceRoot', + 'mapRoot', + 'inlineSources', + 'emitBOM', + 'newLine', + 'stripInternal', + 'noEmitHelpers', + 'noEmitOnError', + 'preserveConstEnums', + 'declarationDir', + 'preserveValueImports', + /* Interop Constraints */ + 'isolatedModules', + 'verbatimModuleSyntax', + 'allowSyntheticDefaultImports', + 'esModuleInterop', + 'preserveSymlinks', + 'forceConsistentCasingInFileNames', + /* Type Checking */ + 'strict', + 'noImplicitAny', + 'strictNullChecks', + 'strictFunctionTypes', + 'strictBindCallApply', + 'strictPropertyInitialization', + 'noImplicitThis', + 'useUnknownInCatchVariables', + 'alwaysStrict', + 'noUnusedLocals', + 'noUnusedParameters', + 'exactOptionalPropertyTypes', + 'noImplicitReturns', + 'noFallthroughCasesInSwitch', + 'noUncheckedIndexedAccess', + 'noImplicitOverride', + 'noPropertyAccessFromIndexSignature', + 'allowUnusedLabels', + 'allowUnreachableCode', + /* Completeness */ + 'skipDefaultLibCheck', + 'skipLibCheck', + ], + }, + ], + }, }], ), rules: { diff --git a/tsconfig.json b/tsconfig.json index de2a6ad93c..f1b6dacdce 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { - "baseUrl": ".", "target": "es2020", "module": "es2020", "moduleResolution": "Bundler", + "baseUrl": ".", "esModuleInterop": true }, "include": [