From bd4bb370a567300ac9b6f0146a4d06e5ea63e4f5 Mon Sep 17 00:00:00 2001 From: Christian Bewernitz Date: Fri, 23 Feb 2018 11:14:53 +0100 Subject: [PATCH] Upgrading/fixing and documenting dependencies 2018-02 (#11) - upgrading everything beside tslint - documented the reasons for the way this package depends on others - added example configurations, cleaner imports in rule - build and test the build output before creating a version - 0.1.0 --- .nvmrc | 2 +- README.md | 62 ++++++ circle.yml | 2 +- dist/noAbsoluteImportToOwnParentRule.js | 6 +- examples/add-configuration/tslint.json | 9 + examples/disable-rules/tslint.json | 8 + examples/minimal/tslint.json | 5 + examples/rules-directory/tslint.json | 13 ++ package-lock.json | 263 ++++++++++++------------ package.json | 27 ++- src/noAbsoluteImportToOwnParentRule.ts | 9 +- 11 files changed, 248 insertions(+), 158 deletions(-) create mode 100644 README.md create mode 100644 examples/add-configuration/tslint.json create mode 100644 examples/disable-rules/tslint.json create mode 100644 examples/minimal/tslint.json create mode 100644 examples/rules-directory/tslint.json diff --git a/.nvmrc b/.nvmrc index 303e51f..a244f6f 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v8.1.4 +v8.9.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..95e7472 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# bm-tslint-rules + +This is a utility package to ease adding tslint checking to a project. + +## Dependencies + +It is different from other [rule configurations](https://github.com/palantir/tslint#custom-rules--plugins) in that it depends on a fixed version of the following npm packages: +* [`tslint`](https://github.com/palantir/tslint) for running it against a codebase (so it doesn't need to be part of your `package.json`) +the configurations that are extended in the following order: +* [`tslint-eslint-rules`](https://github.com/buzinas/tslint-eslint-rules/blob/master/CHANGELOG.md) +* [`tslint-microsoft-contrib`](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/Release-Notes) +* [`tslint-react`](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/Release-Notes) + +to make sure upgrading dependencies in a project does not break any code/CI pipeline because of fixed/improve/more strict tslint rules. + +Instead we are doing regular upgrade days in this project and each project can decide when to switch to a newer version of this package on it's own. + +For executing the custom rule(s) coming with this package there is the additional (peer-)dependency [`ts-node`](https://github.com/TypeStrong/ts-node/). Since `ts-node` also [needs `typescript`](https://github.com/TypeStrong/ts-node/blob/v4.1.0/src/index.ts#L11) at runtime, that is the second peer dependency (`^2.4.1` since this is the version `ts-node` [devDepends on](https://github.com/TypeStrong/ts-node/blob/v4.1.0/package.json#L75). + +## Usage + +1. install an [available version](https://github.com/bettermarks/bm-tslint-rules/releases) (e.g. `v0.1.0`)) as a devDependency: + +`npm install -D github:bettermarks/bm-tslint-rules#` +(You should not use leave out `` since this refers to master and differs depending on which time you install it and npm's cache prevents updates once it fetched it.) + +2. copy [`tslint.json`](https://github.com/bettermarks/bm-tslint-rules/blob/master/examples/minimal/tslint.json) to your project root. + + (optionally adopt the configuration to your need, see [examples](https://github.com/bettermarks/bm-tslint-rules/blob/master/examples)) + +3. add the following to the `scripts` in your `package.json`: + ```json + "tslint": "tslint [OPTIONS]", + ``` + - you will need to find the [options](https://palantir.github.io/tslint/usage/cli/) that work best for your project, we recommend: + + ```json + "tslint": "tslint -c tslint.json --project tsconfig.json -t stylish", + ``` + +4. on the command line run `npm run tslint`. + +## Configured rules + +The repo exports its [`tslint.json`]() as it's main file. + +Since documenting each and every rule here would possible get outdated soon here are the sources for the rules we have configured: + +* [`tslint-eslint-rules`](https://github.com/buzinas/tslint-eslint-rules#rules-copied-from-the-eslint-website) +* `tslint-microsoft-contrib`: + - [extending recommended ruleset](https://github.com/Microsoft/tslint-microsoft-contrib/blob/master/recommended_ruleset.js), + - [available rules and options](https://github.com/Microsoft/tslint-microsoft-contrib#supported-rules) +* `tslint-react`: + - [extending ruleset](https://github.com/palantir/tslint-react/blob/master/tslint-react.json) + - [available rules and options](https://github.com/palantir/tslint-react#rules) + + +## Custom Rules + +### no-absolute-import-to-own-parent + +TODO: document diff --git a/circle.yml b/circle.yml index e342749..149ab28 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: node: - version: v8.2.0 + version: v8.9.0 services: - docker dependencies: diff --git a/dist/noAbsoluteImportToOwnParentRule.js b/dist/noAbsoluteImportToOwnParentRule.js index 0d070e6..ccbb776 100644 --- a/dist/noAbsoluteImportToOwnParentRule.js +++ b/dist/noAbsoluteImportToOwnParentRule.js @@ -10,7 +10,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var Lint = require("tslint"); +var tslint_1 = require("tslint"); var path = require("path"); var configuration_1 = require("tslint/lib/configuration"); var Rule = /** @class */ (function (_super) { @@ -35,7 +35,7 @@ var Rule = /** @class */ (function (_super) { }; Rule.FAILURE_STRING = 'importing parent path '; return Rule; -}(Lint.Rules.AbstractRule)); +}(tslint_1.Rules.AbstractRule)); exports.Rule = Rule; // The walker takes care of all the work. var NoImportsWalker = /** @class */ (function (_super) { @@ -63,4 +63,4 @@ var NoImportsWalker = /** @class */ (function (_super) { _super.prototype.visitImportDeclaration.call(this, node); }; return NoImportsWalker; -}(Lint.RuleWalker)); +}(tslint_1.RuleWalker)); diff --git a/examples/add-configuration/tslint.json b/examples/add-configuration/tslint.json new file mode 100644 index 0000000..6f5b3bb --- /dev/null +++ b/examples/add-configuration/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": [ + "bm-tslint-rules", + "tslint-clean-code" + ], + "rules": { + "newspaper-order": true + } +} diff --git a/examples/disable-rules/tslint.json b/examples/disable-rules/tslint.json new file mode 100644 index 0000000..f99b9de --- /dev/null +++ b/examples/disable-rules/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": [ + "bm-tslint-rules" + ], + "rules": { + "no-absolute-import-to-own-parent": false + } +} diff --git a/examples/minimal/tslint.json b/examples/minimal/tslint.json new file mode 100644 index 0000000..74f5c5f --- /dev/null +++ b/examples/minimal/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "bm-tslint-rules" + ] +} diff --git a/examples/rules-directory/tslint.json b/examples/rules-directory/tslint.json new file mode 100644 index 0000000..ab2ff2c --- /dev/null +++ b/examples/rules-directory/tslint.json @@ -0,0 +1,13 @@ +{ + "extends": [ + "bm-tslint-rules" + ], + "rulesDirectory": "node_modules/tslint-no-unused-expression-chai/rules", + "rules": { + "no-unused-expression": false, + "no-unused-expression-chai": [ + true, + "allow-fast-null-checks" + ] + } +} diff --git a/package-lock.json b/package-lock.json index 03aff27..aadc58d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,38 @@ { "name": "bm-tslint-rules", - "version": "0.0.8", + "version": "0.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@types/node": { - "version": "8.0.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.46.tgz", - "integrity": "sha512-rRkP4kb5JYIfAoRKaDbcdPZBcTNOgzSApyzhPN9e6rhViSJAWQGlSXIX5gc75iR02jikhpzy3usu31wMHllfFw==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-9.4.0.tgz", + "integrity": "sha512-zkYho6/4wZyX6o9UQ8rd0ReEaiEYNNCqYFIAACe2Tf9DrYlgzWW27OigYHnnztnnZQwVRpwWmZKegFmDpinIsA==", + "dev": true + }, + "@types/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=", + "dev": true + }, + "@types/strip-json-comments": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz", + "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==", "dev": true }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "ansi-styles": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true, "requires": { - "color-convert": "1.9.0" + "color-convert": "1.9.1" } }, "arrify": { @@ -35,7 +45,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, "requires": { "chalk": "1.1.3", "esutils": "2.0.2", @@ -45,14 +54,12 @@ "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, "requires": { "ansi-styles": "2.2.1", "escape-string-regexp": "1.0.5", @@ -64,28 +71,24 @@ "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" } } }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, "requires": { "balanced-match": "1.0.0", "concat-map": "0.0.1" @@ -94,25 +97,22 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true, + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.2.1" + "supports-color": "4.5.0" } }, "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", - "dev": true, + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "requires": { "color-name": "1.1.3" } @@ -120,26 +120,22 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.0.tgz", + "integrity": "sha512-okPpdvdJr6mUGi2XzupC+irQxzwGLVaBzacFC14hjLv8NColXEsxsU+QaeuSSXpQUak5g2K0vQ7WjA1e8svczg==" }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "diff": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.0.tgz", - "integrity": "sha512-w0XZubFWn0Adlsapj9EAWX0FqWdO4tz8kc3RiYdWLh4k/V8PTb6i0SMgXt0vRM3zyKnT8tKO7mUlieRQHIjMNg==", - "dev": true + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.4.0.tgz", + "integrity": "sha512-QpVuMTEoJMF7cKzi6bvWhRulU1fZqZnvyVQgNhPaxxuTYwyjn/j1v9falseQ/uXWwPnO56RBfwtg4h/EQXmucA==" }, "doctrine": { "version": "0.7.2", @@ -153,8 +149,7 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "esutils": { "version": "1.1.6", @@ -164,14 +159,12 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -185,7 +178,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, "requires": { "ansi-regex": "2.1.1" } @@ -193,14 +185,21 @@ "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "dev": true, + "requires": { + "parse-passwd": "1.0.0" + } }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "1.4.0", "wrappy": "1.0.2" @@ -209,8 +208,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "isarray": { "version": "0.0.1", @@ -220,20 +218,18 @@ "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" }, "make-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", - "integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.2.tgz", + "integrity": "sha512-l9ra35l5VWLF24y75Tg8XgfGLX0ueRhph118WKM6H5denx4bB5QF59+4UAm9oJ2qsPQZas/CQUDdtDdfvYHBdQ==", "dev": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "1.1.8" } @@ -265,58 +261,58 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1.0.2" } }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=" }, "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", - "dev": true, + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "requires": { "path-parse": "1.0.5" } }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", - "dev": true + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" }, "source-map": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "source-map-support": { - "version": "0.4.16", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.16.tgz", - "integrity": "sha512-A6vlydY7H/ljr4L2UOhDSajQdZQ6dMD7cLH0pzwcmwLyc9u8PNI4WGtnfDDzX7uzGL6c/T+ORL97Zlh+S4iOrg==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.3.tgz", + "integrity": "sha512-eKkTgWYeBOQqFGXRfKabMFdnWepo51vWqEdoeikaEPFiJC7MCU5j2h4+6Q8npkZTeLGbSyecZvRxiSoWl3rh+w==", "dev": true, "requires": { - "source-map": "0.5.6" + "source-map": "0.6.1" } }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, "requires": { "ansi-regex": "2.1.1" } @@ -334,38 +330,39 @@ "dev": true }, "supports-color": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz", - "integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==", - "dev": true, + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "requires": { "has-flag": "2.0.0" } }, "ts-node": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", - "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-4.1.0.tgz", + "integrity": "sha512-xcZH12oVg9PShKhy3UHyDmuDLV3y7iKwX25aMVPt1SIXSuAfWkFiGPEkg+th8R4YKW/QCxDoW7lJdb15lx6QWg==", "dev": true, "requires": { "arrify": "1.0.1", - "chalk": "2.1.0", - "diff": "3.3.0", - "make-error": "1.3.0", + "chalk": "2.3.0", + "diff": "3.4.0", + "make-error": "1.3.2", "minimist": "1.2.0", "mkdirp": "0.5.1", - "source-map-support": "0.4.16", - "tsconfig": "6.0.0", - "v8flags": "3.0.0", + "source-map-support": "0.5.3", + "tsconfig": "7.0.0", + "v8flags": "3.0.1", "yn": "2.0.0" } }, "tsconfig": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", - "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz", + "integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==", "dev": true, "requires": { + "@types/strip-bom": "3.0.0", + "@types/strip-json-comments": "0.0.30", "strip-bom": "3.0.0", "strip-json-comments": "2.0.1" } @@ -379,19 +376,18 @@ "version": "5.8.0", "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.8.0.tgz", "integrity": "sha1-H0mtWy53x2w69N3K5VKuTjYS6xM=", - "dev": true, "requires": { "babel-code-frame": "6.26.0", "builtin-modules": "1.1.1", - "chalk": "2.1.0", - "commander": "2.11.0", - "diff": "3.3.0", + "chalk": "2.3.0", + "commander": "2.14.0", + "diff": "3.4.0", "glob": "7.1.2", "minimatch": "3.0.4", - "resolve": "1.4.0", - "semver": "5.4.1", + "resolve": "1.5.0", + "semver": "5.5.0", "tslib": "1.7.1", - "tsutils": "2.12.1" + "tsutils": "2.21.0" } }, "tslint-eslint-rules": { @@ -412,62 +408,55 @@ } }, "tslint-microsoft-contrib": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.0.1.tgz", - "integrity": "sha1-Mo7pwo0HzfeTKTIEyW4v+rkiGZQ=", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.0.2.tgz", + "integrity": "sha1-7MKnl/d3oS8AZpRM7AyBqefFnuk=", "requires": { - "tsutils": "1.9.1" - }, - "dependencies": { - "tsutils": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz", - "integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=" - } + "tsutils": "2.21.0" } }, "tslint-react": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/tslint-react/-/tslint-react-3.2.0.tgz", - "integrity": "sha1-hR+1BSAcY9A0PFFybmNk9+mtLpk=", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/tslint-react/-/tslint-react-3.4.0.tgz", + "integrity": "sha512-zs4UgLmKfKuXuUh976QBV1zyZ/41gcKfww4IHXrgDpNkvFKl9AiDvYH6CgcqT8yH1DKqfv8KHlHqa0hStEoMxA==", "requires": { - "tsutils": "2.12.1" + "tsutils": "2.21.0" } }, "tsutils": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.12.1.tgz", - "integrity": "sha1-9Nlc4zkciXHkblTEzw7bCiHdWyQ=", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.21.0.tgz", + "integrity": "sha512-zlOHTYtTwvTiKxUyAU8wiKzPpAgwZrGjb7AY18VUlxuCgBiTMVorIl5HjrCT8V64Hm34RI1BZITJMVQpBLMxVg==", "requires": { - "tslib": "1.7.1" + "tslib": "1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" + } } }, "typescript": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.3.tgz", - "integrity": "sha512-ptLSQs2S4QuS6/OD1eAKG+S5G8QQtrU5RT32JULdZQtM1L3WTi34Wsu48Yndzi8xsObRAB9RPt/KhA9wlpEF6w==", - "dev": true - }, - "user-home": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.1.tgz", + "integrity": "sha512-bqB1yS6o9TNA9ZC/MJxM0FZzPnZdtHj0xWK/IZ5khzVqdpGul/R/EIiHRgFXlwTD7PSIaYVnGKq1QgMCu2mnqw==", "dev": true }, "v8flags": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.0.0.tgz", - "integrity": "sha512-AGl+C+4qpeSu2g3JxCD/mGFFOs/vVZ3XREkD3ibQXEqr4Y4zgIrPWW124/IKJFHOIVFIoH8miWrLf0o84HYjwA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.0.1.tgz", + "integrity": "sha1-3Oj8N5wX2fLJ6e142JzgAFKxt2s=", "dev": true, "requires": { - "user-home": "1.1.1" + "homedir-polyfill": "1.0.1" } }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "yn": { "version": "2.0.0", diff --git a/package.json b/package.json index 6f86e12..676dab4 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,21 @@ { "name": "bm-tslint-rules", - "version": "0.0.8", + "version": "0.1.0", "description": "default tslint rules to use for projects using typescript", + "repository": "https://github.com/bettermarks/bm-tslint-rules", + "bugs": "https://github.com/bettermarks/bm-tslint-rules/issues", "main": "tslint.json", "files": [ "dist" ], "engines": { - "node": ">=8.1.4", - "npm": ">=5.0.3" + "node": ">=8.2.0", + "npm": ">=5.2.0" }, "scripts": { + "preinstall": "npx check-node-version --package", + "preversion": "npm run build && npm run test", + "check": "npx npm-check -u --skip-unused", "build": "tsc -p .", "test": "tslint --test test/**/tslint.json" }, @@ -21,18 +26,18 @@ "author": "bettermarks", "license": "ISC", "dependencies": { + "tslint": "5.8.0", "tslint-eslint-rules": "4.1.1", - "tslint-microsoft-contrib": "5.0.1", - "tslint-react": "3.2.0" + "tslint-microsoft-contrib": "5.0.2", + "tslint-react": "3.4.0" }, "devDependencies": { - "@types/node": "^8.0.30", - "ts-node": "^3.3.0", - "tslint": "5.8.0", - "tsutils": "^2.8.2", - "typescript": "~2.5.3" + "@types/node": "^9.4.0", + "ts-node": "^4.1.0", + "typescript": "~2.7.1" }, "peerDependencies": { - "tslint": "5.8.0" + "ts-node": ">=3.2.0", + "typescript": ">=2.6.1" } } diff --git a/src/noAbsoluteImportToOwnParentRule.ts b/src/noAbsoluteImportToOwnParentRule.ts index 1e8d573..df3282b 100644 --- a/src/noAbsoluteImportToOwnParentRule.ts +++ b/src/noAbsoluteImportToOwnParentRule.ts @@ -1,10 +1,9 @@ import * as ts from 'typescript'; -import * as Lint from 'tslint'; -import {IOptions} from 'tslint'; +import {IOptions, RuleFailure, Rules, RuleWalker} from 'tslint'; import * as path from 'path'; import {findConfigurationPath} from 'tslint/lib/configuration'; -export class Rule extends Lint.Rules.AbstractRule { +export class Rule extends Rules.AbstractRule { public static FAILURE_STRING = 'importing parent path '; private static _projectRoot: string; @@ -20,7 +19,7 @@ export class Rule extends Lint.Rules.AbstractRule { return this._projectRoot; } - public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + public apply(sourceFile: ts.SourceFile): RuleFailure[] { // tslint:disable-next-line:no-use-before-declare return this.applyWithWalker(new NoImportsWalker(sourceFile, this.getOptions())); @@ -28,7 +27,7 @@ export class Rule extends Lint.Rules.AbstractRule { } // The walker takes care of all the work. -class NoImportsWalker extends Lint.RuleWalker { +class NoImportsWalker extends RuleWalker { readonly packagePathList: ReadonlyArray; constructor(sourceFile: ts.SourceFile, options: IOptions) {