diff --git a/.eslintignore b/.eslintignore index 6ab0c65328..49260b81bf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,5 +2,7 @@ dist/ node_modules/ e2e/__cases__/ e2e/__workdir_synlink__/ +e2e/__external-repos__/ coverage/ docs/ +*.config.js diff --git a/.eslintrc.js b/.eslintrc.js index e00b96a15a..fc1f6b69de 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,20 @@ module.exports = { env: { node: true, + es6: true, + 'jest/globals': true, }, - extends: 'eslint:recommended', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier + 'plugin:jest/recommended', + 'plugin:prettier/recommended' + ], + parser: '@typescript-eslint/parser', parserOptions: { + project: 'tsconfig.json', ecmaVersion: 2020, sourceType: 'module', impliedStrict: true, @@ -11,21 +22,218 @@ module.exports = { jsx: true, }, }, + plugins: ['@typescript-eslint', 'jest', 'jsdoc'], rules: { - 'no-console': ['error', { allow: ['warn', 'error', 'log'] }], - indent: ['error', 2], - 'linebreak-style': ['error', 'unix'], - quotes: ['error', 'single'], - semi: ['error', 'never'], - 'comma-dangle': [ + 'prettier/prettier': 'error', + 'no-unused-vars': 'off', // let typescript-eslint handle this + 'no-console': 'error', + 'linebreak-style': 'off', + 'comma-dangle': 'off', + 'constructor-super': 'error', + 'for-direction': ['error'], + 'getter-return': 'warn', + 'no-async-promise-executor': ['error'], + 'no-case-declarations': ['error'], + 'no-class-assign': ['error'], + 'no-compare-neg-zero': ['error'], + 'no-cond-assign': 'error', + 'no-const-assign': ['error'], + 'no-constant-condition': ['warn'], + 'no-control-regex': ['warn'], + 'no-debugger': 'error', + 'no-delete-var': ['error'], + 'no-dupe-args': ['error'], + 'no-dupe-class-members': 'warn', + 'no-dupe-keys': ['error'], + 'no-duplicate-case': ['error'], + 'no-empty': [ 'error', { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'always-multiline', - functions: 'never', + allowEmptyCatch: true, + }, + ], + 'no-empty-character-class': ['error'], + 'no-empty-pattern': ['error'], + 'no-ex-assign': ['error'], + 'no-extra-boolean-cast': ['error'], + 'no-extra-semi': 'off', + 'no-fallthrough': 'off', + 'no-func-assign': ['error'], + 'no-global-assign': ['error'], + 'no-inner-declarations': ['error'], + 'no-invalid-regexp': ['error'], + 'no-irregular-whitespace': 'off', + 'no-misleading-character-class': ['error'], + 'no-mixed-spaces-and-tabs': ['error'], + 'no-new-symbol': ['error'], + 'no-obj-calls': ['error'], + 'no-octal': ['error'], + 'no-prototype-builtins': ['error'], + 'no-redeclare': 'warn', + 'no-regex-spaces': ['error'], + 'no-self-assign': ['error'], + 'no-shadow-restricted-names': ['error'], + 'no-sparse-arrays': ['error'], + 'no-this-before-super': ['error'], + 'no-undef': ['error'], + 'no-unexpected-multiline': ['error'], + 'no-unreachable': ['error'], + 'no-unsafe-finally': 'error', + 'no-unsafe-negation': ['error'], + 'no-unused-labels': 'error', + 'no-useless-catch': ['error'], + 'no-useless-escape': 'warn', + 'no-with': ['error'], + 'require-yield': ['error'], + 'use-isnan': 'error', + 'valid-typeof': 'off', + '@typescript-eslint/no-unused-vars': ["error", { "argsIgnorePattern": "^_" }], + '@typescript-eslint/adjacent-overload-signatures': 'error', + '@typescript-eslint/array-type': [ + 'warn', + { + default: 'array', + }, + ], + '@typescript-eslint/ban-types': [ + 'error', + { + types: { + Object: { + message: 'Avoid using the `Object` type. Did you mean `object`?', + }, + Function: { + message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.', + }, + Boolean: { + message: 'Avoid using the `Boolean` type. Did you mean `boolean`?', + }, + Number: { + message: 'Avoid using the `Number` type. Did you mean `number`?', + }, + String: { + message: 'Avoid using the `String` type. Did you mean `string`?', + }, + Symbol: { + message: 'Avoid using the `Symbol` type. Did you mean `symbol`?', + }, + }, + }, + ], + '@typescript-eslint/class-name-casing': 'error', + '@typescript-eslint/prefer-regexp-exec': 'warn', + '@typescript-eslint/prefer-string-starts-ends-with': 'warn', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/prefer-includes': 'warn', + '@typescript-eslint/consistent-type-assertions': 'error', + '@typescript-eslint/consistent-type-definitions': 'error', + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + accessibility: 'no-public', + }, + ], + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/member-delimiter-style': [ + 'error', + { + multiline: { + delimiter: 'none', + requireLast: true, + }, + singleline: { + delimiter: 'semi', + requireLast: false, + }, + }, + ], + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/no-empty-function': ['error', { 'allow': ['arrowFunctions']}], + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-for-in-array': 'error', + '@typescript-eslint/no-inferrable-types': 'error', + '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/no-namespace': 'warn', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-parameter-properties': 'off', + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/prefer-for-of': 'off', + '@typescript-eslint/prefer-function-type': 'error', + '@typescript-eslint/prefer-namespace-keyword': 'error', + '@typescript-eslint/prefer-readonly': 'error', + '@typescript-eslint/triple-slash-reference': [ + 'error', + { + path: 'always', + types: 'prefer-import', + lib: 'always', + }, + ], + '@typescript-eslint/type-annotation-spacing': 'off', + '@typescript-eslint/unified-signatures': 'error', + '@typescript-eslint/no-unnecessary-type-assertion': 'warn', + 'arrow-body-style': 'warn', + 'arrow-parens': ['off', 'always'], + 'brace-style': ['off', 'off'], + camelcase: 'warn', + 'class-methods-use-this': 'warn', + complexity: 'off', + curly: ['warn', 'multi-line'], + 'default-case': 'error', + 'dot-notation': 'error', + 'eol-last': 'off', + eqeqeq: ['error', 'smart'], + 'guard-for-in': 'error', + 'id-match': 'error', + 'jsdoc/check-alignment': 'error', + 'jsdoc/check-indentation': 'error', + 'jsdoc/newline-after-description': 'warn', + 'max-classes-per-file': 'off', + 'max-len': 'off', + 'new-parens': 'off', + 'newline-per-chained-call': 'off', + 'no-bitwise': 'off', + 'no-caller': 'error', + 'no-duplicate-imports': 'error', + 'no-eval': 'error', + 'no-invalid-this': 'off', + 'no-multiple-empty-lines': 'off', + 'no-new-wrappers': 'error', + 'no-return-await': 'error', + 'no-shadow': [ + 'off', + { + hoist: 'all', + }, + ], + 'no-template-curly-in-string': 'error', + 'no-throw-literal': 'error', + 'no-trailing-spaces': 'off', + 'no-undef-init': 'error', + 'no-underscore-dangle': 'off', + 'no-unused-expressions': 'error', + 'no-var': 'error', + 'object-shorthand': 'error', + 'one-var': ['error', 'never'], + 'prefer-const': 'warn', + 'prefer-object-spread': 'error', + 'prefer-template': 'error', + 'quote-props': 'off', + radix: 'error', + 'space-before-function-paren': 'off', + 'space-in-parens': ['off', 'never'], + 'spaced-comment': [ + 'warn', + 'always', + { + markers: ['/'], }, ], }, + settings: {}, } diff --git a/.npmignore b/.npmignore index cf77ec0223..59d84cea3e 100644 --- a/.npmignore +++ b/.npmignore @@ -66,7 +66,6 @@ tsconfig.json .prettierrc .travis.yml tsconfig.build.json -tslint.json .npmrc .markdownlint.yaml .cache diff --git a/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.test.ts b/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.test.ts index 4b02a6dc02..c599b0d01d 100644 --- a/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.test.ts +++ b/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.test.ts @@ -1,7 +1,6 @@ import { main } from './main' test('main', () => { - // tslint:disable-next-line:no-console const mockLog = console.log = jest.fn() main() diff --git a/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.ts b/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.ts index 48651ad71e..302330c9a8 100644 --- a/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.ts +++ b/e2e/__external-repos__/yarn-workspace-composite/packages/my-app/main.ts @@ -3,7 +3,6 @@ import { myLibraryFunction } from '../my-library' export function main() { const value = myLibraryFunction() - // tslint:disable-next-line:no-console console.log(`You got foo: "${value.foo}" and bar: ${value.bar}`) } diff --git a/e2e/__helpers__/test-case/processed-file-io.ts b/e2e/__helpers__/test-case/processed-file-io.ts index 28415ea94f..8c053139de 100644 --- a/e2e/__helpers__/test-case/processed-file-io.ts +++ b/e2e/__helpers__/test-case/processed-file-io.ts @@ -3,7 +3,6 @@ import { Config } from '@jest/types' import ProcessedSource from '../../../src/__helpers__/processed-source' -// tslint:disable-next-line:no-default-export export default class ProcessedFileIo extends ProcessedSource { constructor( cwd: string, diff --git a/e2e/__helpers__/test-case/run-descriptor.ts b/e2e/__helpers__/test-case/run-descriptor.ts index 8cf49bc677..3b37b2c694 100644 --- a/e2e/__helpers__/test-case/run-descriptor.ts +++ b/e2e/__helpers__/test-case/run-descriptor.ts @@ -6,7 +6,6 @@ import RunResult from './run-result' import { run } from './runtime' import { RunTestOptions, RunWithTemplateIteratorContext, RunWithTemplatesIterator, TestRunResultsMap } from './types' -// tslint:disable-next-line:no-default-export export default class RunDescriptor { protected _options: RunTestOptions protected _sourcePackageJson: any @@ -46,8 +45,8 @@ export default class RunDescriptor { template: this.templateName, }) if (logUnlessStatus != null && logUnlessStatus !== result.status) { - // tslint:disable-next-line:no-console - console.log( + // eslint-disable-next-line no-console + console.log( '='.repeat(70), '\n', `Test exited with unexpected status in "${this.name}" using template "${this.templateName}" (exit code: ${result.status}):\n`, @@ -72,7 +71,7 @@ export default class RunDescriptor { throw new RangeError(`There must be at least one template to run the test case with.`) } - if (!templates.every((t, i) => templates.indexOf(t, i + 1) === -1)) { + if (!templates.every((t, i) => !templates.includes(t, i + 1))) { throw new Error(`Each template must be unique. Given ${templates.join(', ')}`) } return templates.reduce((map, template) => { @@ -80,9 +79,7 @@ export default class RunDescriptor { ...this._options, template, }) - const runTest = () => { - return (map[template] = desc.run(expectedStatus)) - } + const runTest = () => (map[template] = desc.run(expectedStatus)) if (iterator) { iterator(runTest, createIteratorContext(template, expectedStatus)) } else { diff --git a/e2e/__helpers__/test-case/run-result.ts b/e2e/__helpers__/test-case/run-result.ts index b434fc1cca..51467ed838 100644 --- a/e2e/__helpers__/test-case/run-result.ts +++ b/e2e/__helpers__/test-case/run-result.ts @@ -10,7 +10,6 @@ import { cacheDir } from '../../../scripts/lib/paths' import ProcessedFileIo from './processed-file-io' import { escapeRegex, normalizeJestOutput, stripAnsiColors } from './utils' -// tslint:disable-next-line:no-default-export export default class RunResult { constructor( readonly cwd: string, @@ -112,8 +111,6 @@ export default class RunResult { return map .sort((a, b) => ((b.from as any).length || Infinity) - ((a.from as any).length || Infinity)) - .reduce((str, { from, to }) => { - return str.replace(typeof from === 'string' ? new RegExp(`${escapeRegex(from)}`, 'g') : from, to) - }, str) + .reduce((str, { from, to }) => str.replace(typeof from === 'string' ? new RegExp(`${escapeRegex(from)}`, 'g') : from, to), str) } } diff --git a/e2e/__helpers__/test-case/runtime.ts b/e2e/__helpers__/test-case/runtime.ts index 718c9e5aa6..3e4bdb5f7f 100644 --- a/e2e/__helpers__/test-case/runtime.ts +++ b/e2e/__helpers__/test-case/runtime.ts @@ -44,12 +44,12 @@ describe.skip('__eval', () => { eval(process.env.__TS_JEST_EVAL); ` -// tslint:disable-next-line:variable-name let __hooksSource: string function hooksSourceWith(vars: Record): string { if (!__hooksSource) { __hooksSource = readFileSync(join(__dirname, '__hooks-source__.js.hbs'), 'utf8') } + // eslint-disable-next-line no-useless-escape return __hooksSource.replace(/\{\{([^\}]+)\}\}/g, (_, key) => JSON.stringify(vars[key])) } @@ -122,6 +122,7 @@ export function run(name: string, options: RunTestOptions = {}): RunResult { // write final config // FIXME: sounds like the json fail to be encoded as an arg + // eslint-disable-next-line no-constant-condition if (false /* enableOptimizations() */) { cmdArgs.push('--config', JSON.stringify(finalConfig)) } else if (Object.keys(extraConfig).length !== 0) { @@ -191,11 +192,9 @@ execFile(cmd, args, options) copySync(wrkDir, srcDir, { overwrite: false, - filter: from => { - return relative(sourceDir, from) + filter: from => relative(sourceDir, from) .split(sep) - .includes('__snapshots__') - }, + .includes('__snapshots__'), }) }) } diff --git a/e2e/__helpers__/test-case/types.ts b/e2e/__helpers__/test-case/types.ts index fc6028af03..8410d12c41 100644 --- a/e2e/__helpers__/test-case/types.ts +++ b/e2e/__helpers__/test-case/types.ts @@ -24,7 +24,7 @@ export interface RunWithTemplateIteratorContext { testLabel: string } -// tslint:disable-next-line:interface-over-type-literal + export type TestRunResultsMap = { [key in T]: RunResult } export interface PreparedTest { diff --git a/e2e/__helpers__/test-case/utils.ts b/e2e/__helpers__/test-case/utils.ts index 2a87c9160b..203029f270 100644 --- a/e2e/__helpers__/test-case/utils.ts +++ b/e2e/__helpers__/test-case/utils.ts @@ -3,6 +3,7 @@ import { join } from 'path' // from https://stackoverflow.com/questions/25245716/remove-all-ansi-colors-styles-from-strings export function stripAnsiColors(stringToStrip: string): string { + // eslint-disable-next-line no-control-regex return stringToStrip.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '') } @@ -18,8 +19,8 @@ export function templateNameForPath(path: string): string { const PASS_MARKS = ['√', '✓'] const FAIL_MARKS = ['×', '✕'] const normalizeTestMark = (mark: string): string => { - if (PASS_MARKS.includes(mark)) return PASS_MARKS[0]; // tslint:disable-line - if (FAIL_MARKS.includes(mark)) return FAIL_MARKS[0]; // tslint:disable-line + if (PASS_MARKS.includes(mark)) return PASS_MARKS[0] + if (FAIL_MARKS.includes(mark)) return FAIL_MARKS[0] return '?' } @@ -27,15 +28,14 @@ export function normalizeJestOutput(output: string): string { let out: string = output .trim() // removes total and estimated times - .replace(/^(\s*Time\s*:\s*)[\d.]+m?s(?:(,\s*estimated\s+)[\d.]+m?s)?$/gm, (_, start) => { - return `${start}XXs` - }) + .replace(/^(\s*Time\s*:\s*)[\d.]+m?s(?:(,\s*estimated\s+)[\d.]+m?s)?$/gm, (_, start) => `${start}XXs`) // remove times after PASS/FAIL path/to/file (xxxs) .replace(/^\s*((?:PASS|FAIL) .+) \([\d.]+m?s\)$/gm, (_, start) => `${start}`) // removes each test time values .replace( + // eslint-disable-next-line no-useless-escape /^(\s*)(✕|×|✓|√)(\s+[^\(]+)(\s+\([\d.]+m?s\))?$/gm, - (_, start, mark, mid /*, time */) => `${start}${normalizeTestMark(mark)}${mid}`, + (_, start, mark, mid /* , time */) => `${start}${normalizeTestMark(mark)}${mid}`, ) // TODO: improves this... if (process.platform === 'win32') { @@ -45,6 +45,7 @@ export function normalizeJestOutput(output: string): string { } export function escapeRegex(s: string) { + // eslint-disable-next-line no-useless-escape return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') } diff --git a/e2e/__serializers__/run-result.ts b/e2e/__serializers__/run-result.ts index 8aeadc38ce..8cc3babddb 100644 --- a/e2e/__serializers__/run-result.ts +++ b/e2e/__serializers__/run-result.ts @@ -2,16 +2,16 @@ import RunResult from '../__helpers__/test-case/run-result' export const test = (val: any) => val && val instanceof RunResult export const print = (val: RunResult, _: any, indent: any) => { - const out = [ - `${val.status === 0 ? '√' : '×'} ${val.cmdLine}`, - `↳ exit code: ${val.status}`, - `===[ STDOUT ]${'='.repeat(67)}`, - val.normalizedStdout, - `===[ STDERR ]${'='.repeat(67)}`, - val.normalizedStderr, - '='.repeat(80), - ] - .map(l => indent(l)) - .join('\n') - return out + const out = [ + `${val.status === 0 ? '√' : '×'} ${val.cmdLine}`, + `↳ exit code: ${val.status}`, + `===[ STDOUT ]${'='.repeat(67)}`, + val.normalizedStdout, + `===[ STDERR ]${'='.repeat(67)}`, + val.normalizedStderr, + '='.repeat(80), + ] + .map(l => indent(l)) + .join('\n') + return out } diff --git a/e2e/__tests__/logger.test.ts b/e2e/__tests__/logger.test.ts index 0352fa9eaf..6563b51e88 100644 --- a/e2e/__tests__/logger.test.ts +++ b/e2e/__tests__/logger.test.ts @@ -26,7 +26,7 @@ describe('TS_JEST_LOG', () => { it(`should pass and create log file when using template "${templateName}"`, () => { const result = runTest() expect(result.status).toBe(0) - expect(existsSync(result.logFilePath)) + expect(existsSync(result.logFilePath)).toBe(true) const filteredEntries = result.logFileEntries // keep only debug and above .filter(m => (m.context[LogContexts.logLevel] || 0) >= LogLevels.debug) diff --git a/e2e/__tests__/module-kinds/helpers.ts b/e2e/__tests__/module-kinds/helpers.ts index 1e01b2aff5..66501102ea 100644 --- a/e2e/__tests__/module-kinds/helpers.ts +++ b/e2e/__tests__/module-kinds/helpers.ts @@ -8,13 +8,12 @@ import { configureTestCase } from '../../__helpers__/test-case' // ES2015 = 5, // ESNext = 6 -const testCaseForCompilerOpt = (config: any) => { - return configureTestCase('module-kinds', { +const testCaseForCompilerOpt = (config: any) => configureTestCase('module-kinds', { tsJestConfig: { tsConfig: config, diagnostics: { warnOnly: true } }, noCache: true, }) -} +// eslint-disable-next-line jest/no-export export const runTestForOptions = (options: { module: string allowSyntheticDefaultImports?: boolean diff --git a/package-lock.json b/package-lock.json index c291359b6e..efc8ed5c8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1453,6 +1453,12 @@ "@types/node": "*" } }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, "@types/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.0.tgz", @@ -1512,6 +1518,12 @@ "integrity": "sha512-otRe77JNNWzoVGLKw8TCspKswRoQToys4tuL6XYVBFxjgeM0RUrx7m3jkaTdxILxeGry3zM8mGYkGXMeQ02guA==", "dev": true }, + "@types/json-schema": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz", + "integrity": "sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==", + "dev": true + }, "@types/json5": { "version": "0.0.30", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.30.tgz", @@ -1648,6 +1660,116 @@ "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.30.0.tgz", + "integrity": "sha512-PGejii0qIZ9Q40RB2jIHyUpRWs1GJuHP1pkoCiaeicfwO9z7Fx03NQzupuyzAmv+q9/gFNHu7lo1ByMXe8PNyg==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.30.0", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "regexpp": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "dev": true + }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + } + } + }, + "@typescript-eslint/experimental-utils": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.30.0.tgz", + "integrity": "sha512-L3/tS9t+hAHksy8xuorhOzhdefN0ERPDWmR9CclsIGOUqGKy6tqc/P+SoXeJRye5gazkuPO0cK9MQRnolykzkA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.30.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + }, + "dependencies": { + "eslint-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", + "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + } + } + }, + "@typescript-eslint/parser": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.30.0.tgz", + "integrity": "sha512-9kDOxzp0K85UnpmPJqUzdWaCNorYYgk1yZmf4IKzpeTlSAclnFsrLjfwD9mQExctLoLoGAUXq1co+fbr+3HeFw==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "2.30.0", + "@typescript-eslint/typescript-estree": "2.30.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.30.0.tgz", + "integrity": "sha512-nI5WOechrA0qAhnr+DzqwmqHsx7Ulr/+0H7bWCcClDhhWkSyZR5BmTvnBEyONwJCTWHfc5PAQExX24VD26IAVw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + } + } + }, "JSONStream": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.4.tgz", @@ -2479,6 +2601,12 @@ "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "dev": true }, + "comment-parser": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.2.tgz", + "integrity": "sha512-4Rjb1FnxtOcv9qsfuaNuVsmmVn4ooVoBHzYfyKteiXwIU84PClyGA5jASoFMwPV93+FPh9spwueXauxFJZkGAg==", + "dev": true + }, "compare-func": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", @@ -3131,12 +3259,6 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true - }, "diff-sequences": { "version": "25.2.6", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-25.2.6.tgz", @@ -3345,24 +3467,64 @@ } } }, - "eslint-plugin-prettier": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.7.0.tgz", - "integrity": "sha512-CStQYJgALoQBw3FsBzH0VOVDRnJ/ZimUlpLm226U8qgqYJfPOY/CPK6wyRInMxh73HSKg5wyRwdS4BVYYHwokA==", + "eslint-config-prettier": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz", + "integrity": "sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA==", "dev": true, "requires": { - "fast-diff": "^1.1.1", - "jest-docblock": "^21.0.0" + "get-stdin": "^6.0.0" }, "dependencies": { - "jest-docblock": { - "version": "21.2.0", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz", - "integrity": "sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==", + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", "dev": true } } }, + "eslint-plugin-jest": { + "version": "23.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz", + "integrity": "sha512-xwbnvOsotSV27MtAe7s8uGWOori0nUsrXh2f1EnpmXua8sDfY6VZhHAhHg2sqK7HBNycRQExF074XSZ7DvfoFg==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "^2.5.0" + } + }, + "eslint-plugin-jsdoc": { + "version": "24.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-24.0.0.tgz", + "integrity": "sha512-AGAc9PYpramsJGVmqtxnXBYlq+AMh+hIZdbJ52OLvyJS3f+PaT/PzuckRFOLnth2uhCDv4IjgsB3r5jUFWqUnw==", + "dev": true, + "requires": { + "comment-parser": "^0.7.2", + "debug": "^4.1.1", + "jsdoctypeparser": "^6.1.0", + "lodash": "^4.17.15", + "regextras": "^0.7.0", + "semver": "^6.3.0", + "spdx-expression-parse": "^3.0.0" + }, + "dependencies": { + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz", + "integrity": "sha512-+HG5jmu/dN3ZV3T6eCD7a4BlAySdN7mLIbJYo0z1cFQuI+r2DiTJEFeF68ots93PsnrMxbzIZ2S/ieX+mkrBeQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -6571,6 +6733,12 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, + "jsdoctypeparser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-6.1.0.tgz", + "integrity": "sha512-UCQBZ3xCUBv/PLfwKAJhp6jmGOSLFNKzrotXGNgbKhWvz27wPsCsVeP7gIcHPElQw2agBmynAitXqhxR58XAmA==", + "dev": true + }, "jsdom": { "version": "15.2.1", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-15.2.1.tgz", @@ -7897,6 +8065,15 @@ "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-format": { "version": "25.2.6", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-25.2.6.tgz", @@ -8078,6 +8255,12 @@ "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, + "regextras": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/regextras/-/regextras-0.7.0.tgz", + "integrity": "sha512-ds+fL+Vhl918gbAUb0k2gVKbTZLsg84Re3DI6p85Et0U0tYME3hyW4nMK8Px4dtDaBA2qNjvG5uWyW7eK5gfmw==", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -9275,67 +9458,6 @@ "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", "dev": true }, - "tslint": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.2.tgz", - "integrity": "sha512-UyNrLdK3E0fQG/xWNqAFAC5ugtFyPO4JJR1KyyfQAyzR8W0fTRrC91A8Wej4BntFzcvETdCSDa/4PnNYJQLYiA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.10.0", - "tsutils": "^2.29.0" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "tslint-config-prettier": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", - "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", - "dev": true - }, - "tslint-plugin-prettier": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslint-plugin-prettier/-/tslint-plugin-prettier-2.3.0.tgz", - "integrity": "sha512-F9e4K03yc9xuvv+A0v1EmjcnDwpz8SpCD8HzqSDe0eyg34cBinwn9JjmnnRrNAs4HdleRQj7qijp+P/JTxt4vA==", - "dev": true, - "requires": { - "eslint-plugin-prettier": "^2.2.0", - "lines-and-columns": "^1.1.6", - "tslib": "^1.7.1" - } - }, - "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - } - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index cf9080f96d..e34d1b6d5c 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,8 @@ "test:unit": "node_modules/.bin/jest", "test:external": "node scripts/test-external-project.js", "test:external-repos": "npm run test:external external-repos", - "lint": "run-s lint:ts lint:js", - "lint:js": "node_modules/.bin/eslint . -f stylish", - "lint:ts": "node_modules/.bin/tslint -t stylish --project .", - "lint:fix": "run-s lint:fix:ts lint:fix:js", - "lint:fix:js": "node_modules/.bin/eslint . --fix", - "lint:fix:ts": "node_modules/.bin/tslint --fix --project .", + "lint": "node_modules/.bin/eslint --ext .js,.ts .", + "lint:fix": "node_modules/.bin/eslint --fix --ext .js,.ts .", "typecheck": "node_modules/.bin/tsc -p .", "doc": "cd docs && bundle exec jekyll serve --livereload", "doc:link": "git worktree add docs/_site gh-pages", @@ -106,9 +102,15 @@ "@types/semver": "latest", "@types/yargs": "latest", "@types/yargs-parser": "15.x", + "@typescript-eslint/eslint-plugin": "^2.30.0", + "@typescript-eslint/parser": "^2.30.0", "conventional-changelog-cli": "2.x", "cross-spawn": "latest", "eslint": "latest", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-jest": "^23.8.2", + "eslint-plugin-jsdoc": "^24.0.0", + "eslint-plugin-prettier": "^3.1.3", "fs-extra": "8.x", "glob-gitignore": "latest", "husky": "3.x", @@ -120,14 +122,11 @@ "npm-run-all": "latest", "prettier": "1.x", "source-map": "latest", - "tslint": "latest", - "tslint-config-prettier": "latest", - "tslint-plugin-prettier": "latest", "typescript": "3.x" }, "lint-staged": { "*.{ts,tsx}": [ - "tslint --fix", + "eslint --fix", "git add" ], "*.{js,jsx}": [ diff --git a/preprocessor.js b/preprocessor.js index 19a071d4bd..c23a1d0f21 100644 --- a/preprocessor.js +++ b/preprocessor.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line no-console console.warn( 'ts-jest[main] (WARN) Replace any occurrences of "ts-jest/dist/preprocessor.js" or ' + ' "/node_modules/ts-jest/preprocessor.js"' + diff --git a/presets/index.js b/presets/index.js index 95cca6d7be..0417538e7c 100644 --- a/presets/index.js +++ b/presets/index.js @@ -1,13 +1,20 @@ const create = require('./create') module.exports = { - get defaults() { return create() }, - get jsWithTs() { return create({ allowJs: true }) }, + get defaults() { + return create() + }, + get jsWithTs() { + return create({ allowJs: true }) + }, get jsWithBabel() { - return create({ allowJs: false }, { - transform: { - '^.+\\.jsx?$': 'babel-jest', - }, - }) + return create( + { allowJs: false }, + { + transform: { + '^.+\\.jsx?$': 'babel-jest', + }, + } + ) }, } diff --git a/scripts/clean.js b/scripts/clean.js index 90b6ee88ab..a66545a7cd 100755 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -4,16 +4,15 @@ const { removeSync } = require('fs-extra') const Paths = require('./lib/paths') const { join } = require('path') -if (process.argv.indexOf('--when-ci-commit-message') !== -1) { - let msg = - process.env.TRAVIS_COMMIT_MESSAGE || - process.env.APPVEYOR_REPO_COMMIT_MESSAGE - if (!msg) +if (process.argv.includes('--when-ci-commit-message')) { + let msg = process.env.TRAVIS_COMMIT_MESSAGE || process.env.APPVEYOR_REPO_COMMIT_MESSAGE + if (!msg) { throw new Error('Unable to guess the commit message from CI env variables') + } if (process.env.APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED) { msg = `${msg}\n${process.env.APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED}` } - if (!/\[ci clean\]/.test(msg)) process.exit(0) + if (!msg.includes('[ci clean]')) process.exit(0) } removeSync(Paths.distDir) diff --git a/scripts/e2e.js b/scripts/e2e.js index 3e2ad46765..10ba9a2152 100755 --- a/scripts/e2e.js +++ b/scripts/e2e.js @@ -1,6 +1,7 @@ #!/usr/bin/env node 'use strict' +// eslint-disable-next-line jest/no-jest-import const jest = require('jest') const { spawnSync } = require('./lib/spawn-sync') const fs = require('fs-extra') @@ -15,21 +16,14 @@ const configFile = path.join(Paths.e2eRootDir, 'jest.config.js') let parentArgs = process.argv.slice(2) if (parentArgs.includes('--coverage')) { - logger.warn( - 'Coverages cannot be activated for e2e tests (but can in each e2e test).' - ) + logger.warn('Coverages cannot be activated for e2e tests (but can in each e2e test).') parentArgs = parentArgs.filter(a => a !== '--coverage') } if (!parentArgs.includes('--runInBand')) parentArgs.push('--runInBand') const prepareOnly = parentArgs.includes('--prepareOnly') -// eslint-disable-next-line no-unused-vars -function enableOptimizations() { - return !!process.env.TS_JEST_E2E_OPTIMIZATIONS -} - function getDirectories(rootDir) { - return fs.readdirSync(rootDir).filter(function (file) { + return fs.readdirSync(rootDir).filter(function(file) { return fs.statSync(path.join(rootDir, file)).isDirectory() }) } @@ -47,11 +41,7 @@ function log(...msg) { function setupE2e() { // kept on top so that the build is triggered beforehand (pack => prepublish => clean-build => build) const bundle = createBundle(log) - log( - 'bundle created:', - path.relative(Paths.rootDir, bundle), - '; computing digest' - ) + log('bundle created:', path.relative(Paths.rootDir, bundle), '; computing digest') // get the hash of the bundle (to know if we should install it again or not) const bundleHash = readPackageDigest() @@ -63,10 +53,7 @@ function setupE2e() { // link locally so we could find it easily if (!process.env.CI && !fs.existsSync(Paths.e2eWotkDirLink)) { fs.symlinkSync(Paths.e2eWorkDir, Paths.e2eWotkDirLink, 'dir') - log( - 'symbolic link to the work directory created at: ', - Paths.e2eWotkDirLink - ) + log('symbolic link to the work directory created at: ', Paths.e2eWotkDirLink) } // cleanup files related to old test run @@ -94,11 +81,7 @@ function setupE2e() { Object.keys(deps) .sort() .forEach(name => { - log( - ' -', - `${name}${' '.repeat(20 - name.length)}`, - deps[name].version - ) + log(' -', `${name}${' '.repeat(20 - name.length)}`, deps[name].version) }) deps = null } @@ -128,16 +111,13 @@ function setupE2e() { const pkgLockHash = sha1(fs.readFileSync(pkgLockFile)) const e2eData = fs.existsSync(e2eFile) ? fs.readJsonSync(e2eFile) : {} let bundleOk = e2eData.bundleHash === bundleHash - let packagesOk = e2eData.packageLockHash === pkgLockHash + const packagesOk = e2eData.packageLockHash === pkgLockHash if (fs.existsSync(nodeModulesDir)) { log(` [template: ${name}]`, 'bundle: ', bundleOk ? 'OK' : 'CHANGED') log(` [template: ${name}]`, 'packages: ', packagesOk ? 'OK' : 'CHANGED') if (bundleOk && packagesOk) { - log( - ` [template: ${name}]`, - 'bundle and packages unchanged, nothing to do' - ) + log(` [template: ${name}]`, 'bundle and packages unchanged, nothing to do') logPackageVersions() return } diff --git a/scripts/lib/npm.js b/scripts/lib/npm.js index dce0223ff4..2cf70e7d50 100644 --- a/scripts/lib/npm.js +++ b/scripts/lib/npm.js @@ -3,15 +3,13 @@ const { satisfies } = require('semver') const memoize = require('lodash.memoize') const { join } = require('path') -const version = memoize(() => { - return spawnSync(['-s', '--version']) +const version = memoize(() => + spawnSync(['-s', '--version']) .stdout.toString() .trim() -}) +) -const spawnSync = (args, options = {}) => { - return spawn('npm', args, options) -} +const spawnSync = (args, options = {}) => spawn('npm', args, options) const can = { ci: memoize(() => satisfies(version(), '>=5.7.0')), diff --git a/scripts/test-external-project.js b/scripts/test-external-project.js index 8bc47e0c25..10b9888bc4 100755 --- a/scripts/test-external-project.js +++ b/scripts/test-external-project.js @@ -38,33 +38,18 @@ const executeTest = (monorepoRealPath, bundle) => { if (!projectPkg.version) projectPkg.version = 'unknown' logger.log() - logger.log( - '='.repeat(20), - `${projectPkg.name}@${projectPkg.version}`, - 'in', - monorepoRealPath, - '='.repeat(20) - ) + logger.log('='.repeat(20), `${projectPkg.name}@${projectPkg.version}`, 'in', monorepoRealPath, '='.repeat(20)) logger.log() // then we install it in the repo logger.log('ensuring all depedencies of target project are installed') - npm.spawnSync( - ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save'], - { cwd: monorepoRealPath } - ) + npm.spawnSync(['install', '--no-package-lock', '--no-shrinkwrap', '--no-save'], { cwd: monorepoRealPath }) logger.log('installing bundled version of ts-jest') - npm.spawnSync( - ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], - { cwd: monorepoRealPath } - ) + npm.spawnSync(['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], { cwd: monorepoRealPath }) // then we can run the tests const useYarn = existsSync(join(monorepoRealPath, 'yarn.lock')) - const cmdLine = - projectPkg.scripts && projectPkg.scripts.test - ? [(useYarn ? 'yarn' : 'npm'), 'test'] - : ['jest'] + const cmdLine = projectPkg.scripts && projectPkg.scripts.test ? [useYarn ? 'yarn' : 'npm', 'test'] : ['jest'] if (jestArgs.length) { cmdLine.push('--') cmdLine.push(...jestArgs) @@ -76,9 +61,7 @@ const executeTest = (monorepoRealPath, bundle) => { spawnSync(cmdLine.shift(), cmdLine, { cwd: monorepoRealPath, stdio: 'inherit', - env: Object.assign({}, process.env, { - TS_JEST_IGNORE_DIAGNOSTICS: '5023,5024', - }), + env: { ...process.env, TS_JEST_IGNORE_DIAGNOSTICS: '5023,5024' }, }) } @@ -97,11 +80,7 @@ if (/^((https|ssh|git):\/\/|[a-z0-9]+@[a-z0-9.]+:).+$/.test(projectPath)) { } catch (e) { monorepoRealPath = undefined } - if ( - !monorepoRealPath || - !existsSync(join(monorepoRealPath, 'package.json')) || - monorepoRealPath === rootDir - ) { + if (!monorepoRealPath || !existsSync(join(monorepoRealPath, 'package.json')) || monorepoRealPath === rootDir) { logger.error('First argument must be the path to a project or a git URL') process.exit(1) } else { diff --git a/scripts/update-e2e-templates.js b/scripts/update-e2e-templates.js index 0c0c531e7d..34df63cebe 100755 --- a/scripts/update-e2e-templates.js +++ b/scripts/update-e2e-templates.js @@ -13,15 +13,10 @@ const templateDirs = fs .filter(f => fs.statSync(path.join(Paths.e2eTemplatesDir, f)).isDirectory()) templateDirs.forEach((tmpl, i) => { const tmplPath = path.join(Paths.e2eTemplatesDir, tmpl) - logger.log( - `[${i + 1}/${templateDirs.length}] updating dependencies of ${tmpl}:` - ) + logger.log(`[${i + 1}/${templateDirs.length}] updating dependencies of ${tmpl}:`) process.chdir(tmplPath) const wanted = require(path.join(tmplPath, 'package.json')).wantedDependencies - if (!wanted) - throw new Error( - 'The package.json must have a "wantedDependencies" section.' - ) + if (!wanted) throw new Error('The package.json must have a "wantedDependencies" section.') let args = [] Object.keys(wanted).forEach(key => { diff --git a/src/__helpers__/mocks.ts b/src/__helpers__/mocks.ts index 75cdd8bc9c..bd49d6a2a0 100644 --- a/src/__helpers__/mocks.ts +++ b/src/__helpers__/mocks.ts @@ -29,14 +29,12 @@ export const mockObject = (obj: T, newProps: M): T & M & { mockRestore: () }) } -export const mockWriteStream = () => { - return { - written: [] as string[], - write(text: string) { - this.written.push(text) - }, - clear() { - this.written = [] - }, - } -} +export const mockWriteStream = () => ({ + written: [] as string[], + write(text: string) { + this.written.push(text) + }, + clear() { + this.written = [] + }, +}) diff --git a/src/__helpers__/path.ts b/src/__helpers__/path.ts index 0ee19c2b47..6841f891e9 100644 --- a/src/__helpers__/path.ts +++ b/src/__helpers__/path.ts @@ -9,7 +9,7 @@ export function relativeToRoot(path: string) { } export function tempDir(ns: string) { - const dir = join(tmpdir(), `ts-jest-unit-tests`, ns, parseInt((Math.random() * 1e17) as any, 10).toString(36)) + const dir = join(tmpdir(), 'ts-jest-unit-tests', ns, parseInt((Math.random() * 1e17) as any, 10).toString(36)) ensureDirSync(dir) return dir } diff --git a/src/__helpers__/processed-source.ts b/src/__helpers__/processed-source.ts index 3ca7f19346..2e9ead49a9 100644 --- a/src/__helpers__/processed-source.ts +++ b/src/__helpers__/processed-source.ts @@ -4,7 +4,6 @@ import { RawSourceMap } from 'source-map' import { ROOT } from './path' import { ParsedSourceWithMaps, parseSource, relativisePaths, rewriteSourceMaps } from './source-maps' -// tslint:disable-next-line:no-default-export export default class ProcessedSource { readonly filename: string @@ -30,7 +29,7 @@ export default class ProcessedSource { get normalizedOutputSourceMaps(): RawSourceMap | undefined { const maps = this.outputSourceMaps if (maps) return this.sourceMapsNormalizer(maps) - return + return undefined } get sourceMapsNormalizer() { return (maps: RawSourceMap): RawSourceMap => relativisePaths(maps, this.cwd, '/') diff --git a/src/__helpers__/source-maps.ts b/src/__helpers__/source-maps.ts index e2c50a6bd5..1c0bfd8e75 100644 --- a/src/__helpers__/source-maps.ts +++ b/src/__helpers__/source-maps.ts @@ -20,6 +20,7 @@ export interface ParsedSourceWithMaps { } export function parseSource(source: string): ParsedSourceWithMaps { const [comment, b64Maps]: [string, string | undefined] = + // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec (source.match(/[\n^]\/\/#\s*sourceMappingURL=data:application\/json;(?:charset=utf-8;)?base64,(\S+)\s*$/) as any) || [] if (b64Maps) { diff --git a/src/cli/config/init.ts b/src/cli/config/init.ts index 410c76f75b..043f901c9c 100644 --- a/src/cli/config/init.ts +++ b/src/cli/config/init.ts @@ -91,17 +91,17 @@ export const run: CliCommand = async (args: Arguments /* , logger: Logger */) => if (jestPreset) { content.push(` preset: '${preset.name}',`) } else { - content.push(` ...tsjPreset,`) + content.push(' ...tsjPreset,') } - if (!jsdom) content.push(` testEnvironment: 'node',`) + if (!jsdom) content.push(" testEnvironment: 'node',") if (tsconfig || shouldPostProcessWithBabel) { - content.push(` globals: {`) - content.push(` 'ts-jest': {`) + content.push(' globals: {') + content.push(" 'ts-jest': {") if (tsconfig) content.push(` tsconfig: ${stringifyJson5(tsconfig)},`) - if (shouldPostProcessWithBabel) content.push(` babelConfig: true,`) - content.push(` },`) - content.push(` },`) + if (shouldPostProcessWithBabel) content.push(' babelConfig: true,') + content.push(' },') + content.push(' },') } content.push('};') diff --git a/src/cli/config/migrate.ts b/src/cli/config/migrate.ts index dadbf0434c..b6caa043e6 100644 --- a/src/cli/config/migrate.ts +++ b/src/cli/config/migrate.ts @@ -13,7 +13,7 @@ import { JestPresetNames, TsJestPresetDescriptor, allPresets, defaults } from '. /** * @internal */ -export const run: CliCommand = async (args: Arguments /*, logger: Logger*/) => { +export const run: CliCommand = async (args: Arguments /* , logger: Logger*/) => { const nullLogger = createLogger({ targets: [] }) const file = args._[0] const filePath = resolve(process.cwd(), file) @@ -110,7 +110,6 @@ Visit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more inf Object.keys(migratedConfig.transform).forEach(key => { const val = (migratedConfig.transform as any)[key] if (typeof val === 'string' && /\/?ts-jest(?:\/preprocessor\.js)?$/.test(val)) { - // tslint:disable-next-line:semicolon ;(migratedConfig.transform as any)[key] = 'ts-jest' } }) @@ -136,8 +135,8 @@ No migration needed for given Jest configuration return } - const stringify = /\.json$/.test(file) ? JSON.stringify : stringifyJson5 - const prefix = /\.json$/.test(file) ? '"jest": ' : 'module.exports = ' + const stringify = file.endsWith('.json') ? JSON.stringify : stringifyJson5 + const prefix = file.endsWith('.json') ? '"jest": ' : 'module.exports = ' // if we are using preset, inform the user that he might be able to remove some section(s) // we couldn't check for equality diff --git a/src/cli/helpers/presets.ts b/src/cli/helpers/presets.ts index e5a3139a3e..fdfb225387 100644 --- a/src/cli/helpers/presets.ts +++ b/src/cli/helpers/presets.ts @@ -32,6 +32,7 @@ const definePreset = (fullName: string): TsJestPresetDescriptor => ({ : fullName .split('/') .pop()! + // eslint-disable-next-line no-useless-escape .replace(/\-([a-z])/g, (_, l) => l.toUpperCase()) }, get value() { diff --git a/src/cli/index.ts b/src/cli/index.ts index 73f3ae4c61..5962ecd802 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -31,7 +31,7 @@ async function cli(args: string[]): Promise { // deprecated if (parsedArgv.allowJs != null) { - if (parsedArgv.js) throw new Error(`The 'allowJs' and 'js' options cannot be set together.`) + if (parsedArgv.js) throw new Error("The 'allowJs' and 'js' options cannot be set together.") parsedArgv.js = parsedArgv.allowJs ? 'ts' : undefined } @@ -41,7 +41,6 @@ async function cli(args: string[]): Promise { if (!VALID_COMMANDS.includes(command)) command = 'help' - // tslint:disable-next-line:no-var-requires const { run, help }: { run: CliCommand; help: CliCommand } = require(`./${command.replace(/:/g, '/')}`) const cmd = isHelp && command !== 'help' ? help : run diff --git a/src/compiler/compiler-utils.ts b/src/compiler/compiler-utils.ts index 154c6f911d..35ddc089e9 100644 --- a/src/compiler/compiler-utils.ts +++ b/src/compiler/compiler-utils.ts @@ -35,17 +35,17 @@ export function cacheResolvedModules( * Ugly trick while waiting for https://github.com/microsoft/TypeScript/issues/33994 */ if (importReferences.length) { - logger.debug({ fileName }, `cacheResolvedModules(): get resolved modules`) + logger.debug({ fileName }, 'cacheResolvedModules(): get resolved modules') memoryCache.resolvedModules[fileName] = Object.create(null) memoryCache.resolvedModules[fileName].modulePaths = importReferences .filter((importReference: any) => importReference.parent.parent.resolvedModules?.get(importReference.text)) - .map((importReference: any) => { - return normalize( + .map((importReference: any) => + normalize( (importReference.parent.parent.resolvedModules.get(importReference.text) as _ts.ResolvedModule) .resolvedFileName, - ) - }) + ), + ) .reduce((a: any, b: any) => a.concat(b), []) memoryCache.resolvedModules[fileName].testFileContent = fileContent writeFileSync(getResolvedModulesCache(cacheDir), JSON.stringify(memoryCache.resolvedModules)) @@ -64,7 +64,7 @@ export function isTestFile(testMatchPatterns: (string | RegExp)[], fileName: str /* istanbul ignore next (we leave this for e2e) */ function isUsingProjectReferences( program: _ts.Program, - projectReferences: ReadonlyArray<_ts.ProjectReference> | undefined, + projectReferences: readonly _ts.ProjectReference[] | undefined, ) { if (projectReferences && !!program.getProjectReferences) { return Boolean(program && program.getProjectReferences()) @@ -76,7 +76,7 @@ function isUsingProjectReferences( /* istanbul ignore next (we leave this for e2e) */ function getResolvedProjectReferences( program: _ts.Program, -): ReadonlyArray<_ts.ResolvedProjectReference | undefined> | undefined { +): readonly (_ts.ResolvedProjectReference | undefined)[] | undefined { const getProjectReferences = program.getResolvedProjectReferences ?? program.getProjectReferences if (getProjectReferences) { return getProjectReferences() @@ -89,7 +89,7 @@ function getResolvedProjectReferences( function getProjectReferenceForFile( filePath: string, program: _ts.Program, - projectReferences: ReadonlyArray<_ts.ProjectReference> | undefined, + projectReferences: readonly _ts.ProjectReference[] | undefined, ) { if (isUsingProjectReferences(program, projectReferences)) { return ( @@ -111,7 +111,7 @@ export function getAndCacheProjectReference( filePath: string, program: _ts.Program, files: TSFiles, - projectReferences: ReadonlyArray<_ts.ProjectReference> | undefined, + projectReferences: readonly _ts.ProjectReference[] | undefined, ) { const file = files.get(filePath) if (file?.projectReference) { @@ -185,7 +185,7 @@ export function getCompileResultFromReferencedProject( if (referencedProject.commandLine.options.outFile !== undefined) { throw new Error( `The referenced project at ${relativeProjectConfigPath} is using ` + - `the outFile' option, which is not supported with ts-jest.`, + "the outFile' option, which is not supported with ts-jest.", ) } @@ -193,10 +193,9 @@ export function getCompileResultFromReferencedProject( const relativeJSFileName = configs.resolvePath(jsFileName) if (!configs.compilerModule.sys.fileExists(jsFileName)) { throw new Error( - // tslint:disable-next-line:prefer-template - `Could not find output JavaScript file for input ` + + 'Could not find output JavaScript file for input ' + `${relativeFilePath} (looked at ${relativeJSFileName}).\n` + - `The input file is part of a project reference located at ` + + 'The input file is part of a project reference located at ' + `${relativeProjectConfigPath}, so ts-jest is looking for the ` + 'project’s pre-built output on disk. Try running `tsc --build` ' + 'to build project references.', diff --git a/src/compiler/instance.ts b/src/compiler/instance.ts index 920e18ecfc..daae479d4b 100644 --- a/src/compiler/instance.ts +++ b/src/compiler/instance.ts @@ -49,23 +49,22 @@ const compileAndCacheResult = ( compileFn: CompileFn, getExtension: (fileName: string) => string, logger: Logger, -) => { - return (code: string, fileName: string, lineOffset?: number) => { - logger.debug({ fileName }, 'compileAndCacheResult(): get compile output') +) => (code: string, fileName: string, lineOffset?: number) => { + logger.debug({ fileName }, 'compileAndCacheResult(): get compile output') - const [value, sourceMap] = compileFn(code, fileName, lineOffset) - const output = updateOutput(value, fileName, sourceMap, getExtension) - memoryCache.files.set(fileName, { - ...memoryCache.files.get(fileName)!, - output, - }) + const [value, sourceMap] = compileFn(code, fileName, lineOffset) + const output = updateOutput(value, fileName, sourceMap, getExtension) + memoryCache.files.set(fileName, { + ...memoryCache.files.get(fileName)!, + output, + }) - return output - } + return output } /** * Register TypeScript compiler instance. + * * @internal */ export const createCompilerInstance = (configs: ConfigSet): TsCompiler => { diff --git a/src/compiler/language-service.spec.ts b/src/compiler/language-service.spec.ts index 133439d377..eb79eefdcd 100644 --- a/src/compiler/language-service.spec.ts +++ b/src/compiler/language-service.spec.ts @@ -69,7 +69,6 @@ describe('Language service', () => { }) it('should cache resolved modules for test file with testMatchPatterns from jest config when match', () => { - // tslint:disable-next-line:no-empty const spy = jest.spyOn(compilerUtils, 'cacheResolvedModules').mockImplementationOnce(() => {}) const tmp = tempDir('compiler') const compiler = makeCompiler({ @@ -90,8 +89,7 @@ export const thing: Thing = { a: 1 }` spy.mockRestore() }) - it(`shouldn't cache resolved modules for test file with testMatchPatterns from jest config when not match`, () => { - // tslint:disable-next-line:no-empty + it("shouldn't cache resolved modules for test file with testMatchPatterns from jest config when not match", () => { jest.spyOn(compilerUtils, 'cacheResolvedModules').mockImplementationOnce(() => {}) const tmp = tempDir('compiler') const compiler = makeCompiler({ @@ -109,7 +107,7 @@ export const thing: Thing = { a: 1 }` }) it('should compile js file for allowJs true with outDir', () => { - const fileName = `test-allow-js-with-outDir.js` + const fileName = 'test-allow-js-with-outDir.js' const compiler = makeCompiler({ tsJestConfig: { tsConfig: { allowJs: true, outDir: '$$foo$$' } }, }) @@ -124,7 +122,7 @@ export const thing: Thing = { a: 1 }` }) it('should compile js file for allowJs true without outDir', () => { - const fileName = `test-allow-js-no-outDir.js` + const fileName = 'test-allow-js-no-outDir.js' const compiler = makeCompiler({ tsJestConfig: { tsConfig: { allowJs: true } }, }) diff --git a/src/compiler/language-service.ts b/src/compiler/language-service.ts index 69eea6fd3c..2555d05ce4 100644 --- a/src/compiler/language-service.ts +++ b/src/compiler/language-service.ts @@ -50,7 +50,7 @@ export const initializeLanguageServiceInstance = ( // Set the file contents into cache. /* istanbul ignore next (cover by e2e) */ const updateMemoryCache = (contents: string, fileName: string) => { - logger.debug({ fileName }, `updateMemoryCache(): update memory cache for language service`) + logger.debug({ fileName }, 'updateMemoryCache(): update memory cache for language service') let shouldIncrementProjectVersion = false const hit = isFileInCache(fileName) @@ -101,7 +101,7 @@ export const initializeLanguageServiceInstance = ( const normalizedFileName = normalize(fileName) const hit = memoryCache.files.has(normalizedFileName) && memoryCache.files.get(normalizedFileName)!.version !== 0 - logger.trace({ normalizedFileName, cacheHit: hit }, `getScriptSnapshot():`, 'cache', hit ? 'hit' : 'miss') + logger.trace({ normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss') // Read contents from TypeScript memory cache. if (!hit) { @@ -152,7 +152,7 @@ export const initializeLanguageServiceInstance = ( } else { const output: _ts.EmitOutput = service.getEmitOutput(fileName) // Do type checking by getting TypeScript diagnostics - logger.debug({ fileName }, `compileFn(): computing diagnostics using language service`) + logger.debug({ fileName }, 'compileFn(): computing diagnostics using language service') doTypeChecking(configs, fileName, service, logger) /** @@ -163,22 +163,21 @@ export const initializeLanguageServiceInstance = ( cacheResolvedModules(fileName, code, memoryCache, service.getProgram()!, cacheDir, logger) } else { Object.entries(memoryCache.resolvedModules) - .filter(entry => { - /** - * When imported modules change, we only need to check whether the test file is compiled previously or not - * base on memory cache. By checking memory cache, we can avoid repeatedly doing type checking against - * test file for 1st time run after clearing cache because - */ - return ( - entry[1].modulePaths.find(modulePath => modulePath === fileName) && !memoryCache.files.has(entry[0]) - ) - }) + .filter( + entry => + /** + * When imported modules change, we only need to check whether the test file is compiled previously or not + * base on memory cache. By checking memory cache, we can avoid repeatedly doing type checking against + * test file for 1st time run after clearing cache because + */ + entry[1].modulePaths.find(modulePath => modulePath === fileName) && !memoryCache.files.has(entry[0]), + ) .forEach(entry => { const testFileName = entry[0] const testFileContent = entry[1].testFileContent logger.debug( { fileName }, - `compileFn(): computing diagnostics for test file that imports this module using language service`, + 'compileFn(): computing diagnostics for test file that imports this module using language service', ) updateMemoryCache(testFileContent, testFileName) diff --git a/src/compiler/transpiler.spec.ts b/src/compiler/transpiler.spec.ts index dc00ed9fcd..86b99a5f2c 100644 --- a/src/compiler/transpiler.spec.ts +++ b/src/compiler/transpiler.spec.ts @@ -89,7 +89,7 @@ describe('Transpiler', () => { }) it('should compile tsx file for jsx preserve', () => { - const fileName = `foo.tsx` + const fileName = 'foo.tsx' const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, @@ -113,7 +113,7 @@ describe('Transpiler', () => { }) it('should compile tsx file for other jsx options', () => { - const fileName = `foo.tsx` + const fileName = 'foo.tsx' const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, diff --git a/src/config/config-set.spec.ts b/src/config/config-set.spec.ts index 527416ac23..daced3bf96 100644 --- a/src/config/config-set.spec.ts +++ b/src/config/config-set.spec.ts @@ -1,9 +1,10 @@ +/* eslint-disable jest/no-mocks-import */ import { Transformer } from '@jest/transform' import { Config } from '@jest/types' import { testing } from 'bs-logger' import { readFileSync } from 'fs' import json5 = require('json5') -import { resolve } from 'path' // tslint:disable-next-line:no-duplicate-imports +import { resolve } from 'path' import * as ts from 'typescript' import * as _myModule from '..' @@ -83,7 +84,7 @@ describe('projectPackageJson', () => { ).toEqual(json5.parse(readFileSync(EXPECTED, 'utf8'))) }) - it(`should return value from root packageJson when provided value to tsJest config is undefined`, () => { + it('should return value from root packageJson when provided value to tsJest config is undefined', () => { expect( createConfigSet({ tsJestConfig: { packageJson: undefined }, @@ -92,7 +93,7 @@ describe('projectPackageJson', () => { ).toEqual('ts-jest') }) - it(`should return empty object when config file path doesn't exist and print loggings`, () => { + it("should return empty object when config file path doesn't exist and print loggings", () => { const logger = testing.createLoggerMock() expect( createConfigSet({ @@ -113,7 +114,7 @@ describe('projectPackageJson', () => { logger.target.clear() }) - it(`should return value from root packageJson when real path rootDir is the same as tsJest root`, () => { + it('should return value from root packageJson when real path rootDir is the same as tsJest root', () => { expect( createConfigSet({ resolve: null, @@ -198,13 +199,6 @@ describe('tsJest', () => { value: undefined, } expect(getTsJest().packageJson).toEqual(EXPECTED) - }) - - it('should be correct when packageJson is true', () => { - const EXPECTED = { - kind: 'file', - value: undefined, - } expect(getTsJest({ packageJson: true }).packageJson).toEqual(EXPECTED) }) @@ -1008,7 +1002,7 @@ describe('cacheKey', () => { cs.jsonValue.value = val // digest is mocked in src/__mocks__/index.ts expect(cs.cacheKey).toMatchInlineSnapshot( - `"{\\"digest\\":\\"a0d51ca854194df8191d0e65c0ca4730f510f332\\",\\"jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"projectDepVersions\\":{\\"dev\\":\\"1.2.5\\",\\"opt\\":\\"1.2.3\\",\\"peer\\":\\"1.2.4\\",\\"std\\":\\"1.2.6\\"},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"packageJson\\":{\\"kind\\":\\"file\\"},\\"transformers\\":[]},\\"tsconfig\\":{\\"declaration\\":false,\\"inlineSourceMap\\":false,\\"inlineSources\\":true,\\"module\\":1,\\"noEmit\\":false,\\"removeComments\\":false,\\"sourceMap\\":true,\\"target\\":1}}"`, + '"{\\"digest\\":\\"a0d51ca854194df8191d0e65c0ca4730f510f332\\",\\"jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"projectDepVersions\\":{\\"dev\\":\\"1.2.5\\",\\"opt\\":\\"1.2.3\\",\\"peer\\":\\"1.2.4\\",\\"std\\":\\"1.2.6\\"},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"packageJson\\":{\\"kind\\":\\"file\\"},\\"transformers\\":[]},\\"tsconfig\\":{\\"declaration\\":false,\\"inlineSourceMap\\":false,\\"inlineSources\\":true,\\"module\\":1,\\"noEmit\\":false,\\"removeComments\\":false,\\"sourceMap\\":true,\\"target\\":1}}"', ) }) }) // cacheKey @@ -1048,7 +1042,7 @@ describe('raiseDiagnostics', () => { it('should throw when warnOnly is false', () => { const { raiseDiagnostics } = createConfigSet({ createTsError, filterDiagnostics }) expect(() => raiseDiagnostics([])).not.toThrow() - expect(() => raiseDiagnostics([makeDiagnostic()])).toThrowErrorMatchingInlineSnapshot(`"[TS9999] foo"`) + expect(() => raiseDiagnostics([makeDiagnostic()])).toThrowErrorMatchingInlineSnapshot('"[TS9999] foo"') expect(() => raiseDiagnostics([makeDiagnostic({ category: ts.DiagnosticCategory.Message })])).not.toThrow() }) @@ -1071,13 +1065,13 @@ describe('raiseDiagnostics', () => { }) }) - describe(`diagnostics don't contain source file`, () => { + describe("diagnostics don't contain source file", () => { const makeDiagnostic = ({ messageText = 'foo', code = 9999, category = ts.DiagnosticCategory.Warning, }: Partial = {}): ts.Diagnostic => ({ messageText, code, category } as any) - it(`should throw when diagnostics contains file path and pathRegex config matches file path`, () => { + it('should throw when diagnostics contains file path and pathRegex config matches file path', () => { const { raiseDiagnostics } = createConfigSet({ createTsError, logger, @@ -1085,12 +1079,12 @@ describe('raiseDiagnostics', () => { }) logger.target.clear() expect(() => raiseDiagnostics([makeDiagnostic()], 'src/__mocks__/index.ts')).toThrowErrorMatchingInlineSnapshot( - `"[TS9999] foo"`, + '"[TS9999] foo"', ) - expect(logger.target.lines).toMatchInlineSnapshot(`Array []`) + expect(logger.target.lines).toMatchInlineSnapshot('Array []') }) - it(`should not throw when diagnostics contains file path and pathRegex config doesn't match file path`, () => { + it("should not throw when diagnostics contains file path and pathRegex config doesn't match file path", () => { const { raiseDiagnostics } = createConfigSet({ createTsError, logger, @@ -1098,7 +1092,7 @@ describe('raiseDiagnostics', () => { }) logger.target.clear() expect(() => raiseDiagnostics([makeDiagnostic()], 'src/__mocks__/index.ts')).not.toThrow() - expect(logger.target.lines).toMatchInlineSnapshot(`Array []`) + expect(logger.target.lines).toMatchInlineSnapshot('Array []') }) }) @@ -1115,7 +1109,7 @@ describe('raiseDiagnostics', () => { category = ts.DiagnosticCategory.Warning, file = program.getSourceFiles().find(sourceFile => sourceFile.fileName === 'src/__mocks__/index.ts'), }: Partial = {}): ts.Diagnostic => ({ messageText, code, category, file } as any) - it(`should not throw when pathRegex config doesn't match source file path`, () => { + it("should not throw when pathRegex config doesn't match source file path", () => { const { raiseDiagnostics } = createConfigSet({ createTsError, logger, @@ -1123,18 +1117,18 @@ describe('raiseDiagnostics', () => { }) logger.target.clear() expect(() => raiseDiagnostics([makeDiagnostic()])).not.toThrow() - expect(logger.target.lines).toMatchInlineSnapshot(`Array []`) + expect(logger.target.lines).toMatchInlineSnapshot('Array []') }) - it(`should throw when pathRegex config doesn't match source file path`, () => { + it("should throw when pathRegex config doesn't match source file path", () => { const { raiseDiagnostics } = createConfigSet({ createTsError, logger, tsJestConfig: { diagnostics: { pathRegex: 'src/__mocks__/index.ts' } }, }) logger.target.clear() - expect(() => raiseDiagnostics([makeDiagnostic()])).toThrowErrorMatchingInlineSnapshot(`"[TS9999] foo"`) - expect(logger.target.lines).toMatchInlineSnapshot(`Array []`) + expect(() => raiseDiagnostics([makeDiagnostic()])).toThrowErrorMatchingInlineSnapshot('"[TS9999] foo"') + expect(logger.target.lines).toMatchInlineSnapshot('Array []') }) }) }) // raiseDiagnostics diff --git a/src/config/config-set.ts b/src/config/config-set.ts index 7fafe414c3..50fb164cba 100644 --- a/src/config/config-set.ts +++ b/src/config/config-set.ts @@ -79,13 +79,11 @@ const enum DiagnosticCodes { ConfigModuleOption, } -const normalizeRegex = (pattern: string | RegExp | undefined): string | undefined => { - return pattern ? (typeof pattern === 'string' ? pattern : pattern.source) : undefined -} +const normalizeRegex = (pattern: string | RegExp | undefined): string | undefined => + pattern ? (typeof pattern === 'string' ? pattern : pattern.source) : undefined -const toDiagnosticCode = (code: any): number | undefined => { - return code ? parseInt(`${code}`.trim().replace(/^TS/, ''), 10) || undefined : undefined -} +const toDiagnosticCode = (code: any): number | undefined => + code ? parseInt(`${code}`.trim().replace(/^TS/, ''), 10) || undefined : undefined const toDiagnosticCodeList = (items: any, into: number[] = []): number[] => { if (!Array.isArray(items)) items = [items] @@ -191,13 +189,14 @@ export class ConfigSet { */ @Memoize() get testMatchPatterns(): (string | RegExp)[] { - const matchablePatterns = [...this.jest.testMatch, ...this.jest.testRegex].filter(pattern => { - /** - * jest config testRegex doesn't always deliver the correct RegExp object - * See https://github.com/facebook/jest/issues/9778 - */ - return pattern instanceof RegExp || typeof pattern === 'string' - }) + const matchablePatterns = [...this.jest.testMatch, ...this.jest.testRegex].filter( + pattern => + /** + * jest config testRegex doesn't always deliver the correct RegExp object + * See https://github.com/facebook/jest/issues/9778 + */ + pattern instanceof RegExp || typeof pattern === 'string', + ) if (!matchablePatterns.length) { matchablePatterns.push(...DEFAULT_JEST_TEST_MATCH) } @@ -394,7 +393,7 @@ export class ConfigSet { } = this if (babelConfig == null) { this.logger.debug('babel is disabled') - return + return undefined } let base: BabelConfig = { cwd: this.cwd } if (babelConfig.kind === 'file') { @@ -433,7 +432,7 @@ export class ConfigSet { @Memoize() get babelJestTransformer(): BabelJestTransformer | undefined { const { babel } = this - if (!babel) return + if (!babel) return undefined this.logger.debug('creating babel-jest transformer') return importer.babelJest(ImportReasons.BabelJest).createTransformer(babel) as BabelJestTransformer } @@ -495,7 +494,7 @@ export class ConfigSet { return false } - return ignoreCodes.indexOf(diagnostic.code) === -1 + return !ignoreCodes.includes(diagnostic.code) }) } } @@ -534,7 +533,7 @@ export class ConfigSet { * @internal */ @Memoize() - get createTsError(): (diagnostics: ReadonlyArray) => TSError { + get createTsError(): (diagnostics: readonly Diagnostic[]) => TSError { const { diagnostics: { pretty }, } = this.tsJest @@ -549,7 +548,7 @@ export class ConfigSet { getCanonicalFileName: path => path, } - return (diagnostics: ReadonlyArray) => { + return (diagnostics: readonly Diagnostic[]) => { const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost) const diagnosticCodes = diagnostics.map(x => x.code) return new TSError(diagnosticText, diagnosticCodes) @@ -563,7 +562,7 @@ export class ConfigSet { get tsCacheDir(): string | undefined { if (!this.jest.cache) { logger.debug('file caching disabled') - return + return undefined } const cacheSuffix = sha1( stringify({ @@ -635,6 +634,7 @@ export class ConfigSet { * Use by e2e, don't mark as internal */ @Memoize() + // eslint-disable-next-line class-methods-use-this get tsJestDigest(): string { return MY_DIGEST } @@ -704,6 +704,7 @@ export class ConfigSet { /** * Load TypeScript configuration. Returns the parsed TypeScript config and * any `tsConfig` options specified in ts-jest tsConfig + * * @internal */ readTsConfig( @@ -758,7 +759,7 @@ export class ConfigSet { } // check the module interoperability - const target = finalOptions.target! + const target = finalOptions.target // compute the default if not set const defaultModule = [ts.ScriptTarget.ES3, ts.ScriptTarget.ES5].includes(target) ? ts.ModuleKind.CommonJS diff --git a/src/index.spec.ts b/src/index.spec.ts index a853a439ed..4705cfefec 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,4 +1,3 @@ -// tslint:disable:max-line-length import { testing } from 'bs-logger' import * as tsJest from '.' diff --git a/src/index.ts b/src/index.ts index d9512569f6..9b427c9329 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,6 @@ export const createJestPreset = helperMoved('createJestPreset', createJestPreset /** @deprecated */ export const pathsToModuleNameMapper = helperMoved('pathsToModuleNameMapper', pathsToModuleNameMapperCore) -// tslint:disable-next-line:no-var-requires export const version: string = require('../package.json').version export const digest: string = readFileSync(resolve(__dirname, '..', '.ts-jest-digest'), 'utf8') @@ -61,12 +60,10 @@ const jestPreset = createJestPresetCore() * @internal */ // for tests -// tslint:disable-next-line:variable-name export const __singleton = () => transformer /** * @internal */ -// tslint:disable-next-line:variable-name export const __resetModule = () => (transformer = undefined as any) export { diff --git a/src/transformers/hoist-jest.spec.ts b/src/transformers/hoist-jest.spec.ts index 1f2cbd6cda..741352cbf7 100644 --- a/src/transformers/hoist-jest.spec.ts +++ b/src/transformers/hoist-jest.spec.ts @@ -37,9 +37,7 @@ const func2 = () => { } ` const logger = testing.createLoggerMock() -const createFactory = () => { - return hoist.factory({ logger, compilerModule: tsc } as any) -} +const createFactory = () => hoist.factory({ logger, compilerModule: tsc } as any) const transpile = (source: string) => tsc.transpileModule(source, { transformers: { before: [createFactory()] } }) describe('hoisting', () => { diff --git a/src/transformers/hoist-jest.ts b/src/transformers/hoist-jest.ts index 8fdd95747a..3dfedf3af2 100644 --- a/src/transformers/hoist-jest.ts +++ b/src/transformers/hoist-jest.ts @@ -1,4 +1,3 @@ -// tslint:disable:curly // take care of including ONLY TYPES here, for the rest use `ts` import { LogContexts, LogLevels } from 'bs-logger' import { @@ -31,6 +30,7 @@ export const version = 1 /** * The factory of hoisting transformer factory + * * @param cs Current jest configuration-set * @internal */ @@ -54,6 +54,7 @@ export function factory(cs: ConfigSet) { /** * Checks whether given node is a statement that we need to hoist + * * @param node The node to test */ function shouldHoistNode(node: Node): node is ExpressionStatement { @@ -62,6 +63,7 @@ export function factory(cs: ConfigSet) { /** * Create a source file visitor which will visit all nodes in a source file + * * @param ctx The typescript transformation context * @param sf The owning source file */ @@ -90,6 +92,7 @@ export function factory(cs: ConfigSet) { const exit = () => level-- /** * Adds a node to the list of nodes to be hoisted in the current level + * * @param node The node to hoist */ const hoist = (node: Statement) => { @@ -101,6 +104,7 @@ export function factory(cs: ConfigSet) { } /** * Our main visitor, which will be called recursively for each node in the source file's AST + * * @param node The node to be visited */ const visitor: Visitor = node => { @@ -136,11 +140,10 @@ export function factory(cs: ConfigSet) { } // returns the transformer factory - return (ctx: TransformationContext): Transformer => { - return logger.wrap( + return (ctx: TransformationContext): Transformer => + logger.wrap( { [LogContexts.logLevel]: LogLevels.debug, call: null }, 'visitSourceFileNode(): hoisting', (sf: SourceFile) => ts.visitNode(sf, createVisitor(ctx, sf)), ) - } } diff --git a/src/ts-jest-transformer.spec.ts b/src/ts-jest-transformer.spec.ts index 114afc158c..1a7e9b04b9 100644 --- a/src/ts-jest-transformer.spec.ts +++ b/src/ts-jest-transformer.spec.ts @@ -167,7 +167,7 @@ Array [ it('should return stringified version of file', () => { config.shouldStringifyContent.mockImplementation(() => true) - expect(process()).toMatchInlineSnapshot(`"module.exports=\\"export default \\\\\\"foo\\\\\\"\\""`) + expect(process()).toMatchInlineSnapshot('"module.exports=\\"export default \\\\\\"foo\\\\\\"\\""') }) it('should warn when trying to process js but allowJs is false', () => { diff --git a/src/ts-jest-transformer.ts b/src/ts-jest-transformer.ts index 9c1f49623e..df8204931a 100644 --- a/src/ts-jest-transformer.ts +++ b/src/ts-jest-transformer.ts @@ -78,7 +78,7 @@ export class TsJestTransformer implements Transformer { const jestConfigObj: Config.ProjectConfig = jestConfig // create the new record in the index - this.logger.info(`no matching config-set found, creating a new one`) + this.logger.info('no matching config-set found, creating a new one') const configSet = new ConfigSet(jestConfigObj, this.options, this.logger) TsJestTransformer._configSetsIndex.push({ diff --git a/src/types.ts b/src/types.ts index 8118577fdc..89d32844c5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -34,6 +34,7 @@ export interface TsJestGlobalOptions { * - `false`: do NOT use default config file * - `path/to/tsconfig.json`: path to a specific tsconfig file ( can be used) * - `{...}`: an object with inline compiler options + * * @default undefined uses the default tsconfig file * @alias tsconfig */ @@ -45,6 +46,7 @@ export interface TsJestGlobalOptions { * - `false`: do NOT use default config file * - `path/to/tsconfig.json`: path to a specific tsconfig file ( can be used) * - `{...}`: an object with inline compiler options + * * @default undefined uses the default tsconfig file * @alias tsConfig */ @@ -55,18 +57,21 @@ export interface TsJestGlobalOptions { * - `true` (or `undefined`, it's the default): use default package.json file * - `path/to/package.json`: path to a specific package.json file ( can be used) * - `{...}`: contents of a package.json + * * @default undefined uses the default package.json file */ packageJson?: boolean | string | object /** * Compiles files as isolated modules (disables some features and type-checking) + * * @default undefined (disabled) */ isolatedModules?: boolean /** * Compiler to use + * * @default 'typescript' */ compiler?: string @@ -81,6 +86,7 @@ export interface TsJestGlobalOptions { * - `true` (or `undefined`, it's the default): show all diagnostics * - `false`: hide diagnostics of all files (kind of useless) * - `{...}`: an inline object with fine grained settings + * * @default undefined shows all diagnostics */ diagnostics?: @@ -88,12 +94,14 @@ export interface TsJestGlobalOptions { | { /** * Enables colorful and pretty output of errors + * * @default undefined (enabled) */ pretty?: boolean /** * List of TypeScript diagnostic error codes to ignore * [here](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json). + * * @see https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json * @default [6059,18002,18003] */ @@ -105,6 +113,7 @@ export interface TsJestGlobalOptions { pathRegex?: RegExp | string /** * Logs TypeScript errors to stderr instead of throwing exceptions + * * @default undefined (disabled) */ warnOnly?: boolean @@ -116,6 +125,7 @@ export interface TsJestGlobalOptions { * - `true`: use babel using default babelrc file * - `path/to/.babelrc`: path to a babelrc file ( can be used) * - `{...}`: an object with inline babel options + * * @default undefined does NOT use babel */ babelConfig?: boolean | string | BabelConfig @@ -202,12 +212,14 @@ export interface TsCompiler { /** * Internal source output. + * * @internal */ export type SourceOutput = [string, string] /** * Track the project information. + * * @internal */ export interface MemoryCache { diff --git a/src/util/backports.spec.ts b/src/util/backports.spec.ts index 5bed89de4f..e2964e6cbd 100644 --- a/src/util/backports.spec.ts +++ b/src/util/backports.spec.ts @@ -20,11 +20,11 @@ describe('backportJestConfig', () => { set(original, oldPath, val) }) describe(`with "${oldPath}" set to ${inspect(val)}`, () => { - it(`should wran the user`, () => { + it('should wran the user', () => { backportJestConfig(logger, original) expect(logTarget.lines.warn).toMatchSnapshot() }) // should warn the user - it(`should have changed the config correctly`, () => { + it('should have changed the config correctly', () => { expect(original).toMatchSnapshot('before') expect(backportJestConfig(logger, original)).toMatchSnapshot('migrated') }) // should have changed the config diff --git a/src/util/backports.ts b/src/util/backports.ts index 66530daf25..4e625c429c 100644 --- a/src/util/backports.ts +++ b/src/util/backports.ts @@ -15,7 +15,7 @@ export const backportJestConfig = { @@ -120,7 +120,7 @@ export const backportTsJestDebugEnvVar = (logger: Logger) => { const shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '') delete process.env.TS_JEST_DEBUG if (shouldLog) { - process.env.TS_JEST_LOG = `ts-jest.log,stderr:warn` + process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn' } logger.warn( context, diff --git a/src/util/importer.spec.ts b/src/util/importer.spec.ts index a326005c71..556c8e63cd 100644 --- a/src/util/importer.spec.ts +++ b/src/util/importer.spec.ts @@ -1,4 +1,3 @@ -// tslint:disable:max-line-length import * as fakers from '../__helpers__/fakers' import { Importer, __requireModule } from './importer' diff --git a/src/util/importer.ts b/src/util/importer.ts index d5ee5bc0e5..63a230735c 100644 --- a/src/util/importer.ts +++ b/src/util/importer.ts @@ -59,7 +59,6 @@ export class Importer { let name: string let loaded: RequireResult | undefined const tries = [moduleName, ...fallbacks] - // tslint:disable-next-line:no-conditional-assignment while ((name = tries.shift() as string) !== undefined) { const req = requireWrapper(name) @@ -92,7 +91,9 @@ export class Importer { } tryTheseOr(moduleNames: [string, ...string[]] | string, missingResult: T, allowLoadError?: boolean): T + // eslint-disable-next-line no-dupe-class-members tryTheseOr(moduleNames: [string, ...string[]] | string, missingResult?: T, allowLoadError?: boolean): T | undefined + // eslint-disable-next-line no-dupe-class-members tryTheseOr(moduleNames: [string, ...string[]] | string, missingResult?: T, allowLoadError = false): T | undefined { const args: [string, ...string[]] = Array.isArray(moduleNames) ? moduleNames : [moduleNames] const result = this.tryThese(...args) @@ -132,9 +133,7 @@ export class Importer { installTip = [{ module: installTip, label: `install "${installTip}"` }] } const fix = installTip - .map(tip => { - return ` ${installTip.length === 1 ? '↳' : '•'} ${interpolate(Helps.FixMissingModule, tip)}` - }) + .map(tip => ` ${installTip.length === 1 ? '↳' : '•'} ${interpolate(Helps.FixMissingModule, tip)}`) .join('\n') throw new Error( diff --git a/src/util/json.ts b/src/util/json.ts index 956b5d4040..ce6b84ead7 100644 --- a/src/util/json.ts +++ b/src/util/json.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-redeclare */ import stableStringify = require('fast-json-stable-stringify') const UNDEFINED = 'undefined' @@ -38,7 +39,7 @@ export function normalize(input: string, { parse: parser = parse }: NormalizeOpt /** * @internal */ -// tslint:disable-next-line:no-namespace +// eslint-disable-next-line @typescript-eslint/no-namespace export namespace normalize { export const cache = new Map() } diff --git a/src/util/memoize.ts b/src/util/memoize.ts index f1d10997b2..852b7fc87b 100644 --- a/src/util/memoize.ts +++ b/src/util/memoize.ts @@ -39,7 +39,7 @@ function memoize( return function(this: any, ...args: any[]): any { const cache = ensureChildCache(this, namespace) const key = keyBuilder.apply(this, args) - if (cache.has(key)) return cache.get(key) as any // tslint:disable-line + if (cache.has(key)) return cache.get(key) const res: any = func.apply(this, args) cache.set(key, res) return res diff --git a/src/util/messages.ts b/src/util/messages.ts index 6bd9d2f2c9..648ccc9720 100644 --- a/src/util/messages.ts +++ b/src/util/messages.ts @@ -1,5 +1,3 @@ -// tslint:disable:max-line-length - /** * @internal */ @@ -53,5 +51,6 @@ export const enum ImportReasons { * @internal */ export function interpolate(msg: string, vars: Record = {}): string { + // eslint-disable-next-line no-useless-escape return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _)) } diff --git a/src/util/ts-error.ts b/src/util/ts-error.ts index 241d348d41..75c741ac88 100644 --- a/src/util/ts-error.ts +++ b/src/util/ts-error.ts @@ -13,6 +13,7 @@ export const INSPECT_CUSTOM = inspect.custom || 'inspect' /** * TypeScript diagnostics error. + * * @internal */ export class TSError extends BaseError { diff --git a/src/util/version-checkers.spec.ts b/src/util/version-checkers.spec.ts index 54c4eceb47..5ccc42d52f 100644 --- a/src/util/version-checkers.spec.ts +++ b/src/util/version-checkers.spec.ts @@ -1,4 +1,3 @@ -// tslint:disable:max-line-length import { mocked } from '../../utils' import { logTargetMock } from '../__helpers__/mocks' @@ -37,18 +36,18 @@ function describeChecker( pv.getPackageVersion.mockImplementation(name => (name === moduleName ? testVersion : undefined)) }) - it(`should log with warn()`, () => { + it('should log with warn()', () => { checker.warn() const warnings = logTarget.messages.warn expect(warnings).toHaveLength(1) expect(warnings[0].message).toMatch(testVersion ? 'has not been tested with ts-jest' : 'is not installed') }) - it(`should log only once with warn()`, () => { + it('should log only once with warn()', () => { checker.warn() checker.warn() expect(logTarget.messages.warn).toHaveLength(1) }) - it(`should throw with raise()`, () => { + it('should throw with raise()', () => { expect(checker.raise).toThrow() // adds another time as it should throw all the time even if already called expect(checker.raise).toThrow() @@ -61,11 +60,11 @@ function describeChecker( beforeEach(() => { pv.getPackageVersion.mockImplementation(name => (name === moduleName ? testVersion : undefined)) }) - it(`should not log with warn()`, () => { + it('should not log with warn()', () => { checker.warn() expect(logTarget.messages.warn).toHaveLength(0) }) - it(`should not throw with raise()`, () => { + it('should not throw with raise()', () => { expect(checker.raise).not.toThrow() }) }) // describe supported version diff --git a/src/util/version-checkers.ts b/src/util/version-checkers.ts index 83c6231df1..e168f385b0 100644 --- a/src/util/version-checkers.ts +++ b/src/util/version-checkers.ts @@ -28,7 +28,6 @@ export interface VersionChecker { /** * @internal */ -// tslint:disable-next-line:variable-name export const VersionCheckers = { jest: createVersionChecker('jest', ExpectedVersions.Jest), typescript: createVersionChecker('typescript', ExpectedVersions.TypeScript), diff --git a/tsconfig.json b/tsconfig.json index aac3940f77..e2ad22c216 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,11 +31,14 @@ "react" ] }, - "include": [], - "exclude": [ - "e2e/__cases__", - "e2e/__templates__", - "e2e/__workdir_synlink__", - "node_modules" - ] + "include": [ + "e2e/__helpers__", + "e2e/__serializers__", + "e2e/__tests__", + "scripts/", + "src/", + "utils/", + "presets", + "./*.js" + ], } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 7669513b00..0000000000 --- a/tslint.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "extends": [ - "tslint:recommended", - "tslint-config-prettier", - "tslint-plugin-prettier" - ], - "linterOptions": { - "exclude": [ - "package.json", - "dist/**/*", - "**/node_modules/**/*", - "e2e/__cases__/**/*" - ] - }, - "rules": { - "arrow-return-shorthand": [ - true - ], - "class-name": true, - "curly": [ - true, - "ignore-same-line" - ], - "encoding": true, - "interface-name": [ - false - ], - "interface-over-type-literal": true, - "max-classes-per-file": false, - "member-access": [ - true, - "no-public" - ], - "no-bitwise": false, - "no-boolean-literal-compare": true, - "no-duplicate-imports": true, - "no-empty": [ - true, - "allow-empty-catch" - ], - "no-empty-interface": false, - "no-for-in-array": true, - "no-inferrable-types": true, - "no-invalid-template-strings": true, - "no-return-await": true, - "no-shadowed-variable": false, - "no-string-throw": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "ordered-imports": [ - true, - { - "grouped-imports": true, - "import-sources-order": "lowercase-last", - "named-imports-order": "lowercase-last" - } - ], - "prefer-const": true, - "prefer-for-of": false, - "prefer-function-over-method": true, - "prefer-object-spread": true, - "prefer-readonly": true, - "prefer-template": true, - "prettier": true, - "semicolon": [ - true, - "never" - ], - "switch-default": true, - "variable-name": [ - true, - "allow-leading-underscore", - "ban-keywords", - "check-format", - "allow-pascal-case" - ] - } -}