From fb84c834a5f90e9b6517b50a2fe852158b4dc071 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 00:54:31 +0100 Subject: [PATCH 01/21] test: basic setup for benchmark of restrict-plus-operands --- packages/benchmark/fixtures/.eslintrc.json | 15 +++++++ packages/benchmark/fixtures/src/test-file.ts | 1 + packages/benchmark/fixtures/tsconfig.json | 8 ++++ packages/benchmark/fixtures/tslint.json | 5 +++ packages/benchmark/package.json | 18 ++++++++ packages/benchmark/run.ts | 41 +++++++++++++++++ packages/benchmark/tsconfig.json | 9 ++++ yarn.lock | 46 ++++++++++++++++++-- 8 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 packages/benchmark/fixtures/.eslintrc.json create mode 100644 packages/benchmark/fixtures/src/test-file.ts create mode 100644 packages/benchmark/fixtures/tsconfig.json create mode 100644 packages/benchmark/fixtures/tslint.json create mode 100644 packages/benchmark/package.json create mode 100644 packages/benchmark/run.ts create mode 100644 packages/benchmark/tsconfig.json diff --git a/packages/benchmark/fixtures/.eslintrc.json b/packages/benchmark/fixtures/.eslintrc.json new file mode 100644 index 000000000000..f49b2f34094f --- /dev/null +++ b/packages/benchmark/fixtures/.eslintrc.json @@ -0,0 +1,15 @@ +{ + "root": true, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/restrict-plus-operands": "error" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json", + "sourceType": "module", + "ecmaFeatures": { + "jsx": false + } + } +} diff --git a/packages/benchmark/fixtures/src/test-file.ts b/packages/benchmark/fixtures/src/test-file.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures/src/test-file.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/fixtures/tsconfig.json b/packages/benchmark/fixtures/tsconfig.json new file mode 100644 index 000000000000..7643d3864a38 --- /dev/null +++ b/packages/benchmark/fixtures/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "declaration": true + }, + "include": [ + "src" + ] +} diff --git a/packages/benchmark/fixtures/tslint.json b/packages/benchmark/fixtures/tslint.json new file mode 100644 index 000000000000..8389b1de47a8 --- /dev/null +++ b/packages/benchmark/fixtures/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "restrict-plus-operands": true + } +} diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json new file mode 100644 index 000000000000..ff2643419bf3 --- /dev/null +++ b/packages/benchmark/package.json @@ -0,0 +1,18 @@ +{ + "name": "@typescript-eslint/benchmark", + "version": "1.1.0", + "private": true, + "scripts": { + "benchmark": "node -r ts-node/register run.ts" + }, + "devDependencies": { + "@types/benchmark": "^1.0.31", + "@types/eslint": "^4.16.5", + "@typescript-eslint/eslint-plugin": "1.1.0", + "@typescript-eslint/parser": "1.1.0", + "benchmark": "^2.1.4", + "eslint": "^5.12.1", + "ts-node": "^8.0.1", + "tslint": "^5.12.1" + } +} diff --git a/packages/benchmark/run.ts b/packages/benchmark/run.ts new file mode 100644 index 000000000000..9b20a82a53d9 --- /dev/null +++ b/packages/benchmark/run.ts @@ -0,0 +1,41 @@ +import Benchmark from 'benchmark'; +import { Linter, Configuration } from 'tslint'; +import eslint from 'eslint'; +import { join } from 'path'; +import { readFileSync } from 'fs'; + +const file = 'fixtures/src/test-file.ts'; +const fileContents = readFileSync(join(__dirname, file), 'utf8'); + +const suite = new Benchmark.Suite('eslint - tslint'); +suite + .add('tslint', function() { + const program = Linter.createProgram('fixtures/tsconfig.json'); + const linter = new Linter({ fix: false }, program); + const tslintConfig = Configuration.findConfiguration( + 'fixtures/tslint.json', + file + ).results; + linter.lint(file, fileContents, tslintConfig); + linter.getResult(); + }) + .add('eslint', function() { + const linter = new eslint.CLIEngine({ + configFile: 'fixtures/.eslintrc.json', + extensions: ['.js', '.ts'] + }); + linter.executeOnFiles([file]); + }) + // add listeners + .on('cycle', function(event: Benchmark.Event) { + console.log(String(event.target)); + }) + .on('complete', function(this: Benchmark.Suite) { + console.log('Fastest is ', this.filter('fastest').map((i: any) => i.name)); + }) + // run async + .run({ + async: true, + minSamples: 10000, + initCount: 10000 + }); diff --git a/packages/benchmark/tsconfig.json b/packages/benchmark/tsconfig.json new file mode 100644 index 000000000000..e9d6d01c11b3 --- /dev/null +++ b/packages/benchmark/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + }, + "include": [ + "src" + ] +} diff --git a/yarn.lock b/yarn.lock index e2d917cdc557..5869a71d9ef5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -789,6 +789,11 @@ resolved "https://registry.yarnpkg.com/@types/babel-code-frame/-/babel-code-frame-6.20.1.tgz#e79a40ea81435034df7b46b5e32e8ed638aea4dd" integrity sha1-55pA6oFDUDTfe0a14y6O1jiupN0= +"@types/benchmark@^1.0.31": + version "1.0.31" + resolved "https://registry.yarnpkg.com/@types/benchmark/-/benchmark-1.0.31.tgz#2dd3514e93396f362ba5551a7c9ff0da405c1d38" + integrity sha512-F6fVNOkGEkSdo/19yWYOwVKGvzbTeWkR/XQYBKtGBQ9oGRjBN9f/L4aJI4sDcVPJO58Y1CJZN8va9V2BhrZapA== + "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" @@ -1017,6 +1022,11 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +arg@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" + integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -1347,6 +1357,14 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +benchmark@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629" + integrity sha1-CfPeMckWQl1JjMLuVloOvzwqVik= + dependencies: + lodash "^4.17.4" + platform "^1.3.3" + bin-links@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/bin-links/-/bin-links-1.1.2.tgz#fb74bd54bae6b7befc6c6221f25322ac830d9757" @@ -2176,7 +2194,7 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diff@^3.2.0, diff@^3.5.0: +diff@^3.1.0, diff@^3.2.0, diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== @@ -4654,7 +4672,7 @@ make-dir@^1.0.0: dependencies: pify "^3.0.0" -make-error@1.x: +make-error@1.x, make-error@^1.1.1: version "1.3.5" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== @@ -5633,6 +5651,11 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +platform@^1.3.3: + version "1.3.5" + resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444" + integrity sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q== + please-upgrade-node@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz#ed320051dfcc5024fae696712c8288993595e8ac" @@ -6859,12 +6882,24 @@ ts-jest@^23.10.4: semver "^5.5" yargs-parser "10.x" +ts-node@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.1.tgz#cad98e8d50f0474f0d763ca8dc4c1bf8b7554ae2" + integrity sha512-zER3Js6Iotp31ghen6nKjgX75UOipwTWX9T5fAVmHaaYAizWhOes4uAsLmDC8H51UG5tHL8gNjoa/wLFjo7wtA== + dependencies: + arg "^4.1.0" + arrify "^1.0.0" + diff "^3.1.0" + make-error "^1.1.1" + source-map-support "^0.5.6" + yn "^2.0.0" + tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== -tslint@^5.11.0: +tslint@^5.0.0, tslint@^5.11.0: version "5.12.1" resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1" integrity sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw== @@ -7281,3 +7316,8 @@ yargs@^12.0.1: which-module "^2.0.0" y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" + +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + integrity sha1-5a2ryKz0CPY4X8dklWhMiOavaJo= From 16008330047746d73c298fc9469fc967437095f6 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 01:20:09 +0100 Subject: [PATCH 02/21] test: remove ts from benchmark and migrate code to js --- packages/benchmark/package.json | 3 +-- packages/benchmark/run.js | 46 +++++++++++++++++++++++++++++++++ packages/benchmark/run.ts | 41 ----------------------------- 3 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 packages/benchmark/run.js delete mode 100644 packages/benchmark/run.ts diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index ff2643419bf3..f9a5cc5acedb 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,7 +3,7 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark": "node -r ts-node/register run.ts" + "benchmark": "node dist/run.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", @@ -12,7 +12,6 @@ "@typescript-eslint/parser": "1.1.0", "benchmark": "^2.1.4", "eslint": "^5.12.1", - "ts-node": "^8.0.1", "tslint": "^5.12.1" } } diff --git a/packages/benchmark/run.js b/packages/benchmark/run.js new file mode 100644 index 000000000000..139ee0cd0ad7 --- /dev/null +++ b/packages/benchmark/run.js @@ -0,0 +1,46 @@ +const Benchmark = require('benchmark'); +const tslint = require('tslint'); +const eslint = require('eslint'); +const path = require('path'); +const fs = require('fs'); + +const file = 'fixtures/src/test-file.ts'; + +const suite = new Benchmark.Suite('eslint - tslint'); +suite + .add('tslint', function() { + const fileContents = fs.readFileSync(path.join(__dirname, file), 'utf8'); + const program = tslint.Linter.createProgram('fixtures/tsconfig.json'); + const linter = new tslint.Linter({ fix: false }, program); + const tslintConfig = tslint.Configuration.findConfiguration( + 'fixtures/tslint.json', + file + ).results; + linter.lint(file, fileContents, tslintConfig); + const result = linter.getResult(); + if (result.errorCount === 0) { + throw new Error('something went wrong') + } + }) + .add('eslint', function() { + const linter = new eslint.CLIEngine({ + configFile: 'fixtures/.eslintrc.json', + extensions: ['.js', '.ts'] + }); + const result = linter.executeOnFiles([file]); + if (result.errorCount === 0) { + throw new Error('something went wrong') + } + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + }) + .on('complete', function() { + console.log('Fastest is ', this.filter('fastest').map(i => i.name)); + }) + // run async + .run({ + minSamples: 10000, + initCount: 10000 + }); diff --git a/packages/benchmark/run.ts b/packages/benchmark/run.ts deleted file mode 100644 index 9b20a82a53d9..000000000000 --- a/packages/benchmark/run.ts +++ /dev/null @@ -1,41 +0,0 @@ -import Benchmark from 'benchmark'; -import { Linter, Configuration } from 'tslint'; -import eslint from 'eslint'; -import { join } from 'path'; -import { readFileSync } from 'fs'; - -const file = 'fixtures/src/test-file.ts'; -const fileContents = readFileSync(join(__dirname, file), 'utf8'); - -const suite = new Benchmark.Suite('eslint - tslint'); -suite - .add('tslint', function() { - const program = Linter.createProgram('fixtures/tsconfig.json'); - const linter = new Linter({ fix: false }, program); - const tslintConfig = Configuration.findConfiguration( - 'fixtures/tslint.json', - file - ).results; - linter.lint(file, fileContents, tslintConfig); - linter.getResult(); - }) - .add('eslint', function() { - const linter = new eslint.CLIEngine({ - configFile: 'fixtures/.eslintrc.json', - extensions: ['.js', '.ts'] - }); - linter.executeOnFiles([file]); - }) - // add listeners - .on('cycle', function(event: Benchmark.Event) { - console.log(String(event.target)); - }) - .on('complete', function(this: Benchmark.Suite) { - console.log('Fastest is ', this.filter('fastest').map((i: any) => i.name)); - }) - // run async - .run({ - async: true, - minSamples: 10000, - initCount: 10000 - }); From 84b2c1f088ad9cf39d4e18ec248de466ccd60595 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 02:28:06 +0100 Subject: [PATCH 03/21] test: add benchmark with multiple files --- .../fixtures/src/{test-file.ts => test1.ts} | 0 packages/benchmark/fixtures/src/test2.ts | 1 + packages/benchmark/fixtures/src/test3.ts | 1 + packages/benchmark/package.json | 3 +- packages/benchmark/run-multi.js | 51 +++++++++++++++++++ packages/benchmark/run.js | 2 +- 6 files changed, 56 insertions(+), 2 deletions(-) rename packages/benchmark/fixtures/src/{test-file.ts => test1.ts} (100%) create mode 100644 packages/benchmark/fixtures/src/test2.ts create mode 100644 packages/benchmark/fixtures/src/test3.ts create mode 100644 packages/benchmark/run-multi.js diff --git a/packages/benchmark/fixtures/src/test-file.ts b/packages/benchmark/fixtures/src/test1.ts similarity index 100% rename from packages/benchmark/fixtures/src/test-file.ts rename to packages/benchmark/fixtures/src/test1.ts diff --git a/packages/benchmark/fixtures/src/test2.ts b/packages/benchmark/fixtures/src/test2.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures/src/test2.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/fixtures/src/test3.ts b/packages/benchmark/fixtures/src/test3.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures/src/test3.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index f9a5cc5acedb..d55ecd634f4c 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,7 +3,8 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark": "node dist/run.js" + "benchmark": "node dist/run.js", + "benchmark-multi": "node dist/run-multi.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", diff --git a/packages/benchmark/run-multi.js b/packages/benchmark/run-multi.js new file mode 100644 index 000000000000..600386b347a1 --- /dev/null +++ b/packages/benchmark/run-multi.js @@ -0,0 +1,51 @@ +const Benchmark = require('benchmark'); +const tslint = require('tslint'); +const eslint = require('eslint'); +const path = require('path'); +const fs = require('fs'); + +const files = [ + 'fixtures/src/test1.ts', + 'fixtures/src/test2.ts', + 'fixtures/src/test3.ts' +]; + +const suite = new Benchmark.Suite('eslint - tslint'); +suite + .add('tslint', function() { + const program = tslint.Linter.createProgram('fixtures/tsconfig.json'); + const linter = new tslint.Linter({ fix: false }, program); + const tslintConfig = tslint.Configuration.findConfiguration( + 'fixtures/tslint.json', + files[0] + ).results; + for (const file of files) { + linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); + } + const result = linter.getResult(); + if (result.errorCount === 0) { + throw new Error('something went wrong') + } + }) + .add('eslint', function() { + const linter = new eslint.CLIEngine({ + configFile: 'fixtures/.eslintrc.json', + extensions: ['.js', '.ts'] + }); + const result = linter.executeOnFiles(files); + if (result.errorCount === 0) { + throw new Error('something went wrong') + } + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + }) + .on('complete', function() { + console.log('Fastest is ', this.filter('fastest').map(i => i.name)); + }) + // run async + .run({ + minSamples: 10000, + initCount: 10000 + }); diff --git a/packages/benchmark/run.js b/packages/benchmark/run.js index 139ee0cd0ad7..ecc7e06275a4 100644 --- a/packages/benchmark/run.js +++ b/packages/benchmark/run.js @@ -4,7 +4,7 @@ const eslint = require('eslint'); const path = require('path'); const fs = require('fs'); -const file = 'fixtures/src/test-file.ts'; +const file = 'fixtures/src/test1.ts'; const suite = new Benchmark.Suite('eslint - tslint'); suite From 657b085a4f5846d864445f2b9d1fc5f9cf417a93 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 03:06:19 +0100 Subject: [PATCH 04/21] test: small update --- packages/benchmark/package.json | 4 ++-- yarn.lock | 28 +++------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index d55ecd634f4c..cd032ec94a73 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,8 +3,8 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark": "node dist/run.js", - "benchmark-multi": "node dist/run-multi.js" + "benchmark": "node run.js", + "benchmark-multi": "node run-multi.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", diff --git a/yarn.lock b/yarn.lock index 5869a71d9ef5..3075b4754ba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1022,11 +1022,6 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -arg@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" - integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== - argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -2194,7 +2189,7 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diff@^3.1.0, diff@^3.2.0, diff@^3.5.0: +diff@^3.2.0, diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== @@ -4672,7 +4667,7 @@ make-dir@^1.0.0: dependencies: pify "^3.0.0" -make-error@1.x, make-error@^1.1.1: +make-error@1.x: version "1.3.5" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== @@ -6882,24 +6877,12 @@ ts-jest@^23.10.4: semver "^5.5" yargs-parser "10.x" -ts-node@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.1.tgz#cad98e8d50f0474f0d763ca8dc4c1bf8b7554ae2" - integrity sha512-zER3Js6Iotp31ghen6nKjgX75UOipwTWX9T5fAVmHaaYAizWhOes4uAsLmDC8H51UG5tHL8gNjoa/wLFjo7wtA== - dependencies: - arg "^4.1.0" - arrify "^1.0.0" - diff "^3.1.0" - make-error "^1.1.1" - source-map-support "^0.5.6" - yn "^2.0.0" - tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== -tslint@^5.0.0, tslint@^5.11.0: +tslint@^5.11.0, tslint@^5.12.1: version "5.12.1" resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1" integrity sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw== @@ -7316,8 +7299,3 @@ yargs@^12.0.1: which-module "^2.0.0" y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" - -yn@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" - integrity sha1-5a2ryKz0CPY4X8dklWhMiOavaJo= From 351f7ba719f3a912f03319a8d11081f4592bf27b Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 03:22:12 +0100 Subject: [PATCH 05/21] test: more tests --- packages/benchmark/fixtures2/.eslintrc.json | 14 +++++++ packages/benchmark/fixtures2/src/test1.ts | 1 + packages/benchmark/fixtures2/src/test2.ts | 1 + packages/benchmark/fixtures2/src/test3.ts | 1 + packages/benchmark/fixtures2/tslint.json | 5 +++ packages/benchmark/run-multi-simple.js | 44 +++++++++++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 packages/benchmark/fixtures2/.eslintrc.json create mode 100644 packages/benchmark/fixtures2/src/test1.ts create mode 100644 packages/benchmark/fixtures2/src/test2.ts create mode 100644 packages/benchmark/fixtures2/src/test3.ts create mode 100644 packages/benchmark/fixtures2/tslint.json create mode 100644 packages/benchmark/run-multi-simple.js diff --git a/packages/benchmark/fixtures2/.eslintrc.json b/packages/benchmark/fixtures2/.eslintrc.json new file mode 100644 index 000000000000..33f6970db353 --- /dev/null +++ b/packages/benchmark/fixtures2/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "root": true, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/no-empty-interface": "error" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "jsx": false + } + } +} diff --git a/packages/benchmark/fixtures2/src/test1.ts b/packages/benchmark/fixtures2/src/test1.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures2/src/test1.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/fixtures2/src/test2.ts b/packages/benchmark/fixtures2/src/test2.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures2/src/test2.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/fixtures2/src/test3.ts b/packages/benchmark/fixtures2/src/test3.ts new file mode 100644 index 000000000000..aa88a44282b9 --- /dev/null +++ b/packages/benchmark/fixtures2/src/test3.ts @@ -0,0 +1 @@ +const test = 'a' + 1 diff --git a/packages/benchmark/fixtures2/tslint.json b/packages/benchmark/fixtures2/tslint.json new file mode 100644 index 000000000000..366f38b35e96 --- /dev/null +++ b/packages/benchmark/fixtures2/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-empty-interface": true + } +} diff --git a/packages/benchmark/run-multi-simple.js b/packages/benchmark/run-multi-simple.js new file mode 100644 index 000000000000..0bc56481de3c --- /dev/null +++ b/packages/benchmark/run-multi-simple.js @@ -0,0 +1,44 @@ +const Benchmark = require('benchmark'); +const tslint = require('tslint'); +const eslint = require('eslint'); +const path = require('path'); +const fs = require('fs'); + +const files = [ + 'fixtures2/src/test1.ts', + 'fixtures2/src/test2.ts', + 'fixtures2/src/test3.ts' +]; + +const suite = new Benchmark.Suite('eslint - tslint'); +suite + .add('tslint', function() { + const linter = new tslint.Linter({ fix: false }); + const tslintConfig = tslint.Configuration.findConfiguration( + 'fixtures2/tslint.json', + files[0] + ).results; + for (const file of files) { + linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); + } + const result = linter.getResult(); + }) + .add('eslint', function() { + const linter = new eslint.CLIEngine({ + configFile: 'fixtures2/.eslintrc.json', + extensions: ['.js', '.ts'] + }); + const result = linter.executeOnFiles(files); + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + }) + .on('complete', function() { + console.log('Fastest is ', this.filter('fastest').map(i => i.name)); + }) + // run async + .run({ + minSamples: 10000, + initCount: 10000 + }); From a304aab6a6a9fa44183d7364cc492deabbd18b57 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 19:10:29 +0100 Subject: [PATCH 06/21] test(benchmark): simplify benchmarks --- .gitignore | 1 + packages/benchmark/benchmark.js | 114 ++++++++++++++++++ .../no-empty-interface}/.eslintrc.json | 0 .../{src => no-empty-interface}/test1.ts | 0 .../{src => no-empty-interface}/test2.ts | 0 .../{src => no-empty-interface}/test3.ts | 0 .../no-empty-interface}/tslint.json | 0 .../.eslintrc.json | 0 .../restrict-plus-operands}/test1.ts | 0 .../restrict-plus-operands}/test2.ts | 0 .../restrict-plus-operands}/test3.ts | 0 .../tsconfig.json | 2 +- .../{ => restrict-plus-operands}/tslint.json | 0 packages/benchmark/package.json | 3 +- packages/benchmark/run-multi-simple.js | 44 ------- packages/benchmark/run-multi.js | 51 -------- packages/benchmark/run.js | 46 ------- 17 files changed, 117 insertions(+), 144 deletions(-) create mode 100644 packages/benchmark/benchmark.js rename packages/benchmark/{fixtures2 => fixtures/no-empty-interface}/.eslintrc.json (100%) rename packages/benchmark/fixtures/{src => no-empty-interface}/test1.ts (100%) rename packages/benchmark/fixtures/{src => no-empty-interface}/test2.ts (100%) rename packages/benchmark/fixtures/{src => no-empty-interface}/test3.ts (100%) rename packages/benchmark/{fixtures2 => fixtures/no-empty-interface}/tslint.json (100%) rename packages/benchmark/fixtures/{ => restrict-plus-operands}/.eslintrc.json (100%) rename packages/benchmark/{fixtures2/src => fixtures/restrict-plus-operands}/test1.ts (100%) rename packages/benchmark/{fixtures2/src => fixtures/restrict-plus-operands}/test2.ts (100%) rename packages/benchmark/{fixtures2/src => fixtures/restrict-plus-operands}/test3.ts (100%) rename packages/benchmark/fixtures/{ => restrict-plus-operands}/tsconfig.json (88%) rename packages/benchmark/fixtures/{ => restrict-plus-operands}/tslint.json (100%) delete mode 100644 packages/benchmark/run-multi-simple.js delete mode 100644 packages/benchmark/run-multi.js delete mode 100644 packages/benchmark/run.js diff --git a/.gitignore b/.gitignore index 41847c7fd604..7b81c70ca57a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ pids *.pid *.seed *.pid.lock +package-lock.json # Directory for instrumented libs generated by jscoverage/JSCover lib-cov diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js new file mode 100644 index 000000000000..f6931dc3cbf1 --- /dev/null +++ b/packages/benchmark/benchmark.js @@ -0,0 +1,114 @@ +const Benchmark = require('benchmark'); +const tslint = require('tslint'); +const eslint = require('eslint'); +const path = require('path'); +const fs = require('fs'); + +function runTSLint(directory, files, useServices) { + const program = useServices + ? tslint.Linter.createProgram(`${directory}/tsconfig.json`) + : undefined + ; + const linter = new tslint.Linter({ fix: false }, program); + const tslintConfig = tslint.Configuration.findConfiguration( + `${directory}/tslint.json`, + files[0] + ).results; + for (const file of files) { + linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); + } + linter.getResult(); +} + +function runESLint(directory, files, useServices) { + const linter = new eslint.CLIEngine({ + configFile: `${directory}/.eslintrc.json`, + extensions: ['.js', '.ts'] + }); + linter.executeOnFiles(files); +} + +function createBenchmark(name, directory, files, useServices) { + return new Promise((resolve) => { + const suite = new Benchmark.Suite(name); + let message = ''; + suite + .add('tslint', function() { + runTSLint(directory, files, useServices) + }) + .add('eslint', function() { + runESLint(directory, files, useServices) + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)) + message += String(event.target) + '\n'; + }) + .on('complete', function() { + message += `Fastest is ${this.filter('fastest').map(i => i.name).join(', ')}\n` + resolve(message) + }) + .run({ + // async: true, + minSamples: 10000, + initCount: 10000 + }); + }) +} + +async function runAllBenchmarks (scenarios) { + let message = ''; + for (const scenario of scenarios) { + console.log(`${scenario.name}`) + message += `## ${scenario.name}\n\n`; + message += await createBenchmark( + scenario.name, + scenario.directory, + scenario.files, + scenario.useServices + ); + message += '\n------- \n\n'; + } + fs.writeFileSync('README.md', `# Benchmark TSLint - ESLint\n\n${message}`) +} + +runAllBenchmarks([ + { + name: 'Single File: restrict-plus-operands', + directory: 'fixtures/restrict-plus-operands/', + useServices: true, + files: [ + 'fixtures/restrict-plus-operands/test1.ts' + ] + }, + { + name: 'Multi File: restrict-plus-operands', + directory: 'fixtures/restrict-plus-operands/', + useServices: true, + files: [ + 'fixtures/restrict-plus-operands/test1.ts', + 'fixtures/restrict-plus-operands/test2.ts', + 'fixtures/restrict-plus-operands/test3.ts' + ] + }, + { + name: 'Single File: no-empty-interface', + directory: 'fixtures/no-empty-interface/', + useServices: false, + files: [ + 'fixtures/no-empty-interface/test1.ts' + ] + }, + { + name: 'Multi File: no-empty-interface', + directory: 'fixtures/no-empty-interface/', + useServices: false, + files: [ + 'fixtures/no-empty-interface/test1.ts', + 'fixtures/no-empty-interface/test2.ts', + 'fixtures/no-empty-interface/test3.ts' + ] + } +]).catch((e) => { + console.log(e) +}) diff --git a/packages/benchmark/fixtures2/.eslintrc.json b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json similarity index 100% rename from packages/benchmark/fixtures2/.eslintrc.json rename to packages/benchmark/fixtures/no-empty-interface/.eslintrc.json diff --git a/packages/benchmark/fixtures/src/test1.ts b/packages/benchmark/fixtures/no-empty-interface/test1.ts similarity index 100% rename from packages/benchmark/fixtures/src/test1.ts rename to packages/benchmark/fixtures/no-empty-interface/test1.ts diff --git a/packages/benchmark/fixtures/src/test2.ts b/packages/benchmark/fixtures/no-empty-interface/test2.ts similarity index 100% rename from packages/benchmark/fixtures/src/test2.ts rename to packages/benchmark/fixtures/no-empty-interface/test2.ts diff --git a/packages/benchmark/fixtures/src/test3.ts b/packages/benchmark/fixtures/no-empty-interface/test3.ts similarity index 100% rename from packages/benchmark/fixtures/src/test3.ts rename to packages/benchmark/fixtures/no-empty-interface/test3.ts diff --git a/packages/benchmark/fixtures2/tslint.json b/packages/benchmark/fixtures/no-empty-interface/tslint.json similarity index 100% rename from packages/benchmark/fixtures2/tslint.json rename to packages/benchmark/fixtures/no-empty-interface/tslint.json diff --git a/packages/benchmark/fixtures/.eslintrc.json b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json similarity index 100% rename from packages/benchmark/fixtures/.eslintrc.json rename to packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json diff --git a/packages/benchmark/fixtures2/src/test1.ts b/packages/benchmark/fixtures/restrict-plus-operands/test1.ts similarity index 100% rename from packages/benchmark/fixtures2/src/test1.ts rename to packages/benchmark/fixtures/restrict-plus-operands/test1.ts diff --git a/packages/benchmark/fixtures2/src/test2.ts b/packages/benchmark/fixtures/restrict-plus-operands/test2.ts similarity index 100% rename from packages/benchmark/fixtures2/src/test2.ts rename to packages/benchmark/fixtures/restrict-plus-operands/test2.ts diff --git a/packages/benchmark/fixtures2/src/test3.ts b/packages/benchmark/fixtures/restrict-plus-operands/test3.ts similarity index 100% rename from packages/benchmark/fixtures2/src/test3.ts rename to packages/benchmark/fixtures/restrict-plus-operands/test3.ts diff --git a/packages/benchmark/fixtures/tsconfig.json b/packages/benchmark/fixtures/restrict-plus-operands/tsconfig.json similarity index 88% rename from packages/benchmark/fixtures/tsconfig.json rename to packages/benchmark/fixtures/restrict-plus-operands/tsconfig.json index 7643d3864a38..3792da469e0e 100644 --- a/packages/benchmark/fixtures/tsconfig.json +++ b/packages/benchmark/fixtures/restrict-plus-operands/tsconfig.json @@ -3,6 +3,6 @@ "declaration": true }, "include": [ - "src" + "./*" ] } diff --git a/packages/benchmark/fixtures/tslint.json b/packages/benchmark/fixtures/restrict-plus-operands/tslint.json similarity index 100% rename from packages/benchmark/fixtures/tslint.json rename to packages/benchmark/fixtures/restrict-plus-operands/tslint.json diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index cd032ec94a73..30ba4e8712f1 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,8 +3,7 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark": "node run.js", - "benchmark-multi": "node run-multi.js" + "benchmark": "node benchmark.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", diff --git a/packages/benchmark/run-multi-simple.js b/packages/benchmark/run-multi-simple.js deleted file mode 100644 index 0bc56481de3c..000000000000 --- a/packages/benchmark/run-multi-simple.js +++ /dev/null @@ -1,44 +0,0 @@ -const Benchmark = require('benchmark'); -const tslint = require('tslint'); -const eslint = require('eslint'); -const path = require('path'); -const fs = require('fs'); - -const files = [ - 'fixtures2/src/test1.ts', - 'fixtures2/src/test2.ts', - 'fixtures2/src/test3.ts' -]; - -const suite = new Benchmark.Suite('eslint - tslint'); -suite - .add('tslint', function() { - const linter = new tslint.Linter({ fix: false }); - const tslintConfig = tslint.Configuration.findConfiguration( - 'fixtures2/tslint.json', - files[0] - ).results; - for (const file of files) { - linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); - } - const result = linter.getResult(); - }) - .add('eslint', function() { - const linter = new eslint.CLIEngine({ - configFile: 'fixtures2/.eslintrc.json', - extensions: ['.js', '.ts'] - }); - const result = linter.executeOnFiles(files); - }) - // add listeners - .on('cycle', function(event) { - console.log(String(event.target)); - }) - .on('complete', function() { - console.log('Fastest is ', this.filter('fastest').map(i => i.name)); - }) - // run async - .run({ - minSamples: 10000, - initCount: 10000 - }); diff --git a/packages/benchmark/run-multi.js b/packages/benchmark/run-multi.js deleted file mode 100644 index 600386b347a1..000000000000 --- a/packages/benchmark/run-multi.js +++ /dev/null @@ -1,51 +0,0 @@ -const Benchmark = require('benchmark'); -const tslint = require('tslint'); -const eslint = require('eslint'); -const path = require('path'); -const fs = require('fs'); - -const files = [ - 'fixtures/src/test1.ts', - 'fixtures/src/test2.ts', - 'fixtures/src/test3.ts' -]; - -const suite = new Benchmark.Suite('eslint - tslint'); -suite - .add('tslint', function() { - const program = tslint.Linter.createProgram('fixtures/tsconfig.json'); - const linter = new tslint.Linter({ fix: false }, program); - const tslintConfig = tslint.Configuration.findConfiguration( - 'fixtures/tslint.json', - files[0] - ).results; - for (const file of files) { - linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); - } - const result = linter.getResult(); - if (result.errorCount === 0) { - throw new Error('something went wrong') - } - }) - .add('eslint', function() { - const linter = new eslint.CLIEngine({ - configFile: 'fixtures/.eslintrc.json', - extensions: ['.js', '.ts'] - }); - const result = linter.executeOnFiles(files); - if (result.errorCount === 0) { - throw new Error('something went wrong') - } - }) - // add listeners - .on('cycle', function(event) { - console.log(String(event.target)); - }) - .on('complete', function() { - console.log('Fastest is ', this.filter('fastest').map(i => i.name)); - }) - // run async - .run({ - minSamples: 10000, - initCount: 10000 - }); diff --git a/packages/benchmark/run.js b/packages/benchmark/run.js deleted file mode 100644 index ecc7e06275a4..000000000000 --- a/packages/benchmark/run.js +++ /dev/null @@ -1,46 +0,0 @@ -const Benchmark = require('benchmark'); -const tslint = require('tslint'); -const eslint = require('eslint'); -const path = require('path'); -const fs = require('fs'); - -const file = 'fixtures/src/test1.ts'; - -const suite = new Benchmark.Suite('eslint - tslint'); -suite - .add('tslint', function() { - const fileContents = fs.readFileSync(path.join(__dirname, file), 'utf8'); - const program = tslint.Linter.createProgram('fixtures/tsconfig.json'); - const linter = new tslint.Linter({ fix: false }, program); - const tslintConfig = tslint.Configuration.findConfiguration( - 'fixtures/tslint.json', - file - ).results; - linter.lint(file, fileContents, tslintConfig); - const result = linter.getResult(); - if (result.errorCount === 0) { - throw new Error('something went wrong') - } - }) - .add('eslint', function() { - const linter = new eslint.CLIEngine({ - configFile: 'fixtures/.eslintrc.json', - extensions: ['.js', '.ts'] - }); - const result = linter.executeOnFiles([file]); - if (result.errorCount === 0) { - throw new Error('something went wrong') - } - }) - // add listeners - .on('cycle', function(event) { - console.log(String(event.target)); - }) - .on('complete', function() { - console.log('Fastest is ', this.filter('fastest').map(i => i.name)); - }) - // run async - .run({ - minSamples: 10000, - initCount: 10000 - }); From 25f7fe7af1cc94fd87d6fe7dc386b06938be2157 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 20:21:16 +0100 Subject: [PATCH 07/21] test(benchmark): generate readme, and fix linting issues --- packages/benchmark/README.md | 31 +++++++++ packages/benchmark/benchmark.js | 68 +++++++++++-------- .../fixtures/no-empty-interface/test1.ts | 2 +- .../fixtures/no-empty-interface/test2.ts | 2 +- .../fixtures/no-empty-interface/test3.ts | 2 +- 5 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 packages/benchmark/README.md diff --git a/packages/benchmark/README.md b/packages/benchmark/README.md new file mode 100644 index 000000000000..a058794c3b83 --- /dev/null +++ b/packages/benchmark/README.md @@ -0,0 +1,31 @@ +# Benchmark TSLint - ESLint + +## Single File: restrict-plus-operands + +tslint x 2.35 ops/sec ±7.05% (11 runs sampled) +eslint x 2.35 ops/sec ±7.40% (10 runs sampled) +Fastest is tslint, eslint + +------- + +## Multi File: restrict-plus-operands + +tslint x 2.56 ops/sec ±6.35% (11 runs sampled) +eslint x 0.82 ops/sec ±5.09% (7 runs sampled) +Fastest is tslint + +------- + +## Single File: no-empty-interface + +tslint x 1,665 ops/sec ±1.04% (90 runs sampled) +eslint x 393 ops/sec ±1.14% (86 runs sampled) +Fastest is tslint + +------- + +## Multi File: no-empty-interface + +tslint x 1,287 ops/sec ±1.02% (91 runs sampled) +eslint x 218 ops/sec ±1.12% (85 runs sampled) +Fastest is tslint diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index f6931dc3cbf1..cb5a180b10e5 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -7,17 +7,23 @@ const fs = require('fs'); function runTSLint(directory, files, useServices) { const program = useServices ? tslint.Linter.createProgram(`${directory}/tsconfig.json`) - : undefined - ; + : undefined; const linter = new tslint.Linter({ fix: false }, program); const tslintConfig = tslint.Configuration.findConfiguration( `${directory}/tslint.json`, files[0] ).results; for (const file of files) { - linter.lint(file, fs.readFileSync(path.join(__dirname, file), 'utf8'), tslintConfig); + linter.lint( + file, + fs.readFileSync(path.join(__dirname, file), 'utf8'), + tslintConfig + ); + } + const result = linter.getResult(); + if (result.errorCount === 0) { + throw new Error('something went wrong'); } - linter.getResult(); } function runESLint(directory, files, useServices) { @@ -25,51 +31,59 @@ function runESLint(directory, files, useServices) { configFile: `${directory}/.eslintrc.json`, extensions: ['.js', '.ts'] }); - linter.executeOnFiles(files); + const result = linter.executeOnFiles(files); + if (result.errorCount === 0) { + throw new Error('something went wrong'); + } } function createBenchmark(name, directory, files, useServices) { - return new Promise((resolve) => { + return new Promise(resolve => { const suite = new Benchmark.Suite(name); let message = ''; suite .add('tslint', function() { - runTSLint(directory, files, useServices) + runTSLint(directory, files, useServices); }) .add('eslint', function() { - runESLint(directory, files, useServices) + runESLint(directory, files, useServices); }) // add listeners .on('cycle', function(event) { - console.log(String(event.target)) + console.log(String(event.target)); message += String(event.target) + '\n'; }) .on('complete', function() { - message += `Fastest is ${this.filter('fastest').map(i => i.name).join(', ')}\n` - resolve(message) + message += `Fastest is ${this.filter('fastest') + .map(i => i.name) + .join(', ')}\n`; + resolve(message); }) .run({ // async: true, - minSamples: 10000, - initCount: 10000 + minSamples: 1000, + initCount: 1000 }); - }) + }); } -async function runAllBenchmarks (scenarios) { - let message = ''; +async function runAllBenchmarks(scenarios) { + const messages = []; for (const scenario of scenarios) { - console.log(`${scenario.name}`) - message += `## ${scenario.name}\n\n`; + console.log(`${scenario.name}`); + let message = `## ${scenario.name}\n\n`; message += await createBenchmark( scenario.name, scenario.directory, scenario.files, scenario.useServices ); - message += '\n------- \n\n'; + messages.push(message); } - fs.writeFileSync('README.md', `# Benchmark TSLint - ESLint\n\n${message}`) + fs.writeFileSync( + 'README.md', + `# Benchmark TSLint - ESLint\n\n${messages.join('\n-------\n\n')}` + ); } runAllBenchmarks([ @@ -77,9 +91,7 @@ runAllBenchmarks([ name: 'Single File: restrict-plus-operands', directory: 'fixtures/restrict-plus-operands/', useServices: true, - files: [ - 'fixtures/restrict-plus-operands/test1.ts' - ] + files: ['fixtures/restrict-plus-operands/test1.ts'] }, { name: 'Multi File: restrict-plus-operands', @@ -95,9 +107,7 @@ runAllBenchmarks([ name: 'Single File: no-empty-interface', directory: 'fixtures/no-empty-interface/', useServices: false, - files: [ - 'fixtures/no-empty-interface/test1.ts' - ] + files: ['fixtures/no-empty-interface/test1.ts'] }, { name: 'Multi File: no-empty-interface', @@ -109,6 +119,6 @@ runAllBenchmarks([ 'fixtures/no-empty-interface/test3.ts' ] } -]).catch((e) => { - console.log(e) -}) +]).catch(e => { + console.log(e); +}); diff --git a/packages/benchmark/fixtures/no-empty-interface/test1.ts b/packages/benchmark/fixtures/no-empty-interface/test1.ts index aa88a44282b9..fa0ebf3c5638 100644 --- a/packages/benchmark/fixtures/no-empty-interface/test1.ts +++ b/packages/benchmark/fixtures/no-empty-interface/test1.ts @@ -1 +1 @@ -const test = 'a' + 1 +interface Foo {} diff --git a/packages/benchmark/fixtures/no-empty-interface/test2.ts b/packages/benchmark/fixtures/no-empty-interface/test2.ts index aa88a44282b9..fa0ebf3c5638 100644 --- a/packages/benchmark/fixtures/no-empty-interface/test2.ts +++ b/packages/benchmark/fixtures/no-empty-interface/test2.ts @@ -1 +1 @@ -const test = 'a' + 1 +interface Foo {} diff --git a/packages/benchmark/fixtures/no-empty-interface/test3.ts b/packages/benchmark/fixtures/no-empty-interface/test3.ts index aa88a44282b9..fa0ebf3c5638 100644 --- a/packages/benchmark/fixtures/no-empty-interface/test3.ts +++ b/packages/benchmark/fixtures/no-empty-interface/test3.ts @@ -1 +1 @@ -const test = 'a' + 1 +interface Foo {} From 4c5285a016fbfa36b787f71ac552d814b6ccbcc8 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 20:28:39 +0100 Subject: [PATCH 08/21] test(benchmark): improve readme generation --- packages/benchmark/README.md | 27 ++++++++++++++++----------- packages/benchmark/benchmark.js | 5 +++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/benchmark/README.md b/packages/benchmark/README.md index a058794c3b83..047c0e5fbe9e 100644 --- a/packages/benchmark/README.md +++ b/packages/benchmark/README.md @@ -2,30 +2,35 @@ ## Single File: restrict-plus-operands -tslint x 2.35 ops/sec ±7.05% (11 runs sampled) -eslint x 2.35 ops/sec ±7.40% (10 runs sampled) +``` +tslint x 2.46 ops/sec ±8.81% (11 runs sampled) +eslint x 2.44 ops/sec ±8.02% (11 runs sampled) Fastest is tslint, eslint +``` -------- ## Multi File: restrict-plus-operands -tslint x 2.56 ops/sec ±6.35% (11 runs sampled) -eslint x 0.82 ops/sec ±5.09% (7 runs sampled) +``` +tslint x 2.60 ops/sec ±7.01% (11 runs sampled) +eslint x 0.82 ops/sec ±6.36% (7 runs sampled) Fastest is tslint +``` -------- ## Single File: no-empty-interface -tslint x 1,665 ops/sec ±1.04% (90 runs sampled) -eslint x 393 ops/sec ±1.14% (86 runs sampled) +``` +tslint x 1,679 ops/sec ±0.68% (90 runs sampled) +eslint x 389 ops/sec ±1.23% (89 runs sampled) Fastest is tslint +``` -------- ## Multi File: no-empty-interface -tslint x 1,287 ops/sec ±1.02% (91 runs sampled) -eslint x 218 ops/sec ±1.12% (85 runs sampled) +``` +tslint x 1,286 ops/sec ±1.01% (90 runs sampled) +eslint x 216 ops/sec ±1.10% (84 runs sampled) Fastest is tslint +``` diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index cb5a180b10e5..11f1b6e1dca3 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -40,7 +40,7 @@ function runESLint(directory, files, useServices) { function createBenchmark(name, directory, files, useServices) { return new Promise(resolve => { const suite = new Benchmark.Suite(name); - let message = ''; + let message = '```\n'; suite .add('tslint', function() { runTSLint(directory, files, useServices); @@ -57,6 +57,7 @@ function createBenchmark(name, directory, files, useServices) { message += `Fastest is ${this.filter('fastest') .map(i => i.name) .join(', ')}\n`; + message += '```\n'; resolve(message); }) .run({ @@ -82,7 +83,7 @@ async function runAllBenchmarks(scenarios) { } fs.writeFileSync( 'README.md', - `# Benchmark TSLint - ESLint\n\n${messages.join('\n-------\n\n')}` + `# Benchmark TSLint - ESLint\n\n${messages.join('\n\n')}` ); } From 31478c081905b514844824cf0c97e0708a45f168 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 20:32:05 +0100 Subject: [PATCH 09/21] test: add fixtures to prettierignore --- .prettierignore | 5 ++--- packages/benchmark/README.md | 3 --- packages/benchmark/benchmark.js | 2 +- packages/benchmark/tsconfig.json | 6 ++---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.prettierignore b/.prettierignore index 49b3a61e6d8f..d96a940857f3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,8 +1,7 @@ -**/tests/fixtures/**/* +**/fixtures/**/* **/dist **/coverage **/shared-fixtures -**/tests/integration/fixtures/**/* **/lib/configs/recommended.json **/.vscode -**/.nyc_output \ No newline at end of file +**/.nyc_output diff --git a/packages/benchmark/README.md b/packages/benchmark/README.md index 047c0e5fbe9e..8d1e83eccc27 100644 --- a/packages/benchmark/README.md +++ b/packages/benchmark/README.md @@ -8,7 +8,6 @@ eslint x 2.44 ops/sec ±8.02% (11 runs sampled) Fastest is tslint, eslint ``` - ## Multi File: restrict-plus-operands ``` @@ -17,7 +16,6 @@ eslint x 0.82 ops/sec ±6.36% (7 runs sampled) Fastest is tslint ``` - ## Single File: no-empty-interface ``` @@ -26,7 +24,6 @@ eslint x 389 ops/sec ±1.23% (89 runs sampled) Fastest is tslint ``` - ## Multi File: no-empty-interface ``` diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index 11f1b6e1dca3..9b937bba07af 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -83,7 +83,7 @@ async function runAllBenchmarks(scenarios) { } fs.writeFileSync( 'README.md', - `# Benchmark TSLint - ESLint\n\n${messages.join('\n\n')}` + `# Benchmark TSLint - ESLint\n\n${messages.join('\n')}` ); } diff --git a/packages/benchmark/tsconfig.json b/packages/benchmark/tsconfig.json index e9d6d01c11b3..38e6103e9c6e 100644 --- a/packages/benchmark/tsconfig.json +++ b/packages/benchmark/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "declaration": true, + "declaration": true }, - "include": [ - "src" - ] + "include": ["src"] } From 8a721e2c9a461f2f2ba529851577280cb0517a1d Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 25 Jan 2019 03:17:03 +0100 Subject: [PATCH 10/21] test: add benchmark for parsers (ts-estree vs parse) --- packages/benchmark/PARSERS.md | 9 ++ packages/benchmark/README.md | 33 ------ packages/benchmark/RULES.md | 33 ++++++ packages/benchmark/benchmark.js | 5 +- packages/benchmark/package.json | 7 +- packages/benchmark/parsers.js | 90 ++++++++++++++++ yarn.lock | 176 ++++++++++++++++++++++++++++++-- 7 files changed, 309 insertions(+), 44 deletions(-) create mode 100644 packages/benchmark/PARSERS.md delete mode 100644 packages/benchmark/README.md create mode 100644 packages/benchmark/RULES.md create mode 100644 packages/benchmark/parsers.js diff --git a/packages/benchmark/PARSERS.md b/packages/benchmark/PARSERS.md new file mode 100644 index 000000000000..8f6e255bf3de --- /dev/null +++ b/packages/benchmark/PARSERS.md @@ -0,0 +1,9 @@ +# Benchmark TSEstree - Parser + +## Single File + +``` +ts-estree x 20,086 ops/sec ±1.66% (83 runs sampled) +ts-parser x 8,736 ops/sec ±2.30% (83 runs sampled) +Fastest is ts-estree +``` diff --git a/packages/benchmark/README.md b/packages/benchmark/README.md deleted file mode 100644 index 8d1e83eccc27..000000000000 --- a/packages/benchmark/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Benchmark TSLint - ESLint - -## Single File: restrict-plus-operands - -``` -tslint x 2.46 ops/sec ±8.81% (11 runs sampled) -eslint x 2.44 ops/sec ±8.02% (11 runs sampled) -Fastest is tslint, eslint -``` - -## Multi File: restrict-plus-operands - -``` -tslint x 2.60 ops/sec ±7.01% (11 runs sampled) -eslint x 0.82 ops/sec ±6.36% (7 runs sampled) -Fastest is tslint -``` - -## Single File: no-empty-interface - -``` -tslint x 1,679 ops/sec ±0.68% (90 runs sampled) -eslint x 389 ops/sec ±1.23% (89 runs sampled) -Fastest is tslint -``` - -## Multi File: no-empty-interface - -``` -tslint x 1,286 ops/sec ±1.01% (90 runs sampled) -eslint x 216 ops/sec ±1.10% (84 runs sampled) -Fastest is tslint -``` diff --git a/packages/benchmark/RULES.md b/packages/benchmark/RULES.md new file mode 100644 index 000000000000..db409d367233 --- /dev/null +++ b/packages/benchmark/RULES.md @@ -0,0 +1,33 @@ +# Benchmark TSLint - ESLint + +## Single File: restrict-plus-operands + +``` +tslint x 2.42 ops/sec ±8.40% (11 runs sampled) +eslint x 2.47 ops/sec ±6.46% (11 runs sampled) +Fastest is eslint, tslint +``` + +## Multi File: restrict-plus-operands + +``` +tslint x 2.54 ops/sec ±7.02% (11 runs sampled) +eslint x 0.80 ops/sec ±3.96% (7 runs sampled) +Fastest is tslint +``` + +## Single File: no-empty-interface + +``` +tslint x 1,647 ops/sec ±1.04% (91 runs sampled) +eslint x 385 ops/sec ±1.13% (88 runs sampled) +Fastest is tslint +``` + +## Multi File: no-empty-interface + +``` +tslint x 1,269 ops/sec ±0.91% (90 runs sampled) +eslint x 212 ops/sec ±1.13% (83 runs sampled) +Fastest is tslint +``` diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index 9b937bba07af..d9876fa3709c 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -53,6 +53,9 @@ function createBenchmark(name, directory, files, useServices) { console.log(String(event.target)); message += String(event.target) + '\n'; }) + .on('error', function(e) { + console.log(e); + }) .on('complete', function() { message += `Fastest is ${this.filter('fastest') .map(i => i.name) @@ -82,7 +85,7 @@ async function runAllBenchmarks(scenarios) { messages.push(message); } fs.writeFileSync( - 'README.md', + 'RULES.md', `# Benchmark TSLint - ESLint\n\n${messages.join('\n')}` ); } diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 30ba4e8712f1..0b9227518002 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,15 +3,18 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark": "node benchmark.js" + "benchmark:rules": "node benchmark.js", + "benchmark:parsers": "node parsers.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", "@types/eslint": "^4.16.5", "@typescript-eslint/eslint-plugin": "1.1.0", "@typescript-eslint/parser": "1.1.0", + "@typescript-eslint/typescript-estree": "1.1.0", "benchmark": "^2.1.4", "eslint": "^5.12.1", - "tslint": "^5.12.1" + "tslint": "^5.12.1", + "microtime": "^2.1.8" } } diff --git a/packages/benchmark/parsers.js b/packages/benchmark/parsers.js new file mode 100644 index 000000000000..10de2b2a5341 --- /dev/null +++ b/packages/benchmark/parsers.js @@ -0,0 +1,90 @@ +const Benchmark = require('benchmark'); +const fs = require('fs'); +const tsEstree = require('@typescript-eslint/typescript-estree'); +const tsParser = require('@typescript-eslint/parser'); + +function runTSESTree(directory, files) { + for (const file of files) { + const result = tsEstree.parse(file, { + comment: true, + tokens: true + }); + if (result.type !== 'Program') { + throw new Error('something went wrong'); + } + } +} + +function runTSParser(directory, files) { + for (const file of files) { + const result = tsParser.parse(file, { + comment: true, + tokens: true + }); + if (result.type !== 'Program') { + throw new Error('something went wrong'); + } + } +} + +function createBenchmark(name, directory, files) { + return new Promise(resolve => { + const suite = new Benchmark.Suite(name); + let message = '```\n'; + suite + .add('ts-estree', function() { + runTSESTree(directory, files); + }) + .add('ts-parser', function tsParser() { + runTSParser(directory, files); + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + message += String(event.target) + '\n'; + }) + .on('error', function(e) { + console.log(e); + }) + .on('complete', function() { + message += `Fastest is ${this.filter('fastest') + .map(i => i.name) + .join(', ')}\n`; + message += '```\n'; + resolve(message); + }) + .run({ + async: true, + minSamples: 100000, + initCount: 100000 + }); + }); +} + +async function runAllBenchmarks(scenarios) { + const messages = []; + for (const scenario of scenarios) { + console.log(`${scenario.name}`); + let message = `## ${scenario.name}\n\n`; + message += await createBenchmark( + scenario.name, + scenario.directory, + scenario.files + ); + messages.push(message); + } + fs.writeFileSync( + 'PARSERS.md', + `# Benchmark TSEstree - Parser\n\n${messages.join('\n')}` + ); +} + +runAllBenchmarks([ + { + name: 'Single File', + directory: 'fixtures/restrict-plus-operands/', + files: ['fixtures/restrict-plus-operands/test1.ts'] + } +]).catch(e => { + console.log(e); +}); diff --git a/yarn.lock b/yarn.lock index 3075b4754ba6..d2e813e48d26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1371,6 +1371,19 @@ bin-links@^1.1.2: graceful-fs "^4.1.11" write-file-atomic "^2.3.0" +bindings@1.3.x: + version "1.3.1" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.1.tgz#21fc7c6d67c18516ec5aaa2815b145ff77b26ea5" + integrity sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew== + +bl@^1.0.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" + integrity sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA== + dependencies: + readable-stream "^2.3.5" + safe-buffer "^5.1.1" + block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" @@ -1442,6 +1455,24 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" +buffer-alloc-unsafe@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" + integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg== + +buffer-alloc@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" + integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow== + dependencies: + buffer-alloc-unsafe "^1.1.0" + buffer-fill "^1.0.0" + +buffer-fill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" + integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= + buffer-from@1.x, buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1621,7 +1652,7 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== -chownr@^1.1.1: +chownr@^1.0.1, chownr@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== @@ -2091,6 +2122,13 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= + dependencies: + mimic-response "^1.0.0" + dedent@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" @@ -2171,7 +2209,7 @@ detect-indent@^5.0.0: resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50= -detect-libc@^1.0.2: +detect-libc@^1.0.2, detect-libc@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= @@ -2581,6 +2619,11 @@ expand-range@^1.8.1: dependencies: fill-range "^2.1.0" +expand-template@^1.0.2: + version "1.1.1" + resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.1.tgz#981f188c0c3a87d2e28f559bc541426ff94f21dd" + integrity sha512-cebqLtV8KOZfw0UI8TEFWxtczxxC1jvyUvx6H4fyp1K1FN7A4Q+uggVUlOsI1K8AGU0rwOGqP8nCapdrw8CYQg== + expect@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/expect/-/expect-23.6.0.tgz#1e0c8d3ba9a581c87bd71fb9bc8862d443425f98" @@ -2840,6 +2883,11 @@ from2@^2.1.0: inherits "^2.0.1" readable-stream "^2.0.0" +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== + fs-extra@^7.0.0: version "7.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" @@ -3046,6 +3094,11 @@ gitconfiglocal@^1.0.0: dependencies: ini "^1.3.2" +github-from-package@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" + integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= + glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" @@ -4847,6 +4900,15 @@ micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: snapdragon "^0.8.1" to-regex "^3.0.2" +microtime@^2.1.8: + version "2.1.8" + resolved "https://registry.yarnpkg.com/microtime/-/microtime-2.1.8.tgz#b43c4c5ab13e527e173370d0306d9e0a4bbf410d" + integrity sha1-tDxMWrE+Un4XM3DQMG2eCku/QQ0= + dependencies: + bindings "1.3.x" + nan "2.10.x" + prebuild-install "^2.1.0" + mime-db@~1.37.0: version "1.37.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" @@ -4864,6 +4926,11 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== +mimic-response@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -4996,6 +5063,11 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" +nan@2.10.x: + version "2.10.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" + integrity sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA== + nan@^2.9.2: version "2.12.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" @@ -5037,6 +5109,13 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +node-abi@^2.2.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.5.1.tgz#bb17288fc3b2f68fea0ed9897c66979fd754ed47" + integrity sha512-oDbFc7vCFx0RWWCweTer3hFm1u+e60N5FtGnmRV6QqvgATGFH/XRR6vqWIeBVosCYCqt6YdIr2L0exLZuEdVcQ== + dependencies: + semver "^5.4.1" + node-fetch-npm@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz#7258c9046182dca345b4208eda918daf33697ff7" @@ -5095,6 +5174,11 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" +noop-logger@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" + integrity sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI= + "nopt@2 || 3": version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -5227,7 +5311,7 @@ npm-which@^3.0.1: npm-path "^2.0.2" which "^1.2.10" -"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.2, npmlog@^4.1.2: +"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.1, npmlog@^4.0.2, npmlog@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -5347,7 +5431,7 @@ ora@^3.0.0: strip-ansi "^4.0.0" wcwidth "^1.0.1" -os-homedir@^1.0.0: +os-homedir@^1.0.0, os-homedir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= @@ -5673,6 +5757,27 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +prebuild-install@^2.1.0: + version "2.5.3" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.3.tgz#9f65f242782d370296353710e9bc843490c19f69" + integrity sha512-/rI36cN2g7vDQnKWN8Uzupi++KjyqS9iS+/fpwG4Ea8d0Pip0PQ5bshUNzVwt+/D2MRfhVAplYMMvWLqWrCF/g== + dependencies: + detect-libc "^1.0.3" + expand-template "^1.0.2" + github-from-package "0.0.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + node-abi "^2.2.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + os-homedir "^1.0.1" + pump "^2.0.1" + rc "^1.1.6" + simple-get "^2.7.0" + tar-fs "^1.13.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -5761,7 +5866,15 @@ psl@^1.1.24, psl@^1.1.28: resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184" integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw== -pump@^2.0.0: +pump@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + integrity sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^2.0.0, pump@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== @@ -5820,7 +5933,7 @@ randomatic@^3.0.0: kind-of "^6.0.0" math-random "^1.0.1" -rc@^1.2.7: +rc@^1.1.6, rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -5909,7 +6022,7 @@ read@1, read@~1.0.1: dependencies: mute-stream "~0.0.4" -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@~2.3.6: +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== @@ -6284,6 +6397,20 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +simple-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" + integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY= + +simple-get@^2.7.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" + integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== + dependencies: + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" + sisteransi@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-0.1.1.tgz#5431447d5f7d1675aac667ccd0b865a4994cb3ce" @@ -6676,6 +6803,29 @@ table@^5.0.2: slice-ansi "2.0.0" string-width "^2.1.1" +tar-fs@^1.13.0: + version "1.16.3" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" + integrity sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw== + dependencies: + chownr "^1.0.1" + mkdirp "^0.5.1" + pump "^1.0.0" + tar-stream "^1.1.2" + +tar-stream@^1.1.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555" + integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A== + dependencies: + bl "^1.0.0" + buffer-alloc "^1.2.0" + end-of-stream "^1.0.0" + fs-constants "^1.0.0" + readable-stream "^2.3.0" + to-buffer "^1.1.1" + xtend "^4.0.0" + tar@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" @@ -6780,6 +6930,11 @@ tmpl@1.0.x: resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE= +to-buffer@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" + integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== + to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" @@ -7119,6 +7274,11 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= +which-pm-runs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" + integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= + which@1, which@^1.2.10, which@^1.2.12, which@^1.2.9, which@^1.3.0, which@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -7217,7 +7377,7 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== -xtend@~4.0.1: +xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= From 53d43b849e5f0b71812ded81d1f9f613a6eda662 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 26 Jan 2019 01:49:20 +0100 Subject: [PATCH 11/21] test: update benchmarks --- packages/benchmark/PARSERS.md | 4 +-- packages/benchmark/RULES.md | 18 +++++------ packages/benchmark/benchmark.js | 56 +++++++-------------------------- packages/benchmark/eslint.js | 56 +++++++++++++++++++++++++++++++++ packages/benchmark/package.json | 4 +-- packages/benchmark/tslint.js | 31 ++++++++++++++++++ 6 files changed, 112 insertions(+), 57 deletions(-) create mode 100644 packages/benchmark/eslint.js create mode 100644 packages/benchmark/tslint.js diff --git a/packages/benchmark/PARSERS.md b/packages/benchmark/PARSERS.md index 8f6e255bf3de..aad37b87a1c0 100644 --- a/packages/benchmark/PARSERS.md +++ b/packages/benchmark/PARSERS.md @@ -3,7 +3,7 @@ ## Single File ``` -ts-estree x 20,086 ops/sec ±1.66% (83 runs sampled) -ts-parser x 8,736 ops/sec ±2.30% (83 runs sampled) +ts-estree x 18,114 ops/sec ±14.31% (76 runs sampled) +ts-parser x 8,969 ops/sec ±2.70% (81 runs sampled) Fastest is ts-estree ``` diff --git a/packages/benchmark/RULES.md b/packages/benchmark/RULES.md index db409d367233..44f367cbaabc 100644 --- a/packages/benchmark/RULES.md +++ b/packages/benchmark/RULES.md @@ -3,31 +3,31 @@ ## Single File: restrict-plus-operands ``` -tslint x 2.42 ops/sec ±8.40% (11 runs sampled) -eslint x 2.47 ops/sec ±6.46% (11 runs sampled) +tslint x 2.67 ops/sec ±7.60% (11 runs sampled) +eslint x 2.70 ops/sec ±6.17% (11 runs sampled) Fastest is eslint, tslint ``` ## Multi File: restrict-plus-operands ``` -tslint x 2.54 ops/sec ±7.02% (11 runs sampled) -eslint x 0.80 ops/sec ±3.96% (7 runs sampled) +tslint x 2.87 ops/sec ±3.78% (12 runs sampled) +eslint x 0.94 ops/sec ±6.10% (7 runs sampled) Fastest is tslint ``` ## Single File: no-empty-interface ``` -tslint x 1,647 ops/sec ±1.04% (91 runs sampled) -eslint x 385 ops/sec ±1.13% (88 runs sampled) -Fastest is tslint +tslint x 1,408 ops/sec ±0.62% (91 runs sampled) +eslint x 2,660 ops/sec ±3.96% (79 runs sampled) +Fastest is eslint ``` ## Multi File: no-empty-interface ``` -tslint x 1,269 ops/sec ±0.91% (90 runs sampled) -eslint x 212 ops/sec ±1.13% (83 runs sampled) +tslint x 1,100 ops/sec ±1.08% (91 runs sampled) +eslint x 1,073 ops/sec ±3.46% (85 runs sampled) Fastest is tslint ``` diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index d9876fa3709c..bfde45cb5afd 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -1,52 +1,24 @@ const Benchmark = require('benchmark'); -const tslint = require('tslint'); -const eslint = require('eslint'); -const path = require('path'); const fs = require('fs'); -function runTSLint(directory, files, useServices) { - const program = useServices - ? tslint.Linter.createProgram(`${directory}/tsconfig.json`) - : undefined; - const linter = new tslint.Linter({ fix: false }, program); - const tslintConfig = tslint.Configuration.findConfiguration( - `${directory}/tslint.json`, - files[0] - ).results; - for (const file of files) { - linter.lint( - file, - fs.readFileSync(path.join(__dirname, file), 'utf8'), - tslintConfig - ); - } - const result = linter.getResult(); - if (result.errorCount === 0) { - throw new Error('something went wrong'); - } -} - -function runESLint(directory, files, useServices) { - const linter = new eslint.CLIEngine({ - configFile: `${directory}/.eslintrc.json`, - extensions: ['.js', '.ts'] - }); - const result = linter.executeOnFiles(files); - if (result.errorCount === 0) { - throw new Error('something went wrong'); - } -} - function createBenchmark(name, directory, files, useServices) { return new Promise(resolve => { - const suite = new Benchmark.Suite(name); + const suite = new Benchmark.Suite(name, { + async: true + }); let message = '```\n'; suite .add('tslint', function() { - runTSLint(directory, files, useServices); + const result = require('./tslint').runTSLint(directory, files, useServices); + if (typeof result !== 'string') { + throw new Error('something went wrong'); + } }) .add('eslint', function() { - runESLint(directory, files, useServices); + const result = require('./eslint').runESLint(directory, files, useServices); + if (typeof result !== 'string') { + throw new Error('something went wrong'); + } }) // add listeners .on('cycle', function(event) { @@ -63,11 +35,7 @@ function createBenchmark(name, directory, files, useServices) { message += '```\n'; resolve(message); }) - .run({ - // async: true, - minSamples: 1000, - initCount: 1000 - }); + .run(); }); } diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint.js new file mode 100644 index 000000000000..a5e2db13f5da --- /dev/null +++ b/packages/benchmark/eslint.js @@ -0,0 +1,56 @@ +const eslint = require('eslint'); +const path = require('path'); +const fs = require('fs'); + +// exports.runESLint = function(directory, files, useServices) { +// const linter = new eslint.CLIEngine({ +// files: files, +// configFile: `${directory}.eslintrc.json`, +// extensions: ['.js', '.ts'] +// }); +// const results = []; +// for (const file of files) { +// results.push( +// linter.executeOnText( +// fs.readFileSync(path.join(__dirname, file), 'utf8'), +// file, +// true +// ) +// ); +// } +// +// if (results[0].errorCount === 0) { +// throw new Error('something went wrong'); +// } +// if ( +// results[0].results[0].messages[0].message !== +// 'An empty interface is equivalent to `{}`.' +// ) { +// throw new Error('something went wrong'); +// } +// }; + +exports.runESLint = function(directory, files, useServices) { + const linter = new eslint.Linter(); + linter.defineRule( + '@typescript-eslint/no-empty-interface', + require('@typescript-eslint/eslint-plugin/lib/rules/no-empty-interface') + ); + linter.defineRule( + '@typescript-eslint/restrict-plus-operands', + require('@typescript-eslint/eslint-plugin/lib/rules/restrict-plus-operands') + ); + let result; + for (const file of files) { + result = linter.verify( + fs.readFileSync(path.join(__dirname, file), 'utf8'), + require(`./${directory}.eslintrc.json`), + file + ) + } + if (result.length === 0) { + throw new Error('something went wrong'); + } + + return result[0].message; +}; diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 0b9227518002..8f530f7aa1d7 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -3,8 +3,8 @@ "version": "1.1.0", "private": true, "scripts": { - "benchmark:rules": "node benchmark.js", - "benchmark:parsers": "node parsers.js" + "benchmark:rules": "node --allow-natives-syntax benchmark.js", + "benchmark:parsers": "node --allow-natives-syntax parsers.js" }, "devDependencies": { "@types/benchmark": "^1.0.31", diff --git a/packages/benchmark/tslint.js b/packages/benchmark/tslint.js new file mode 100644 index 000000000000..c4d0e6d4c654 --- /dev/null +++ b/packages/benchmark/tslint.js @@ -0,0 +1,31 @@ +const tslint = require('tslint'); +const path = require('path'); +const fs = require('fs'); + +exports.runTSLint = function(directory, files, useServices) { + const program = useServices + ? tslint.Linter.createProgram(`${directory}tsconfig.json`) + : undefined; + const linter = new tslint.Linter( + { + fix: false, + formatter: 'json' + }, + program + ); + const tslintConfig = tslint.Configuration.loadConfigurationFromPath( + `./${directory}tslint.json` + ); + for (const file of files) { + linter.lint( + file, + fs.readFileSync(path.join(__dirname, file), 'utf8'), + tslintConfig + ); + } + const result = linter.getResult(); + if (result.errorCount === 0) { + throw new Error('something went wrong'); + } + return result.failures[0].failure +}; From 9d0422462db434a579b187b02ec3fc7c5392421f Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 26 Jan 2019 01:54:15 +0100 Subject: [PATCH 12/21] test: update benchmarks --- packages/benchmark/RULES.md | 18 +++++++++--------- packages/benchmark/eslint.js | 9 +++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/benchmark/RULES.md b/packages/benchmark/RULES.md index 44f367cbaabc..836ae58b546d 100644 --- a/packages/benchmark/RULES.md +++ b/packages/benchmark/RULES.md @@ -3,31 +3,31 @@ ## Single File: restrict-plus-operands ``` -tslint x 2.67 ops/sec ±7.60% (11 runs sampled) -eslint x 2.70 ops/sec ±6.17% (11 runs sampled) -Fastest is eslint, tslint +tslint x 2.72 ops/sec ±9.39% (12 runs sampled) +eslint x 2.48 ops/sec ±2.95% (11 runs sampled) +Fastest is tslint ``` ## Multi File: restrict-plus-operands ``` -tslint x 2.87 ops/sec ±3.78% (12 runs sampled) -eslint x 0.94 ops/sec ±6.10% (7 runs sampled) +tslint x 2.78 ops/sec ±3.98% (12 runs sampled) +eslint x 0.91 ops/sec ±6.49% (7 runs sampled) Fastest is tslint ``` ## Single File: no-empty-interface ``` -tslint x 1,408 ops/sec ±0.62% (91 runs sampled) -eslint x 2,660 ops/sec ±3.96% (79 runs sampled) +tslint x 1,757 ops/sec ±0.91% (91 runs sampled) +eslint x 2,295 ops/sec ±3.73% (76 runs sampled) Fastest is eslint ``` ## Multi File: no-empty-interface ``` -tslint x 1,100 ops/sec ±1.08% (91 runs sampled) -eslint x 1,073 ops/sec ±3.46% (85 runs sampled) +tslint x 1,359 ops/sec ±0.79% (91 runs sampled) +eslint x 885 ops/sec ±2.86% (83 runs sampled) Fastest is tslint ``` diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint.js index a5e2db13f5da..5143820c7851 100644 --- a/packages/benchmark/eslint.js +++ b/packages/benchmark/eslint.js @@ -44,9 +44,14 @@ exports.runESLint = function(directory, files, useServices) { for (const file of files) { result = linter.verify( fs.readFileSync(path.join(__dirname, file), 'utf8'), - require(`./${directory}.eslintrc.json`), + JSON.parse( + fs.readFileSync( + path.join(__dirname, `./${directory}.eslintrc.json`), + 'utf8' + ) + ), file - ) + ); } if (result.length === 0) { throw new Error('something went wrong'); From 1cd1b44f13e67c7ce1613ad5b41a49d76ccf832a Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 26 Jan 2019 02:44:08 +0100 Subject: [PATCH 13/21] chore: fix linting --- packages/benchmark/benchmark.js | 12 ++++++++++-- packages/benchmark/tslint.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index bfde45cb5afd..1668651201eb 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -9,13 +9,21 @@ function createBenchmark(name, directory, files, useServices) { let message = '```\n'; suite .add('tslint', function() { - const result = require('./tslint').runTSLint(directory, files, useServices); + const result = require('./tslint').runTSLint( + directory, + files, + useServices + ); if (typeof result !== 'string') { throw new Error('something went wrong'); } }) .add('eslint', function() { - const result = require('./eslint').runESLint(directory, files, useServices); + const result = require('./eslint').runESLint( + directory, + files, + useServices + ); if (typeof result !== 'string') { throw new Error('something went wrong'); } diff --git a/packages/benchmark/tslint.js b/packages/benchmark/tslint.js index c4d0e6d4c654..aff8f3c5fe0d 100644 --- a/packages/benchmark/tslint.js +++ b/packages/benchmark/tslint.js @@ -27,5 +27,5 @@ exports.runTSLint = function(directory, files, useServices) { if (result.errorCount === 0) { throw new Error('something went wrong'); } - return result.failures[0].failure + return result.failures[0].failure; }; From 0449862d65a3d3be6d1ad799aae9cc9d1be62252 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 26 Jan 2019 04:06:16 +0100 Subject: [PATCH 14/21] chore: remove dead dependencies --- packages/benchmark/package.json | 3 +- yarn.lock | 176 ++------------------------------ 2 files changed, 9 insertions(+), 170 deletions(-) diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 8f530f7aa1d7..0bd22128a6f7 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -14,7 +14,6 @@ "@typescript-eslint/typescript-estree": "1.1.0", "benchmark": "^2.1.4", "eslint": "^5.12.1", - "tslint": "^5.12.1", - "microtime": "^2.1.8" + "tslint": "^5.12.1" } } diff --git a/yarn.lock b/yarn.lock index d2e813e48d26..3075b4754ba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1371,19 +1371,6 @@ bin-links@^1.1.2: graceful-fs "^4.1.11" write-file-atomic "^2.3.0" -bindings@1.3.x: - version "1.3.1" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.1.tgz#21fc7c6d67c18516ec5aaa2815b145ff77b26ea5" - integrity sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew== - -bl@^1.0.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" - integrity sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" @@ -1455,24 +1442,6 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" -buffer-alloc-unsafe@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" - integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg== - -buffer-alloc@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" - integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow== - dependencies: - buffer-alloc-unsafe "^1.1.0" - buffer-fill "^1.0.0" - -buffer-fill@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" - integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= - buffer-from@1.x, buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1652,7 +1621,7 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== -chownr@^1.0.1, chownr@^1.1.1: +chownr@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== @@ -2122,13 +2091,6 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= - dependencies: - mimic-response "^1.0.0" - dedent@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" @@ -2209,7 +2171,7 @@ detect-indent@^5.0.0: resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50= -detect-libc@^1.0.2, detect-libc@^1.0.3: +detect-libc@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= @@ -2619,11 +2581,6 @@ expand-range@^1.8.1: dependencies: fill-range "^2.1.0" -expand-template@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.1.tgz#981f188c0c3a87d2e28f559bc541426ff94f21dd" - integrity sha512-cebqLtV8KOZfw0UI8TEFWxtczxxC1jvyUvx6H4fyp1K1FN7A4Q+uggVUlOsI1K8AGU0rwOGqP8nCapdrw8CYQg== - expect@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/expect/-/expect-23.6.0.tgz#1e0c8d3ba9a581c87bd71fb9bc8862d443425f98" @@ -2883,11 +2840,6 @@ from2@^2.1.0: inherits "^2.0.1" readable-stream "^2.0.0" -fs-constants@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" - integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== - fs-extra@^7.0.0: version "7.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" @@ -3094,11 +3046,6 @@ gitconfiglocal@^1.0.0: dependencies: ini "^1.3.2" -github-from-package@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" - integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= - glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" @@ -4900,15 +4847,6 @@ micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: snapdragon "^0.8.1" to-regex "^3.0.2" -microtime@^2.1.8: - version "2.1.8" - resolved "https://registry.yarnpkg.com/microtime/-/microtime-2.1.8.tgz#b43c4c5ab13e527e173370d0306d9e0a4bbf410d" - integrity sha1-tDxMWrE+Un4XM3DQMG2eCku/QQ0= - dependencies: - bindings "1.3.x" - nan "2.10.x" - prebuild-install "^2.1.0" - mime-db@~1.37.0: version "1.37.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" @@ -4926,11 +4864,6 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== -mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -5063,11 +4996,6 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nan@2.10.x: - version "2.10.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" - integrity sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA== - nan@^2.9.2: version "2.12.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" @@ -5109,13 +5037,6 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== -node-abi@^2.2.0: - version "2.5.1" - resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.5.1.tgz#bb17288fc3b2f68fea0ed9897c66979fd754ed47" - integrity sha512-oDbFc7vCFx0RWWCweTer3hFm1u+e60N5FtGnmRV6QqvgATGFH/XRR6vqWIeBVosCYCqt6YdIr2L0exLZuEdVcQ== - dependencies: - semver "^5.4.1" - node-fetch-npm@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz#7258c9046182dca345b4208eda918daf33697ff7" @@ -5174,11 +5095,6 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" -noop-logger@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" - integrity sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI= - "nopt@2 || 3": version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -5311,7 +5227,7 @@ npm-which@^3.0.1: npm-path "^2.0.2" which "^1.2.10" -"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.1, npmlog@^4.0.2, npmlog@^4.1.2: +"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.2, npmlog@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -5431,7 +5347,7 @@ ora@^3.0.0: strip-ansi "^4.0.0" wcwidth "^1.0.1" -os-homedir@^1.0.0, os-homedir@^1.0.1: +os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= @@ -5757,27 +5673,6 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= -prebuild-install@^2.1.0: - version "2.5.3" - resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.3.tgz#9f65f242782d370296353710e9bc843490c19f69" - integrity sha512-/rI36cN2g7vDQnKWN8Uzupi++KjyqS9iS+/fpwG4Ea8d0Pip0PQ5bshUNzVwt+/D2MRfhVAplYMMvWLqWrCF/g== - dependencies: - detect-libc "^1.0.3" - expand-template "^1.0.2" - github-from-package "0.0.0" - minimist "^1.2.0" - mkdirp "^0.5.1" - node-abi "^2.2.0" - noop-logger "^0.1.1" - npmlog "^4.0.1" - os-homedir "^1.0.1" - pump "^2.0.1" - rc "^1.1.6" - simple-get "^2.7.0" - tar-fs "^1.13.0" - tunnel-agent "^0.6.0" - which-pm-runs "^1.0.0" - prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -5866,15 +5761,7 @@ psl@^1.1.24, psl@^1.1.28: resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184" integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw== -pump@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" - integrity sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pump@^2.0.0, pump@^2.0.1: +pump@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== @@ -5933,7 +5820,7 @@ randomatic@^3.0.0: kind-of "^6.0.0" math-random "^1.0.1" -rc@^1.1.6, rc@^1.2.7: +rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -6022,7 +5909,7 @@ read@1, read@~1.0.1: dependencies: mute-stream "~0.0.4" -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@~2.3.6: +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== @@ -6397,20 +6284,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= -simple-concat@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" - integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY= - -simple-get@^2.7.0: - version "2.8.1" - resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" - integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== - dependencies: - decompress-response "^3.3.0" - once "^1.3.1" - simple-concat "^1.0.0" - sisteransi@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-0.1.1.tgz#5431447d5f7d1675aac667ccd0b865a4994cb3ce" @@ -6803,29 +6676,6 @@ table@^5.0.2: slice-ansi "2.0.0" string-width "^2.1.1" -tar-fs@^1.13.0: - version "1.16.3" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" - integrity sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw== - dependencies: - chownr "^1.0.1" - mkdirp "^0.5.1" - pump "^1.0.0" - tar-stream "^1.1.2" - -tar-stream@^1.1.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555" - integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A== - dependencies: - bl "^1.0.0" - buffer-alloc "^1.2.0" - end-of-stream "^1.0.0" - fs-constants "^1.0.0" - readable-stream "^2.3.0" - to-buffer "^1.1.1" - xtend "^4.0.0" - tar@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" @@ -6930,11 +6780,6 @@ tmpl@1.0.x: resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE= -to-buffer@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" - integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== - to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" @@ -7274,11 +7119,6 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which-pm-runs@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" - integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= - which@1, which@^1.2.10, which@^1.2.12, which@^1.2.9, which@^1.3.0, which@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -7377,7 +7217,7 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== -xtend@^4.0.0, xtend@~4.0.1: +xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= From af99f6a66982c9c4499b1e2f6ecd9fc31826b1aa Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 27 Jan 2019 18:35:45 +0100 Subject: [PATCH 15/21] test: add missing file reading in parsers --- packages/benchmark/parsers.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/benchmark/parsers.js b/packages/benchmark/parsers.js index 10de2b2a5341..326428a33bc6 100644 --- a/packages/benchmark/parsers.js +++ b/packages/benchmark/parsers.js @@ -1,14 +1,18 @@ const Benchmark = require('benchmark'); const fs = require('fs'); +const path = require('path'); const tsEstree = require('@typescript-eslint/typescript-estree'); const tsParser = require('@typescript-eslint/parser'); function runTSESTree(directory, files) { for (const file of files) { - const result = tsEstree.parse(file, { - comment: true, - tokens: true - }); + const result = tsEstree.parse( + fs.readFileSync(path.join(__dirname, file), 'utf8'), + { + comment: true, + tokens: true + } + ); if (result.type !== 'Program') { throw new Error('something went wrong'); } @@ -17,10 +21,13 @@ function runTSESTree(directory, files) { function runTSParser(directory, files) { for (const file of files) { - const result = tsParser.parse(file, { - comment: true, - tokens: true - }); + const result = tsParser.parse( + fs.readFileSync(path.join(__dirname, file), 'utf8'), + { + comment: true, + tokens: true + } + ); if (result.type !== 'Program') { throw new Error('something went wrong'); } From 698acf958857d90532ef29476b52c4c9f1eb9589 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 28 Jan 2019 22:20:22 +0100 Subject: [PATCH 16/21] test: add complex test case for parsers --- packages/benchmark/PARSERS.md | 14 +- packages/benchmark/fixtures/complex/test.ts | 402 ++++++++++++++++++++ packages/benchmark/parsers.js | 7 +- 3 files changed, 419 insertions(+), 4 deletions(-) create mode 100644 packages/benchmark/fixtures/complex/test.ts diff --git a/packages/benchmark/PARSERS.md b/packages/benchmark/PARSERS.md index 204cc221b3fa..c06456826545 100644 --- a/packages/benchmark/PARSERS.md +++ b/packages/benchmark/PARSERS.md @@ -1,9 +1,17 @@ # Benchmark TSEstree - Parser -## Single File +## Complex File ``` -ts-estree x 8,761 ops/sec ±6.78% (83 runs sampled) -ts-parser x 4,158 ops/sec ±1.58% (87 runs sampled) +ts-estree x 232 ops/sec ±3.76% (84 runs sampled) +ts-parser x 161 ops/sec ±0.83% (82 runs sampled) +Fastest is ts-estree +``` + +## Simple File + +``` +ts-estree x 8,534 ops/sec ±2.25% (90 runs sampled) +ts-parser x 3,941 ops/sec ±0.89% (89 runs sampled) Fastest is ts-estree ``` diff --git a/packages/benchmark/fixtures/complex/test.ts b/packages/benchmark/fixtures/complex/test.ts new file mode 100644 index 000000000000..6dd1d10852a1 --- /dev/null +++ b/packages/benchmark/fixtures/complex/test.ts @@ -0,0 +1,402 @@ +class Red extends Color { + public shade() { + var getHue = () => { + return this.hue(); + }; + return getHue() + ' red'; + } +} + +class Color { + public shade() { + return 'some shade'; + } + public hue() { + return 'some hue'; + } +} + +class Blue extends Color { + public shade() { + var getHue = () => { + return this.hue(); + }; + return getHue() + ' blue'; + } +} + +var r = new Red(); +var b = new Blue(); + +r.shade(); +r.hue(); +b.shade(); +b.hue(); + +// @declaration: true +// @filename: foo.ts +const foo = { + bar: 'hello', + bat: 'world', + bam: { bork: { bar: 'a', baz: 'b' } } +}; +const arr: [0, 1, 2, ['a', 'b', 'c', [{ def: 'def' }, { sec: 'sec' }]]] = [ + 0, + 1, + 2, + ['a', 'b', 'c', [{ def: 'def' }, { sec: 'sec' }]] +]; + +const { + bar: baz, + bat, + bam: { + bork: { bar: ibar, baz: ibaz } + } +} = foo; +{ baz, ibaz }; + +const [, one, , [, bee, , [, { sec }]]] = arr; +{ one, bee, sec }; + +const getFoo = () => ({ + foo: 'foo' +}); + +const { foo: foo2 } = getFoo(); +class TestFile { + name: string; + foo(message: string): () => string { + return (...x: string[]) => + /// Test summary + /// + /// + + message + this.name; + } +} +var simpleExample = class { + static getTags() {} + tags() {} +}; +var circularReference = class C { + static getTags(c: C): C { + return c; + } + tags(c: C): C { + return c; + } +}; + +// repro from #15066 +class FooItem { + foo(): void {} + name?: string; +} + +type Constructor = new (...args: any[]) => T; +function WithTags>(Base: T) { + return class extends Base { + static getTags(): void {} + tags(): void {} + }; +} + +class Test extends WithTags(FooItem) {} + +const test = new Test(); + +Test.getTags(); +test.tags(); +interface Foo { + a: string; + b: number; +}; + +interface Bar { + b: string; +} + +interface Other { + totallyUnrelatedProperty: number; +} + +let x = { a: '', b: '' }; + +declare function f(x: Foo | Other): any; + +f(x); +f({ a: '', b: '' }) + +declare function g(x: Bar | Other): any; + +g(x); +g({ a: '', b: '' }) + +declare function h(x: Foo | Bar | Other): any; + +h(x); +h({ a: '', b: '' }) + +interface CatDog { cat: any, dog: any } +interface ManBearPig { man: any, bear: any, pig: any } +interface Platypus { platypus: any } + +type ExoticAnimal = + | CatDog + | ManBearPig + | Platypus; + +declare function addToZoo(animal: ExoticAnimal): void; + +addToZoo({ dog: "Barky McBarkface" }); +addToZoo({ man: "Manny", bear: "Coffee" }); + +const manBeer = { man: "Manny", beer: "Coffee" }; +addToZoo({ man: "Manny", beer: "Coffee" }); +addToZoo(manBeer); +interface I { +} + +enum E { + Red, Green, Blue +} + +function f() { + var a: any; + var n=3; + var s=""; + var b=false; + var i:I; + var e:E; + + n&&a; + n&&s; + n&&b; + n&&i; + n&&n; + n&&e; + + s&&a; + s&&n; + s&&b; + s&&i; + s&&s; + s&&e; + + a&&n; + a&&s; + a&&b; + a&&i; + a&&a; + a&&e; + + i&&n; + i&&s; + i&&b; + i&&a; + i&&i; + i&&e; + + e&&n; + e&&s; + e&&b; + e&&a; + e&&i; + e&&e; + + n||a; + n||s; + n||b; + n||i; + n||n; + n||e; + + s||a; + s||n; + s||b; + s||i; + s||s; + s||e; + + a||n; + a||s; + a||b; + a||i; + a||a; + a||e; + + i||n; + i||s; + i||b; + i||a; + i||i; + i||e; + + e||n; + e||s; + e||b; + e||a; + e||i; + e||e; + + n==a; + n==s; + n==b; + n==i; + n==n; + n==e; + + s==a; + s==n; + s==b; + s==i; + s==s; + s==e; + + a==n; + a==s; + a==b; + a==i; + a==a; + a==e; + + i==n; + i==s; + i==b; + i==a; + i==i; + i==e; + + e==n; + e==s; + e==b; + e==a; + e==i; + e==e; + + +i; + +s; + +n; + +a; + +b; + + -i; + -s; + -n; + -a; + -b; + + !i; + !s; + !n; + !a; + !b; + + + n+a; + n+s; + n+b; + n+i; + n+n; + n+e; + + s+a; + s+n; + s+b; + s+i; + s+s; + s+e; + + a+n; + a+s; + a+b; + a+i; + a+a; + a+e; + + i+n; + i+s; + i+b; + i+a; + i+i; + i+e; + + e+n; + e+s; + e+b; + e+a; + e+i; + e+e; + + n^a; + n^s; + n^b; + n^i; + n^n; + n^e; + + s^a; + s^n; + s^b; + s^i; + s^s; + s^e; + + a^n; + a^s; + a^b; + a^i; + a^a; + a^e; + + i^n; + i^s; + i^b; + i^a; + i^i; + i^e; + + e^n; + e^s; + e^b; + e^a; + e^i; + e^e; + + n-a; + n-s; + n-b; + n-i; + n-n; + n-e; + + s-a; + s-n; + s-b; + s-i; + s-s; + s-e; + + a-n; + a-s; + a-b; + a-i; + a-a; + a-e; + + i-n; + i-s; + i-b; + i-a; + i-i; + i-e; + + e-n; + e-s; + e-b; + e-a; + e-i; + e-e; + +} diff --git a/packages/benchmark/parsers.js b/packages/benchmark/parsers.js index 326428a33bc6..15990057915e 100644 --- a/packages/benchmark/parsers.js +++ b/packages/benchmark/parsers.js @@ -88,7 +88,12 @@ async function runAllBenchmarks(scenarios) { runAllBenchmarks([ { - name: 'Single File', + name: 'Complex File', + directory: 'fixtures/complex/', + files: ['fixtures/complex/test.ts'] + }, + { + name: 'Simple File', directory: 'fixtures/restrict-plus-operands/', files: ['fixtures/restrict-plus-operands/test1.ts'] } From aad489818712d51f2ed576fbe9f356381556b268 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 29 Jan 2019 23:08:29 +0100 Subject: [PATCH 17/21] test: do not generate results (its objective, for each environment) --- packages/benchmark/PARSERS.md | 17 ----------------- packages/benchmark/RULES.md | 33 --------------------------------- packages/benchmark/benchmark.js | 28 ++++++++++------------------ packages/benchmark/package.json | 6 +++--- packages/benchmark/parsers.js | 32 ++++++++++---------------------- yarn.lock | 10 +++++----- 6 files changed, 28 insertions(+), 98 deletions(-) delete mode 100644 packages/benchmark/PARSERS.md delete mode 100644 packages/benchmark/RULES.md diff --git a/packages/benchmark/PARSERS.md b/packages/benchmark/PARSERS.md deleted file mode 100644 index c06456826545..000000000000 --- a/packages/benchmark/PARSERS.md +++ /dev/null @@ -1,17 +0,0 @@ -# Benchmark TSEstree - Parser - -## Complex File - -``` -ts-estree x 232 ops/sec ±3.76% (84 runs sampled) -ts-parser x 161 ops/sec ±0.83% (82 runs sampled) -Fastest is ts-estree -``` - -## Simple File - -``` -ts-estree x 8,534 ops/sec ±2.25% (90 runs sampled) -ts-parser x 3,941 ops/sec ±0.89% (89 runs sampled) -Fastest is ts-estree -``` diff --git a/packages/benchmark/RULES.md b/packages/benchmark/RULES.md deleted file mode 100644 index 231b21dc8011..000000000000 --- a/packages/benchmark/RULES.md +++ /dev/null @@ -1,33 +0,0 @@ -# Benchmark TSLint - ESLint - -## Single File: restrict-plus-operands - -``` -tslint x 2.58 ops/sec ±7.49% (11 runs sampled) -eslint x 2.60 ops/sec ±4.57% (11 runs sampled) -Fastest is eslint, tslint -``` - -## Multi File: restrict-plus-operands - -``` -tslint x 2.70 ops/sec ±2.67% (11 runs sampled) -eslint x 0.81 ops/sec ±5.28% (7 runs sampled) -Fastest is tslint -``` - -## Single File: no-empty-interface - -``` -tslint x 1,624 ops/sec ±0.97% (88 runs sampled) -eslint x 2,134 ops/sec ±3.56% (80 runs sampled) -Fastest is eslint -``` - -## Multi File: no-empty-interface - -``` -tslint x 1,241 ops/sec ±1.17% (89 runs sampled) -eslint x 823 ops/sec ±2.81% (83 runs sampled) -Fastest is tslint -``` diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index 1668651201eb..be565b26b7fa 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -2,11 +2,10 @@ const Benchmark = require('benchmark'); const fs = require('fs'); function createBenchmark(name, directory, files, useServices) { - return new Promise(resolve => { + return new Promise((resolve, reject) => { const suite = new Benchmark.Suite(name, { async: true }); - let message = '```\n'; suite .add('tslint', function() { const result = require('./tslint').runTSLint( @@ -31,39 +30,32 @@ function createBenchmark(name, directory, files, useServices) { // add listeners .on('cycle', function(event) { console.log(String(event.target)); - message += String(event.target) + '\n'; }) .on('error', function(e) { - console.log(e); + reject(e); }) .on('complete', function() { - message += `Fastest is ${this.filter('fastest') - .map(i => i.name) - .join(', ')}\n`; - message += '```\n'; - resolve(message); + console.log( + `Fastest is ${this.filter('fastest') + .map(i => i.name) + .join(', ')}` + ); + resolve(); }) .run(); }); } async function runAllBenchmarks(scenarios) { - const messages = []; for (const scenario of scenarios) { - console.log(`${scenario.name}`); - let message = `## ${scenario.name}\n\n`; - message += await createBenchmark( + console.log(scenario.name); + await createBenchmark( scenario.name, scenario.directory, scenario.files, scenario.useServices ); - messages.push(message); } - fs.writeFileSync( - 'RULES.md', - `# Benchmark TSLint - ESLint\n\n${messages.join('\n')}` - ); } runAllBenchmarks([ diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 0bd22128a6f7..2df9225185f7 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -9,9 +9,9 @@ "devDependencies": { "@types/benchmark": "^1.0.31", "@types/eslint": "^4.16.5", - "@typescript-eslint/eslint-plugin": "1.1.0", - "@typescript-eslint/parser": "1.1.0", - "@typescript-eslint/typescript-estree": "1.1.0", + "@typescript-eslint/eslint-plugin": "1.1.1", + "@typescript-eslint/parser": "1.1.1", + "@typescript-eslint/typescript-estree": "1.1.1", "benchmark": "^2.1.4", "eslint": "^5.12.1", "tslint": "^5.12.1" diff --git a/packages/benchmark/parsers.js b/packages/benchmark/parsers.js index 15990057915e..9565c262531f 100644 --- a/packages/benchmark/parsers.js +++ b/packages/benchmark/parsers.js @@ -35,9 +35,8 @@ function runTSParser(directory, files) { } function createBenchmark(name, directory, files) { - return new Promise(resolve => { + return new Promise((resolve, reject) => { const suite = new Benchmark.Suite(name); - let message = '```\n'; suite .add('ts-estree', function() { runTSESTree(directory, files); @@ -48,17 +47,17 @@ function createBenchmark(name, directory, files) { // add listeners .on('cycle', function(event) { console.log(String(event.target)); - message += String(event.target) + '\n'; }) .on('error', function(e) { - console.log(e); + reject(e); }) .on('complete', function() { - message += `Fastest is ${this.filter('fastest') - .map(i => i.name) - .join(', ')}\n`; - message += '```\n'; - resolve(message); + console.log( + `Fastest is ${this.filter('fastest') + .map(i => i.name) + .join(', ')}` + ); + resolve(); }) .run({ async: true, @@ -69,21 +68,10 @@ function createBenchmark(name, directory, files) { } async function runAllBenchmarks(scenarios) { - const messages = []; for (const scenario of scenarios) { - console.log(`${scenario.name}`); - let message = `## ${scenario.name}\n\n`; - message += await createBenchmark( - scenario.name, - scenario.directory, - scenario.files - ); - messages.push(message); + console.log(scenario.name); + await createBenchmark(scenario.name, scenario.directory, scenario.files); } - fs.writeFileSync( - 'PARSERS.md', - `# Benchmark TSEstree - Parser\n\n${messages.join('\n')}` - ); } runAllBenchmarks([ diff --git a/yarn.lock b/yarn.lock index e283dcea7222..c91501604006 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5749,11 +5749,6 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" -platform@^1.3.3: - version "1.3.5" - resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444" - integrity sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q== - pkg-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" @@ -5761,6 +5756,11 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" +platform@^1.3.3: + version "1.3.5" + resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444" + integrity sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q== + please-upgrade-node@^3.0.2, please-upgrade-node@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz#ed320051dfcc5024fae696712c8288993595e8ac" From fddc4fef05a5e0ea0a5b8cf6598777b5db8201ae Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 30 Jan 2019 21:03:08 +0100 Subject: [PATCH 18/21] test: add missing tsconfigRootDir to eslintrc --- packages/benchmark/eslint.js | 9 ++------- .../fixtures/no-empty-interface/.eslintrc.js | 14 ++++++++++++++ .../fixtures/no-empty-interface/.eslintrc.json | 14 -------------- .../fixtures/restrict-plus-operands/.eslintrc.js | 16 ++++++++++++++++ .../restrict-plus-operands/.eslintrc.json | 15 --------------- 5 files changed, 32 insertions(+), 36 deletions(-) create mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.js delete mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.json create mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js delete mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint.js index 5143820c7851..397d6b56a271 100644 --- a/packages/benchmark/eslint.js +++ b/packages/benchmark/eslint.js @@ -5,7 +5,7 @@ const fs = require('fs'); // exports.runESLint = function(directory, files, useServices) { // const linter = new eslint.CLIEngine({ // files: files, -// configFile: `${directory}.eslintrc.json`, +// configFile: `${directory}.eslintrc.js`, // extensions: ['.js', '.ts'] // }); // const results = []; @@ -44,12 +44,7 @@ exports.runESLint = function(directory, files, useServices) { for (const file of files) { result = linter.verify( fs.readFileSync(path.join(__dirname, file), 'utf8'), - JSON.parse( - fs.readFileSync( - path.join(__dirname, `./${directory}.eslintrc.json`), - 'utf8' - ) - ), + require(path.join(__dirname, `./${directory}.eslintrc.js`)), file ); } diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js new file mode 100644 index 000000000000..4eb332bf900d --- /dev/null +++ b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + root: true, + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/no-empty-interface': 'error' + }, + parser: '@typescript-eslint/parser', + parserOptions: { + sourceType: 'module', + ecmaFeatures: { + jsx: false + } + } +}; diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json deleted file mode 100644 index 33f6970db353..000000000000 --- a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "root": true, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/no-empty-interface": "error" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "jsx": false - } - } -} diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js new file mode 100644 index 000000000000..29e8d14c7e9d --- /dev/null +++ b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js @@ -0,0 +1,16 @@ +module.exports = { + root: true, + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/restrict-plus-operands': 'error' + }, + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json', + sourceType: 'module', + ecmaFeatures: { + jsx: false + } + } +}; diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json deleted file mode 100644 index f49b2f34094f..000000000000 --- a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "root": true, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/restrict-plus-operands": "error" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json", - "sourceType": "module", - "ecmaFeatures": { - "jsx": false - } - } -} From 358d0a66b25bbcecd9f2d21cf8cf29b45f2712a9 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 30 Jan 2019 21:16:38 +0100 Subject: [PATCH 19/21] test: migrate config to json and apply tsconfigRootDir for useServices --- packages/benchmark/eslint.js | 13 +++++++++++-- .../fixtures/no-empty-interface/.eslintrc.js | 14 -------------- .../fixtures/no-empty-interface/.eslintrc.json | 14 ++++++++++++++ .../fixtures/restrict-plus-operands/.eslintrc.js | 16 ---------------- .../restrict-plus-operands/.eslintrc.json | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 32 deletions(-) delete mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.js create mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.json delete mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js create mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint.js index 397d6b56a271..10e38aeff3c2 100644 --- a/packages/benchmark/eslint.js +++ b/packages/benchmark/eslint.js @@ -5,7 +5,7 @@ const fs = require('fs'); // exports.runESLint = function(directory, files, useServices) { // const linter = new eslint.CLIEngine({ // files: files, -// configFile: `${directory}.eslintrc.js`, +// configFile: `${directory}.eslintrc.json`, // extensions: ['.js', '.ts'] // }); // const results = []; @@ -41,10 +41,19 @@ exports.runESLint = function(directory, files, useServices) { require('@typescript-eslint/eslint-plugin/lib/rules/restrict-plus-operands') ); let result; + const config = JSON.parse( + fs.readFileSync( + path.join(__dirname, `./${directory}.eslintrc.json`), + 'utf8' + ) + ); + if (useServices) { + config.parserOptions.tsconfigRootDir = path.join(__dirname, directory); + } for (const file of files) { result = linter.verify( fs.readFileSync(path.join(__dirname, file), 'utf8'), - require(path.join(__dirname, `./${directory}.eslintrc.js`)), + config, file ); } diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js deleted file mode 100644 index 4eb332bf900d..000000000000 --- a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - root: true, - plugins: ['@typescript-eslint'], - rules: { - '@typescript-eslint/no-empty-interface': 'error' - }, - parser: '@typescript-eslint/parser', - parserOptions: { - sourceType: 'module', - ecmaFeatures: { - jsx: false - } - } -}; diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json new file mode 100644 index 000000000000..33f6970db353 --- /dev/null +++ b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "root": true, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/no-empty-interface": "error" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "jsx": false + } + } +} diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js deleted file mode 100644 index 29e8d14c7e9d..000000000000 --- a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - root: true, - plugins: ['@typescript-eslint'], - rules: { - '@typescript-eslint/restrict-plus-operands': 'error' - }, - parser: '@typescript-eslint/parser', - parserOptions: { - tsconfigRootDir: __dirname, - project: './tsconfig.json', - sourceType: 'module', - ecmaFeatures: { - jsx: false - } - } -}; diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json new file mode 100644 index 000000000000..f49b2f34094f --- /dev/null +++ b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json @@ -0,0 +1,15 @@ +{ + "root": true, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/restrict-plus-operands": "error" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json", + "sourceType": "module", + "ecmaFeatures": { + "jsx": false + } + } +} From 70e04c8bfc17c8d0148128c9d5b9f25531829a9c Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 30 Jan 2019 21:16:38 +0100 Subject: [PATCH 20/21] Revert "test: migrate config to json and apply tsconfigRootDir for useServices" This reverts commit 358d0a66b25bbcecd9f2d21cf8cf29b45f2712a9. --- packages/benchmark/eslint.js | 13 ++----------- .../fixtures/no-empty-interface/.eslintrc.js | 14 ++++++++++++++ .../fixtures/no-empty-interface/.eslintrc.json | 14 -------------- .../fixtures/restrict-plus-operands/.eslintrc.js | 16 ++++++++++++++++ .../restrict-plus-operands/.eslintrc.json | 15 --------------- 5 files changed, 32 insertions(+), 40 deletions(-) create mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.js delete mode 100644 packages/benchmark/fixtures/no-empty-interface/.eslintrc.json create mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js delete mode 100644 packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint.js index 10e38aeff3c2..397d6b56a271 100644 --- a/packages/benchmark/eslint.js +++ b/packages/benchmark/eslint.js @@ -5,7 +5,7 @@ const fs = require('fs'); // exports.runESLint = function(directory, files, useServices) { // const linter = new eslint.CLIEngine({ // files: files, -// configFile: `${directory}.eslintrc.json`, +// configFile: `${directory}.eslintrc.js`, // extensions: ['.js', '.ts'] // }); // const results = []; @@ -41,19 +41,10 @@ exports.runESLint = function(directory, files, useServices) { require('@typescript-eslint/eslint-plugin/lib/rules/restrict-plus-operands') ); let result; - const config = JSON.parse( - fs.readFileSync( - path.join(__dirname, `./${directory}.eslintrc.json`), - 'utf8' - ) - ); - if (useServices) { - config.parserOptions.tsconfigRootDir = path.join(__dirname, directory); - } for (const file of files) { result = linter.verify( fs.readFileSync(path.join(__dirname, file), 'utf8'), - config, + require(path.join(__dirname, `./${directory}.eslintrc.js`)), file ); } diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js new file mode 100644 index 000000000000..4eb332bf900d --- /dev/null +++ b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + root: true, + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/no-empty-interface': 'error' + }, + parser: '@typescript-eslint/parser', + parserOptions: { + sourceType: 'module', + ecmaFeatures: { + jsx: false + } + } +}; diff --git a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json b/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json deleted file mode 100644 index 33f6970db353..000000000000 --- a/packages/benchmark/fixtures/no-empty-interface/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "root": true, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/no-empty-interface": "error" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "jsx": false - } - } -} diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js new file mode 100644 index 000000000000..29e8d14c7e9d --- /dev/null +++ b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.js @@ -0,0 +1,16 @@ +module.exports = { + root: true, + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/restrict-plus-operands': 'error' + }, + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json', + sourceType: 'module', + ecmaFeatures: { + jsx: false + } + } +}; diff --git a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json b/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json deleted file mode 100644 index f49b2f34094f..000000000000 --- a/packages/benchmark/fixtures/restrict-plus-operands/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "root": true, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/restrict-plus-operands": "error" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json", - "sourceType": "module", - "ecmaFeatures": { - "jsx": false - } - } -} From c8665f67a5dbf3c88fae5086bd2a4d2ebaa14f94 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 30 Jan 2019 23:56:05 +0100 Subject: [PATCH 21/21] test: add e2e benchmark --- packages/benchmark/benchmark.js | 5 +- packages/benchmark/e2e.js | 66 +++++++++++++++++++ .../benchmark/{eslint.js => eslint-runner.js} | 0 packages/benchmark/package.json | 5 +- .../benchmark/{tslint.js => tslint-runner.js} | 0 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 packages/benchmark/e2e.js rename packages/benchmark/{eslint.js => eslint-runner.js} (100%) rename packages/benchmark/{tslint.js => tslint-runner.js} (100%) diff --git a/packages/benchmark/benchmark.js b/packages/benchmark/benchmark.js index be565b26b7fa..f74616be4db4 100644 --- a/packages/benchmark/benchmark.js +++ b/packages/benchmark/benchmark.js @@ -1,5 +1,4 @@ const Benchmark = require('benchmark'); -const fs = require('fs'); function createBenchmark(name, directory, files, useServices) { return new Promise((resolve, reject) => { @@ -8,7 +7,7 @@ function createBenchmark(name, directory, files, useServices) { }); suite .add('tslint', function() { - const result = require('./tslint').runTSLint( + const result = require('./tslint-runner').runTSLint( directory, files, useServices @@ -18,7 +17,7 @@ function createBenchmark(name, directory, files, useServices) { } }) .add('eslint', function() { - const result = require('./eslint').runESLint( + const result = require('./eslint-runner').runESLint( directory, files, useServices diff --git a/packages/benchmark/e2e.js b/packages/benchmark/e2e.js new file mode 100644 index 000000000000..c80e5741f48c --- /dev/null +++ b/packages/benchmark/e2e.js @@ -0,0 +1,66 @@ +const Benchmark = require('benchmark'); +const child_process = require('child_process'); +const path = require('path'); + +function normalizeCommand(command) { + return path.normalize(command); +} + +function createBenchmark(name, directory, files, useServices) { + return new Promise((resolve, reject) => { + const suite = new Benchmark.Suite(name, { + async: true + }); + suite + .add('tslint', function() { + let hasError = false; + try { + child_process.execSync( + normalizeCommand('./node_modules/.bin/tslint') + + ' -p fixtures/restrict-plus-operands/tsconfig.json "fixtures/restrict-plus-operands/*.ts"' + ); + } catch (e) { + // console.error(e.output ? e.output.toString() : e); + hasError = true; + } + if (!hasError) { + throw new Error('something went wrong'); + } + }) + .add('eslint', function() { + let hasError = false; + try { + child_process.execSync( + normalizeCommand('./node_modules/.bin/eslint') + + ' --ext .ts "fixtures/restrict-plus-operands/*.ts"' + ); + } catch (e) { + // console.error(e.output ? e.output.toString() : e); + hasError = true; + } + if (!hasError) { + throw new Error('something went wrong'); + } + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + }) + .on('error', function(e) { + reject(e); + }) + .on('complete', function() { + console.log( + `Fastest is ${this.filter('fastest') + .map(i => i.name) + .join(', ')}` + ); + resolve(); + }) + .run(); + }); +} + +createBenchmark().catch(e => { + console.log(e); +}); diff --git a/packages/benchmark/eslint.js b/packages/benchmark/eslint-runner.js similarity index 100% rename from packages/benchmark/eslint.js rename to packages/benchmark/eslint-runner.js diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 2df9225185f7..58f4d26fcdc5 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -4,7 +4,10 @@ "private": true, "scripts": { "benchmark:rules": "node --allow-natives-syntax benchmark.js", - "benchmark:parsers": "node --allow-natives-syntax parsers.js" + "benchmark:parsers": "node --allow-natives-syntax parsers.js", + "benchmark:e2e": "node --allow-natives-syntax e2e.js", + "eslint": "eslint --ext .ts fixtures/restrict-plus-operands", + "tslint": "tslint -p fixtures/restrict-plus-operands/tsconfig.json \"fixtures/restrict-plus-operands/*.ts\"" }, "devDependencies": { "@types/benchmark": "^1.0.31", diff --git a/packages/benchmark/tslint.js b/packages/benchmark/tslint-runner.js similarity index 100% rename from packages/benchmark/tslint.js rename to packages/benchmark/tslint-runner.js pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy