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

Migrate tslint to eslint #1590

Merged
merged 21 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
808dfc5
feat(eslint): change config files to support eslint
tanettrimas May 1, 2020
f3a401b
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 1, 2020
b1eea13
feat(eslint): removed tslint.json file and updated ignorepattern
tanettrimas May 1, 2020
89a09b4
feat(eslint): fix small parsing error and several linting fixes
tanettrimas May 1, 2020
6846b8c
feat(eslint): rm unused func and made eslint warn nounused var
tanettrimas May 1, 2020
ec5bb01
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 1, 2020
892b59b
feat(eslint): added jest&jsdoc plugins and small linting fixes
tanettrimas May 2, 2020
83dfc17
feat(eslint): changed from off to warn on no-unbound
tanettrimas May 2, 2020
0bb98c1
build(deps-dev): bump jest from 25.5.3 to 25.5.4 (#1589)
dependabot-preview[bot] May 2, 2020
85e877a
feat(eslint): changes from review of kulshekhar/ts-jest#1590
tanettrimas May 2, 2020
6048e43
feat(eslint): changes from review of kulshekhar/ts-jest#1590
tanettrimas May 2, 2020
fd5a7d9
Merge remote-tracking branch 'upstream/master' into migrate-tslint-to…
tanettrimas May 2, 2020
1b8fca1
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 2, 2020
f37fad5
feat(eslint): changes according to pr review
tanettrimas May 2, 2020
54a8b76
feat(eslint): changes according to pr review
tanettrimas May 2, 2020
3d5225d
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 2, 2020
e2d7a8a
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 2, 2020
6b0cbbe
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 2, 2020
cdb6ebd
fix(eslint): re-ordered eslintignore and added matcher to logger.test
tanettrimas May 2, 2020
0467fb8
Merge branch 'migrate-tslint-to-eslint' of https://github.com/tanettr…
tanettrimas May 2, 2020
008572b
feat(eslint): added linebreak from code review
tanettrimas May 3, 2020
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
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ dist/
node_modules/
e2e/__cases__/
e2e/__workdir_synlink__/
e2e/__external-repos__
e2e/__templates__
e2e/__helpers__
e2e/__tests__
utils/
coverage/
docs/
*.config.js
tanettrimas marked this conversation as resolved.
Show resolved Hide resolved
236 changes: 224 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,243 @@
module.exports = {
ahnpnl marked this conversation as resolved.
Show resolved Hide resolved
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',
'plugin:jest/recommended',
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
ecmaVersion: 2020,
sourceType: 'module',
impliedStrict: true,
ecmaFeatures: {
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': [
'no-console': 'warn',
tanettrimas marked this conversation as resolved.
Show resolved Hide resolved
indent: 'off',
'linebreak-style': 'off',
quotes: ['warn', 'single'],
semi: ['warn', 'never'],
'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/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': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
tanettrimas marked this conversation as resolved.
Show resolved Hide resolved
'@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/indent': 'off',
'@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': 'warn',
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@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-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/quotes': 'off',
'@typescript-eslint/semi': ['warn', 'never'],
'@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: {},
}
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ tsconfig.json
.prettierrc
.travis.yml
tsconfig.build.json
tslint.json
.npmrc
.markdownlint.yaml
.cache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { main } from './main'

test('main', () => {
// tslint:disable-next-line:no-console
// eslint:disable-next-line:no-console
const mockLog = console.log = jest.fn()

main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { myLibraryFunction } from '../my-library'
export function main() {
const value = myLibraryFunction()

// tslint:disable-next-line:no-console
// eslint:disable-next-line:no-console
console.log(`You got foo: "${value.foo}" and bar: ${value.bar}`)
}

Expand Down
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/processed-file-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Config } from '@jest/types'

import ProcessedSource from '../../../src/__helpers__/processed-source'

// tslint:disable-next-line:no-default-export
// eslint:disable-next-line:no-default-export
export default class ProcessedFileIo extends ProcessedSource {
constructor(
cwd: string,
Expand Down
4 changes: 2 additions & 2 deletions e2e/__helpers__/test-case/run-descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import RunResult from './run-result'
import { run } from './runtime'
import { RunTestOptions, RunWithTemplateIteratorContext, RunWithTemplatesIterator, TestRunResultsMap } from './types'

// tslint:disable-next-line:no-default-export
// eslint:disable-next-line:no-default-export
export default class RunDescriptor {
protected _options: RunTestOptions
protected _sourcePackageJson: any
Expand Down Expand Up @@ -46,7 +46,7 @@ export default class RunDescriptor {
template: this.templateName,
})
if (logUnlessStatus != null && logUnlessStatus !== result.status) {
// tslint:disable-next-line:no-console
// eslint:disable-next-line:no-console
console.log(
'='.repeat(70),
'\n',
Expand Down
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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
// eslint:disable-next-line:no-default-export
export default class RunResult {
constructor(
readonly cwd: string,
Expand Down
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe.skip('__eval', () => {
eval(process.env.__TS_JEST_EVAL);
`

// tslint:disable-next-line:variable-name
// eslint:disable-next-line:variable-name
let __hooksSource: string
function hooksSourceWith(vars: Record<string, any>): string {
if (!__hooksSource) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface RunWithTemplateIteratorContext {
testLabel: string
}

// tslint:disable-next-line:interface-over-type-literal

export type TestRunResultsMap<T extends string = string> = { [key in T]: RunResult }

export interface PreparedTest {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__helpers__/test-case/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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 '?'
}

Expand Down
24 changes: 12 additions & 12 deletions e2e/__serializers__/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}