Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@magicspace/tslint-rules

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magicspace/tslint-rules - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

bld/rules/index.js

5

bld/main.js
"use strict";
[].map(() => { });
let foo = () => {
return () => { };
let foo = {
zhangsan: () => { },
};
//# sourceMappingURL=main.js.map

49

bld/rules/explicitReturnTypeRule.js

@@ -29,8 +29,9 @@ "use strict";

walk(sourceFile) {
let cb = (node) => {
let callback = (node) => {
if ((tsutils_1.isArrowFunction(node) ||
tsutils_1.isFunctionDeclaration(node) ||
tsutils_1.isFunctionExpression(node) ||
tsutils_1.isMethodDeclaration(node)) &&
!this.missingType(node)) {
tsutils_1.isMethodDeclaration(node) ||
tsutils_1.isGetAccessorDeclaration(node)) &&
!this.hasExplicitType(node)) {
this.failureManager.append({

@@ -41,27 +42,31 @@ node,

}
TypeScript.forEachChild(node, cb);
TypeScript.forEachChild(node, callback);
};
TypeScript.forEachChild(sourceFile, cb);
TypeScript.forEachChild(sourceFile, callback);
this.failureManager.throw();
}
missingType(node) {
let { type } = node;
if (type) {
hasExplicitType(node) {
if ('type' in node && node.type) {
return true;
}
else if (node.parent) {
let parent = node.parent;
if (tsutils_1.isCallExpression(parent)) {
return true;
}
else if (parent.type) {
return true;
}
else if (tsutils_1.isReturnStatement(parent)) {
return this.missingType(parent);
}
else {
return false;
}
let parent = node.parent;
if (!parent) {
return false;
}
if (tsutils_1.isCallExpression(parent)) {
// example: [].map(() => {});
return true;
}
else if (tsutils_1.isVariableDeclaration(parent)) {
// example: let foo: Foo = () => {};
return !!parent.type;
}
else if (
// example: return () => {};
tsutils_1.isReturnStatement(parent) ||
// example: let foo: Foo = {bar() {}};
tsutils_1.isObjectLiteralExpression(parent) ||
TypeScript.isObjectLiteralElement(parent)) {
return this.hasExplicitType(parent);
}
else {

@@ -68,0 +73,0 @@ return false;

@@ -58,7 +58,7 @@ "use strict";

if (config.startsWith('$')) {
return BUILT_IN_MODULE_GROUP_TESTER_DICT[config] || (() => false);
return (BUILT_IN_MODULE_GROUP_TESTER_DICT[config] || (() => false));
}
else {
let regex = new RegExp(config);
return path => regex.test(path);
return (path) => regex.test(path);
}

@@ -153,7 +153,2 @@ }

}
else if (tsutils_1.isExportDeclaration(statement)) {
if (statement.moduleSpecifier !== undefined && 4 /* ExportFrom */) {
checkWithAppendModuleImport(statement.moduleSpecifier);
}
}
else {

@@ -160,0 +155,0 @@ pendingCache.push(statement);

@@ -32,2 +32,6 @@ "use strict";

},
baseUrlDirSearchName: {
type: 'string',
default: 'tsconfig',
},
},

@@ -92,3 +96,3 @@ },

getBaseUrl() {
let rootPath = findProjectRootPath(this.sourceDirname);
let rootPath = findProjectRootPath(this.sourceDirname, this.options.baseUrlDirSearchName);
if (!rootPath) {

@@ -123,3 +127,3 @@ throw new Error('can not find tslint.json');

let rootPathCache;
return function inner(currentPath) {
return function inner(currentPath, baseUrlDirSearchName) {
if (rootPathCache) {

@@ -130,3 +134,3 @@ return rootPathCache;

let files = FS.readdirSync(currentPath);
if (_.includes(files, 'tslint.json')) {
if (_.includes(files, baseUrlDirSearchName)) {
rootPathCache = currentPath;

@@ -136,7 +140,7 @@ return currentPath;

else {
return inner(Path.join(currentPath, '..'));
return inner(Path.join(currentPath, '..'), baseUrlDirSearchName);
}
}
catch (e) {
return undefined;
throw new Error(`can not find such 'baseUrlDirSearchName' that ${baseUrlDirSearchName}`);
}

@@ -143,0 +147,0 @@ };

@@ -11,3 +11,3 @@ "use strict";

const RELATIVE_PATH = /^(?:\.{1,2}[\\/])+/;
const ERROR_MESSAGE_BANNED_PARENT_IMPORT = 'this module can not be imported, because it is imported from parent directory.';
const ERROR_MESSAGE_BANNED_PARENT_IMPORT = 'Importing from parent directory is not allowed.';
class Rule extends tslint_1.Rules.AbstractRule {

@@ -20,3 +20,3 @@ apply(sourceFile) {

ruleName: 'no-parent-import',
description: 'No additional parameters are required',
description: '',
optionsDescription: '',

@@ -23,0 +23,0 @@ options: undefined,

@@ -35,3 +35,3 @@ "use strict";

ruleName: 'scoped-modules',
description: 'No additional parameters are required',
description: '',
optionsDescription: '',

@@ -38,0 +38,0 @@ options: undefined,

"use strict";
// tslint:disable:no-implicit-dependencies
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,3 +6,3 @@ const Path = require("path");

const test_1 = require("tslint/lib/test");
console.log('Testing Lint Rules:');
console.info('Testing Lint Rules:');
let testDirs = glob

@@ -10,0 +9,0 @@ .sync('../../test/rules/**/tslint.json', { cwd: __dirname, absolute: true })

{
"name": "@magicspace/tslint-rules",
"version": "0.1.3",
"version": "0.1.4",
"description": "Custom TSLint rules for MagicSpace.",

@@ -13,2 +13,5 @@ "repository": "https://github.com/makeflow/magicspace.git",

},
"files": [
"bld/**/*.js"
],
"peerDependencies": {

@@ -15,0 +18,0 @@ "tslint": "*",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc