feat(build): replace tslint with eslint
This commit is contained in:
parent
d34c9763b0
commit
f50af4cfa2
|
@ -1,7 +1,16 @@
|
|||
version: "2"
|
||||
|
||||
checks:
|
||||
method-complexity:
|
||||
config:
|
||||
threshold: 6 # 5 is *just* too low and flags a number of otherwise readable methods
|
||||
method-lines:
|
||||
config:
|
||||
threshold: 30 # with object literals, lines are not a great measure
|
||||
|
||||
exclude_patterns:
|
||||
- CHANGELOG.md
|
||||
- config/
|
||||
- docs/api/
|
||||
- docs/dev/style.md
|
||||
- src/migration/
|
||||
|
@ -13,13 +22,14 @@ plugins:
|
|||
config:
|
||||
languages:
|
||||
typescript:
|
||||
mass_threshold: 120
|
||||
mass_threshold: 225
|
||||
eslint:
|
||||
enabled: true
|
||||
config:
|
||||
config: config/eslint.json
|
||||
fixme:
|
||||
enabled: true
|
||||
markdownlint:
|
||||
enabled: true
|
||||
shellcheck:
|
||||
enabled: true
|
||||
tslint:
|
||||
enabled: true
|
||||
config: config/tslint.cc.json
|
||||
|
|
|
@ -0,0 +1,389 @@
|
|||
{
|
||||
"env": {
|
||||
"es6": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"eslint-plugin-chai",
|
||||
"eslint-plugin-chai-expect",
|
||||
"eslint-plugin-chai-expect-keywords",
|
||||
"eslint-plugin-import",
|
||||
"eslint-plugin-mocha",
|
||||
"eslint-plugin-no-null",
|
||||
"eslint-plugin-sonarjs",
|
||||
"@typescript-eslint",
|
||||
"@typescript-eslint/tslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{
|
||||
"default": "generic"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"null": "Use 'undefined' instead of 'null'"
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/class-name-casing": "error",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/consistent-type-definitions": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": [
|
||||
"error",
|
||||
{
|
||||
"accessibility": "explicit",
|
||||
"overrides": {
|
||||
"constructors": "no-public"
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/indent": [
|
||||
"error",
|
||||
2,
|
||||
{
|
||||
"ObjectExpression": "first",
|
||||
"FunctionDeclaration": {
|
||||
"parameters": "first"
|
||||
},
|
||||
"FunctionExpression": {
|
||||
"parameters": "first"
|
||||
},
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/interface-name-prefix": "error",
|
||||
"@typescript-eslint/member-delimiter-style": [
|
||||
"error",
|
||||
{
|
||||
"multiline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": true
|
||||
},
|
||||
"singleline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/member-ordering": [
|
||||
"error",
|
||||
{
|
||||
"default": [
|
||||
"public-static-method",
|
||||
"public-static-field",
|
||||
"public-instance-field",
|
||||
"protected-instance-field",
|
||||
"public-constructor",
|
||||
"public-instance-method",
|
||||
"protected-instance-method"
|
||||
]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-empty-function": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"no-param-reassign": "error",
|
||||
"@typescript-eslint/no-parameter-properties": "error",
|
||||
"@typescript-eslint/no-this-alias": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
||||
"@typescript-eslint/no-use-before-declare": "off",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "error",
|
||||
"@typescript-eslint/prefer-function-type": "error",
|
||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||
"@typescript-eslint/quotes": [
|
||||
"error",
|
||||
"single",
|
||||
{
|
||||
"avoidEscape": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"@typescript-eslint/semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"space-in-parens": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"@typescript-eslint/strict-boolean-expressions": "error",
|
||||
"@typescript-eslint/triple-slash-reference": "error",
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"@typescript-eslint/unified-signatures": "error",
|
||||
"arrow-body-style": "error",
|
||||
"arrow-parens": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"camelcase": "error",
|
||||
"complexity": [
|
||||
"error",
|
||||
{
|
||||
"max": 12
|
||||
}
|
||||
],
|
||||
"constructor-super": "error",
|
||||
"curly": "error",
|
||||
"default-case": "error",
|
||||
"dot-notation": "error",
|
||||
"eol-last": "error",
|
||||
"eqeqeq": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"guard-for-in": "error",
|
||||
"id-blacklist": [
|
||||
"error",
|
||||
"any",
|
||||
"Number",
|
||||
"String",
|
||||
"Boolean",
|
||||
"Undefined"
|
||||
],
|
||||
"id-match": "error",
|
||||
"import/no-default-export": "error",
|
||||
"import/no-deprecated": "error",
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"import/no-internal-modules": "off",
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
"groups": [
|
||||
[
|
||||
"builtin",
|
||||
"external"
|
||||
],
|
||||
[
|
||||
"index",
|
||||
"parent",
|
||||
"sibling",
|
||||
"unknown"
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"max-classes-per-file": [
|
||||
"off",
|
||||
1
|
||||
],
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
"code": 180
|
||||
}
|
||||
],
|
||||
"max-lines": [
|
||||
"error",
|
||||
500
|
||||
],
|
||||
"new-parens": "error",
|
||||
"no-bitwise": "off",
|
||||
"no-caller": "error",
|
||||
"no-cond-assign": "error",
|
||||
"no-console": "error",
|
||||
"no-debugger": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-empty": "error",
|
||||
"no-eval": "error",
|
||||
"no-extra-bind": "error",
|
||||
"no-fallthrough": "off",
|
||||
"no-invalid-this": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-magic-numbers": [
|
||||
"error",
|
||||
{
|
||||
"ignore": [
|
||||
-3,
|
||||
-2,
|
||||
-1,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
20,
|
||||
30,
|
||||
40,
|
||||
50,
|
||||
60,
|
||||
70,
|
||||
80,
|
||||
90,
|
||||
100
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-multiple-empty-lines": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-null/no-null": "error",
|
||||
"no-plusplus": [
|
||||
"error",
|
||||
{
|
||||
"allowForLoopAfterthoughts": true
|
||||
}
|
||||
],
|
||||
"no-redeclare": "error",
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
"ForInStatement"
|
||||
],
|
||||
"no-return-await": "error",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": [
|
||||
"error",
|
||||
{
|
||||
"hoist": "all"
|
||||
}
|
||||
],
|
||||
"no-sparse-arrays": "error",
|
||||
"no-template-curly-in-string": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-underscore-dangle": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-useless-constructor": "error",
|
||||
"no-var": "error",
|
||||
"no-void": "error",
|
||||
"max-params": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"object-shorthand": "error",
|
||||
"one-var": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"prefer-const": "error",
|
||||
"prefer-object-spread": "error",
|
||||
"@typescript-eslint/prefer-readonly": "error",
|
||||
"quote-props": [
|
||||
"error",
|
||||
"consistent-as-needed"
|
||||
],
|
||||
"radix": "error",
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
{
|
||||
"anonymous": "never",
|
||||
"asyncArrow": "always",
|
||||
"named": "never"
|
||||
}
|
||||
],
|
||||
"spaced-comment": "error",
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "off",
|
||||
"sonarjs/max-switch-cases": "error",
|
||||
"sonarjs/cognitive-complexity": "error",
|
||||
"sonarjs/no-all-duplicated-branches": "error",
|
||||
"sonarjs/no-collapsible-if": "error",
|
||||
"sonarjs/no-collection-size-mischeck": "error",
|
||||
"sonarjs/no-duplicate-string": "error",
|
||||
"sonarjs/no-duplicated-branches": "error",
|
||||
"sonarjs/no-element-overwrite": "error",
|
||||
"sonarjs/no-identical-conditions": "error",
|
||||
"sonarjs/no-identical-expressions": "error",
|
||||
"sonarjs/no-identical-functions": "error",
|
||||
"sonarjs/no-inverted-boolean-check": "error",
|
||||
"sonarjs/no-redundant-boolean": "error",
|
||||
"sonarjs/no-redundant-jump": "error",
|
||||
"sonarjs/no-same-line-conditional": "error",
|
||||
"sonarjs/no-useless-catch": "error",
|
||||
"sonarjs/prefer-immediate-return": "error",
|
||||
"@typescript-eslint/tslint/config": [
|
||||
"error",
|
||||
{
|
||||
"rules": {
|
||||
"ban": [
|
||||
true,
|
||||
{
|
||||
"message": "use lodash isString",
|
||||
"name": [
|
||||
"util",
|
||||
"isString"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "use lodash isNil",
|
||||
"name": [
|
||||
"util",
|
||||
"isNullOrUndefined"
|
||||
]
|
||||
}
|
||||
],
|
||||
"import-spacing": true,
|
||||
"jsdoc-format": [
|
||||
true,
|
||||
"check-multiline-start"
|
||||
],
|
||||
"no-boolean-literal-compare": true,
|
||||
"no-dynamic-delete": true,
|
||||
"no-inferred-empty-object-type": true,
|
||||
"no-reference-import": true,
|
||||
"object-literal-sort-keys": true,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
"check-else",
|
||||
"check-finally",
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"prefer-switch": true,
|
||||
"strict-type-predicates": true,
|
||||
"trailing-comma": [
|
||||
true,
|
||||
{
|
||||
"esSpecCompliant": true,
|
||||
"multiline": {
|
||||
"arrays": "always",
|
||||
"functions": "never",
|
||||
"object": "always"
|
||||
},
|
||||
"singleline": "never"
|
||||
}
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-type-operator",
|
||||
"check-rest-spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
import { join, sep } from 'path';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import externals from 'rollup-plugin-node-externals';
|
||||
import { eslint } from 'rollup-plugin-eslint';
|
||||
import json from 'rollup-plugin-json';
|
||||
import multiEntry from 'rollup-plugin-multi-entry';
|
||||
import replace from 'rollup-plugin-replace';
|
||||
import externals from 'rollup-plugin-node-externals';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import tslint from 'rollup-plugin-tslint';
|
||||
import replace from 'rollup-plugin-replace';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import yaml from 'rollup-plugin-yaml';
|
||||
|
||||
|
@ -97,8 +97,8 @@ const bundle = {
|
|||
commonjs({
|
||||
namedExports,
|
||||
}),
|
||||
tslint({
|
||||
configuration: join('.', 'config', 'tslint.json'),
|
||||
eslint({
|
||||
configFile: join('.', 'config', 'eslint.json'),
|
||||
exclude: [
|
||||
join('node_modules', '**'),
|
||||
join('src', 'resource'),
|
||||
|
|
11
package.json
11
package.json
|
@ -29,12 +29,23 @@
|
|||
"@types/mocha": "5.2.7",
|
||||
"@types/sinon-chai": "3.2.3",
|
||||
"@types/source-map-support": "0.5.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
||||
"@typescript-eslint/eslint-plugin-tslint": "^2.6.1",
|
||||
"@typescript-eslint/parser": "^2.6.1",
|
||||
"chai": "4.2.0",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"eslint-plugin-chai": "^0.0.1",
|
||||
"eslint-plugin-chai-expect": "^2.0.1",
|
||||
"eslint-plugin-chai-expect-keywords": "^1.0.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-mocha": "^6.2.1",
|
||||
"eslint-plugin-no-null": "^1.0.2",
|
||||
"eslint-plugin-sonarjs": "^0.5.0",
|
||||
"mocha": "6.2.2",
|
||||
"nyc": "14.1.1",
|
||||
"rollup": "1.26.3",
|
||||
"rollup-plugin-commonjs": "10.1.0",
|
||||
"rollup-plugin-eslint": "^7.0.0",
|
||||
"rollup-plugin-json": "4.0.0",
|
||||
"rollup-plugin-multi-entry": "2.1.0",
|
||||
"rollup-plugin-node-externals": "2.1.2",
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
/* tslint:disable:no-default-import */
|
||||
import JSON_DATA from './resource/json.json';
|
||||
import YAML_DATA from './resource/yaml.yml';
|
||||
import { VERSION_INFO } from './version';
|
||||
|
||||
export async function main(argv: Array<string>): Promise<number> {
|
||||
// tslint:disable-next-line:no-console
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log('Hello World!', VERSION_INFO, JSON_DATA, YAML_DATA, argv);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ const STATUS_ERROR = 1;
|
|||
* This is the main entry-point to the program and the only file not included in the main bundle.
|
||||
*/
|
||||
main(process.argv).then((status) => process.exit(status)).catch((err: Error) => {
|
||||
/* tslint:disable-next-line:no-console */
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('uncaught error during main:', err);
|
||||
process.exit(STATUS_ERROR);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import { VERSION_INFO } from './version';
|
||||
|
||||
export default {
|
||||
VERSION_INFO,
|
||||
};
|
|
@ -1,15 +1,22 @@
|
|||
import { use } from 'chai';
|
||||
import chai from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import sinonChai from 'sinon-chai';
|
||||
import sourceMapSupport from 'source-map-support';
|
||||
|
||||
sourceMapSupport.install({
|
||||
environment: 'node',
|
||||
handleUncaughtExceptions: true,
|
||||
hookRequire: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* This will break the whole test run if any test leaks an unhandled rejection.
|
||||
*/
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('unhandled error during tests', reason);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
use(chaiAsPromised);
|
||||
use(sinonChai);
|
||||
chai.use(chaiAsPromised);
|
||||
chai.use(sinonChai);
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
import { AsyncHook, createHook } from 'async_hooks';
|
||||
|
||||
// this will pull Mocha internals out of the stacks
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
||||
const { stackTraceFilter } = require('mocha/lib/utils');
|
||||
const filterStack = stackTraceFilter();
|
||||
|
||||
type AsyncMochaTest = (this: Mocha.Context | void) => Promise<void>;
|
||||
type AsyncMochaSuite = (this: Mocha.Suite) => Promise<void>;
|
||||
|
||||
function isNil<T>(val: T | null | undefined): val is null | undefined {
|
||||
/* eslint-disable-next-line no-null/no-null */
|
||||
return val === null || val === undefined;
|
||||
}
|
||||
|
||||
export interface TrackedResource {
|
||||
source: string;
|
||||
triggerAsyncId: number;
|
||||
|
@ -18,10 +23,6 @@ function debugMode() {
|
|||
return Reflect.has(process.env, 'DEBUG');
|
||||
}
|
||||
|
||||
function isNil<T>(val: T | null | undefined): val is null | undefined {
|
||||
return val === null || val === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Async resource tracker using node's internal hooks.
|
||||
*
|
||||
|
@ -70,8 +71,8 @@ export class Tracker {
|
|||
this.hook.disable();
|
||||
}
|
||||
|
||||
/* eslint-disable no-console, no-invalid-this */
|
||||
public dump() {
|
||||
/* tslint:disable:no-console */
|
||||
console.error(`tracking ${this.resources.size} async resources`);
|
||||
this.resources.forEach((res, id) => {
|
||||
console.error(`${id}: ${res.type}`);
|
||||
|
@ -80,7 +81,6 @@ export class Tracker {
|
|||
console.error('\n');
|
||||
}
|
||||
});
|
||||
/* tslint:enable:no-console */
|
||||
}
|
||||
|
||||
public enable() {
|
||||
|
@ -114,7 +114,7 @@ export function describeLeaks(description: string, cb: AsyncMochaSuite): Mocha.S
|
|||
if (debugMode()) {
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
// tslint:disable-next-line:no-console
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.warn(msg);
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ export function describeLeaks(description: string, cb: AsyncMochaSuite): Mocha.S
|
|||
|
||||
const suite: PromiseLike<void> | undefined = cb.call(this);
|
||||
if (isNil(suite) || !Reflect.has(suite, 'then')) {
|
||||
// tslint:disable-next-line:no-console
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.error(`test suite '${description}' did not return a promise`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue