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

ci: Use a standard tsconfig.json base for all packages. #1681

Merged
merged 2 commits into from Sep 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 7 additions & 72 deletions integration-tests/tsconfig.json
@@ -1,74 +1,9 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["ES2019"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"src"
],
"exclude": [
]
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"build-integration-tests": "cd ./integration-tests && npm i",
"check-spelling": "npx cspell -c cspellrc.json",
"clean-build": "npm run clean && lerna run clean-build",
"clean": "rimraf **/.tsbuildinfo && lerna run clean && rimraf lcov.info",
"clean": "rimraf \"{*,*/*}/{.tsbuildinfo,temp,coverage}\" lcov.info && lerna run clean",
"coverage": "lerna run coverage --stream && npm run coverage-collect",
"coverage-collect": "globcat packages/*/coverage/lcov.info > lcov.info",
"install": "lerna bootstrap --ci",
Expand Down Expand Up @@ -60,6 +60,7 @@
},
"homepage": "https://streetsidesoftware.github.io/cspell/",
"devDependencies": {
"@tsconfig/node12": "^1.0.9",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.11",
"@typescript-eslint/eslint-plugin": "^4.7.0",
Expand Down
64 changes: 3 additions & 61 deletions packages/cspell-bundled-dicts/tsconfig.json
@@ -1,65 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": false, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"declaration": false,
"sourceMap": false
}
}
38 changes: 8 additions & 30 deletions packages/cspell-dynamic-loader/tsconfig.json
@@ -1,32 +1,10 @@
{
"compilerOptions": {
"target": "es2019",
"lib": [
"es2019",
"es2020.promise",
"es2020.bigint",
"es2020.string"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"alwaysStrict": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitThis": true,
"esModuleInterop": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*.ts",
"src/**/*.test.ts"
],
"exclude": [
"node_modules/**",
"dist/**"
]
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src/**/*.ts",
"src/**/*.test.ts"
]
}
34 changes: 8 additions & 26 deletions packages/cspell-glob/tsconfig.json
@@ -1,28 +1,10 @@
{
"compilerOptions": {
"target": "es2019",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"alwaysStrict": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*.ts",
"src/**/*.test.ts"
],
"exclude": [
"node_modules/**",
"dist/**",
"dictionaries/**",
"samples"
]
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src/**/*.ts",
"src/**/*.test.ts"
]
}
29 changes: 7 additions & 22 deletions packages/cspell-io/tsconfig.json
@@ -1,24 +1,9 @@
{
"compilerOptions": {
"target": "es2019",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"alwaysStrict": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"newLine": "LF",
"strict": true,
"strictFunctionTypes": false,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist"
},
"include": [
"src"
]
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}
10 changes: 8 additions & 2 deletions packages/cspell-lib/src/Settings/GlobalSettings.ts
@@ -1,6 +1,8 @@
import { CSpellSettings, CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
import ConfigStore from 'configstore';
import { logError } from '../util/logger';
import { isErrnoException } from '../util/errors';
import { format } from 'util';

const packageName = 'cspell';

Expand Down Expand Up @@ -34,7 +36,11 @@ export function getRawGlobalSettings(): GlobalSettingsWithSource {
};
}
} catch (error) {
if (!['ENOENT', 'EACCES', 'ENOTDIR', 'EISDIR'].includes(error.code)) {
if (
!isErrnoException(error) ||
!error.code ||
!['ENOENT', 'EACCES', 'ENOTDIR', 'EISDIR'].includes(error.code)
) {
logError(error);
}
}
Expand All @@ -53,7 +59,7 @@ export function writeRawGlobalSettings(settings: GlobalCSpellSettings): Error |
return undefined;
} catch (error) {
if (error instanceof Error) return error;
return new Error(error.toString());
return new Error(format(error));
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/cspell-lib/src/Settings/ImportError.ts
@@ -1,5 +1,9 @@
import { isError } from '../util/errors';

export class ImportError extends Error {
constructor(msg: string, readonly cause?: Error) {
readonly cause?: Error;
constructor(msg: string, cause?: Error | unknown) {
super(msg);
this.cause = isError(cause) ? cause : undefined;
}
}
4 changes: 3 additions & 1 deletion packages/cspell-lib/src/spellCheckFile.ts
Expand Up @@ -15,6 +15,7 @@ import * as path from 'path';
import { combineTextAndLanguageSettings } from './Settings/TextDocumentSettings';
import { GlobMatcher } from 'cspell-glob';
import { memorizer } from './util/Memorizer';
import { isError } from './util/errors';

const getLanguagesForExt = memorizer(_getLanguagesForExt);

Expand Down Expand Up @@ -106,14 +107,15 @@ export async function spellCheckDocument(
try {
return spellCheckFullDocument(await resolveDocument(document), options, settings);
} catch (e) {
const errors = isError(e) ? [e] : [];
return {
document,
options,
settingsUsed: settings,
localConfigFilepath: undefined,
issues: [],
checked: false,
errors: [e],
errors,
};
}
}
Expand Down