@nativescript/tslint-rules
Advanced tools
| import * as Lint from "tslint"; | ||
| import * as ts from "typescript"; | ||
| export declare class Rule extends Lint.Rules.AbstractRule { | ||
| apply(sourceFile: ts.SourceFile): Array<Lint.RuleFailure>; | ||
| } |
| var __extends = (this && this.__extends) || (function () { | ||
| var extendStatics = function (d, b) { | ||
| extendStatics = Object.setPrototypeOf || | ||
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
| return extendStatics(d, b); | ||
| }; | ||
| return function (d, b) { | ||
| extendStatics(d, b); | ||
| function __() { this.constructor = d; } | ||
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var Lint = require("tslint"); | ||
| var FAILURE_STRING = "Use of android.R is forbidden because of performance reasons. Use a constant instead."; | ||
| var Rule = /** @class */ (function (_super) { | ||
| __extends(Rule, _super); | ||
| function Rule() { | ||
| return _super !== null && _super.apply(this, arguments) || this; | ||
| } | ||
| Rule.prototype.apply = function (sourceFile) { | ||
| return this.applyWithWalker(new Walk(sourceFile, this.getOptions())); | ||
| }; | ||
| return Rule; | ||
| }(Lint.Rules.AbstractRule)); | ||
| exports.Rule = Rule; | ||
| var Walk = /** @class */ (function (_super) { | ||
| __extends(Walk, _super); | ||
| function Walk() { | ||
| return _super !== null && _super.apply(this, arguments) || this; | ||
| } | ||
| Walk.prototype.visitPropertyAccessExpression = function (node) { | ||
| if (node.name.getText() === "R" && node.expression.getText() === "android") { | ||
| this.addFailure(this.createFailure(node.getStart(), node.getWidth(), FAILURE_STRING)); | ||
| } | ||
| _super.prototype.visitPropertyAccessExpression.call(this, node); | ||
| }; | ||
| return Walk; | ||
| }(Lint.RuleWalker)); | ||
| //# sourceMappingURL=noAndroidResourcesRule.js.map |
| {"version":3,"file":"noAndroidResourcesRule.js","sourceRoot":"","sources":["../src/noAndroidResourcesRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6BAA+B;AAG/B,IAAM,cAAc,GAAG,uFAAuF,CAAC;AAE/G;IAA0B,wBAAuB;IAAjD;;IAIA,CAAC;IAHG,oBAAK,GAAL,UAAM,UAAyB;QAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IACL,WAAC;AAAD,CAAC,AAJD,CAA0B,IAAI,CAAC,KAAK,CAAC,YAAY,GAIhD;AAJY,oBAAI;AAMjB;IAAmB,wBAAe;IAAlC;;IAQA,CAAC;IAPa,4CAA6B,GAAvC,UAAwC,IAAiC;QACrE,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,SAAS,EAAE;YACxE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;SACzF;QAED,iBAAM,6BAA6B,YAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACL,WAAC;AAAD,CAAC,AARD,CAAmB,IAAI,CAAC,UAAU,GAQjC"} |
+6
-0
@@ -0,1 +1,7 @@ | ||
| ## 0.0.5 (2019-10-29) | ||
| ### Features | ||
| - no-android-resources rule ([04e1373](https://github.com/NativeScript/nativescript-tslint-rules/commit/04e1373)) | ||
| ## 0.0.4 (2019-09-08) | ||
@@ -2,0 +8,0 @@ |
+2
-0
| export { Rule as PreferMappedImportsRule, RemapOptions, RuleArgs, parseCompilerOptions } from "./preferMappedImportsRule"; | ||
| export { Rule as NoAndroidResourcesRule } from "./noAndroidResourcesRule"; | ||
| export declare const rulesDirectory = "."; | ||
| export declare const rules: { | ||
| "prefer-mapped-imports": boolean[]; | ||
| "no-android-resources": boolean[]; | ||
| }; |
+4
-1
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.parseCompilerOptions = preferMappedImportsRule_1.parseCompilerOptions; | ||
| var noAndroidResourcesRule_1 = require("./noAndroidResourcesRule"); | ||
| exports.NoAndroidResourcesRule = noAndroidResourcesRule_1.Rule; | ||
| exports.rulesDirectory = "."; | ||
| exports.rules = { | ||
| "prefer-mapped-imports": [true] | ||
| "prefer-mapped-imports": [true], | ||
| "no-android-resources": [true] | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAKmC;AAJ/B,4DAAA,IAAI,CAA2B;AAG/B,yDAAA,oBAAoB,CAAA;AAGX,QAAA,cAAc,GAAG,GAAG,CAAC;AACrB,QAAA,KAAK,GAAG;IACjB,uBAAuB,EAAE,CAAC,IAAI,CAAC;CAClC,CAAC"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAKmC;AAJ/B,4DAAA,IAAI,CAA2B;AAG/B,yDAAA,oBAAoB,CAAA;AAGxB,mEAA0E;AAAjE,0DAAA,IAAI,CAA0B;AAE1B,QAAA,cAAc,GAAG,GAAG,CAAC;AACrB,QAAA,KAAK,GAAG;IACjB,uBAAuB,EAAE,CAAC,IAAI,CAAC;IAC/B,sBAAsB,EAAE,CAAC,IAAI,CAAC;CACjC,CAAC"} |
@@ -18,4 +18,4 @@ var __extends = (this && this.__extends) || (function () { | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var _a; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var ts = require("typescript"); | ||
@@ -22,0 +22,0 @@ var Lint = require("tslint"); |
+7
-8
| { | ||
| "name": "@nativescript/tslint-rules", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "description": "A set of TSLint rules for NativeScript projects.", | ||
@@ -59,8 +59,5 @@ "main": "dist/index.js", | ||
| "testEnvironment": "node", | ||
| "globals": { | ||
| "__TS_CONFIG__": "tsconfig.json" | ||
| }, | ||
| "moduleFileExtensions": [ | ||
| "ts", | ||
| "js" | ||
| "js", | ||
| "ts" | ||
| ], | ||
@@ -73,5 +70,7 @@ "collectCoverage": true, | ||
| "transform": { | ||
| "\\.(ts)$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
| "\\.(ts)$": "ts-jest" | ||
| }, | ||
| "testRegex": "/test/.*\\.spec\\.ts$" | ||
| "testRegex": "/test/.*\\.spec\\.ts$", | ||
| "preset": "ts-jest", | ||
| "testMatch": null | ||
| }, | ||
@@ -78,0 +77,0 @@ "husky": { |
+4
-0
@@ -38,1 +38,5 @@ # NativeScript TSLint Rules | ||
| - Used in typescript project with `baseUrl` and `path` mappings for either web or mobile files. | ||
| ## `no-android-resources` rule | ||
| The rule forbids using constants inside `android.R` as they cause performance issues. |
35293
10.52%13
30%266
23.15%42
10.53%