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

eslint-plugin-typescript

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-typescript - npm Package Compare versions

Comparing version 0.1.0 to 0.3.0

docs/rules/interface-name-prefix.md

6

docs/rules/type-annotation-spacing.md

@@ -6,3 +6,3 @@ # Enforces spacing around type annotations (type-annotation-spacing)

```ts
var foo: string = "bar";
let foo: string = "bar";

@@ -23,3 +23,3 @@ function foo(a: string): string {

```ts
var foo:string = "bar";
let foo:string = "bar";

@@ -34,3 +34,3 @@ function foo(a : string):string {

```js
var foo: string = "bar";
let foo: string = "bar";

@@ -37,0 +37,0 @@ function foo(a: string): string {

@@ -11,4 +11,4 @@ /**

var requireIndex = require("requireindex"),
path = require("path");
const requireIndex = require("requireindex");
const path = require("path");

@@ -15,0 +15,0 @@ //------------------------------------------------------------------------------

@@ -20,3 +20,3 @@ /**

create: function(context) {
create(context) {

@@ -37,3 +37,3 @@ //----------------------------------------------------------------------

node: methodDefinition,
message: "Missing accessibility modifier on method definition " + methodDefinition.key.name + "."
message: `Missing accessibility modifier on method definition ${methodDefinition.key.name}.`
});

@@ -53,3 +53,3 @@ }

node: classProperty,
message: "Missing accessibility modifier on class property " + classProperty.key.name + "."
message: `Missing accessibility modifier on class property ${classProperty.key.name}.`
});

@@ -56,0 +56,0 @@ }

@@ -21,3 +21,3 @@ /**

create: function(context) {
create(context) {

@@ -38,13 +38,28 @@ const sourceCode = context.getSourceCode();

function checkTypeAnnotationSpacing(typeAnnotation) {
const colonToken = sourceCode.getTokenBefore(typeAnnotation),
let colonToken = typeAnnotation,
previousToken = sourceCode.getTokenBefore(typeAnnotation);
if (previousToken.type === "Punctuator") {
colonToken = previousToken;
previousToken = sourceCode.getTokenBefore(colonToken);
if (typeAnnotation.range[0] - colonToken.range[1] === 0) {
context.report({
node: typeAnnotation,
message: "Expected a space after the colon.",
fix(fixer) {
return fixer.insertTextAfter(colonToken, " ");
}
});
if (typeAnnotation.range[0] - colonToken.range[1] === 0) {
context.report({
node: typeAnnotation,
message: "Expected a space after the colon.",
fix(fixer) {
return fixer.insertTextAfter(colonToken, " ");
}
});
}
} else {
if (typeAnnotation.typeAnnotation.range[0] - typeAnnotation.range[0] === 1) {
context.report({
node: typeAnnotation,
message: "Expected a space after the colon.",
fix(fixer) {
return fixer.insertTextAfterRange([typeAnnotation.range[0], typeAnnotation.typeAnnotation.range[0]], " ");
}
});
}
}

@@ -51,0 +66,0 @@

{
"name": "eslint-plugin-typescript",
"version": "0.1.0",
"version": "0.3.0",
"description": "TypeScript plugin for ESLint",

@@ -15,3 +15,5 @@ "keywords": [

"lint": "eslint lib/",
"test": "npm run lint && mocha tests --recursive"
"lint:fix": "eslint --fix lib/",
"mocha": "mocha tests --recursive",
"test": "npm run lint && npm run mocha"
},

@@ -22,6 +24,8 @@ "dependencies": {

"devDependencies": {
"eslint": "~3.0.0",
"eslint-config-eslint": "^3.0.0",
"mocha": "^2.4.5",
"typescript-eslint-parser": "^0.4.0"
"eslint": "^4.1.1",
"eslint-config-eslint": "^4.0.0",
"eslint-plugin-node": "^5.1.0",
"mocha": "^3.4.2",
"typescript": "~2.3.0",
"typescript-eslint-parser": "^4.0.0"
},

@@ -28,0 +32,0 @@ "engines": {

@@ -54,1 +54,7 @@ # eslint-plugin-typescript

* `typescript/explicit-member-accessibility` - enforces accessibility modifiers on class properties and methods.
* `typescript/interface-name-prefix` - enforces interface names are prefixed.
* `typescript/no-triple-slash-reference` - enforces `/// <reference />` is not used.
* `typescript/no-explicit-any` - enforces the any type is not used.
* `typescript/no-angle-bracket-type-assertion` - enforces the use of `as Type` assertions instead of `<Type>` assertions.
* `typescript/no-namespace` - disallows the use of custom TypeScript modules and namespaces.
* `typescript/prefer-namespace-keyword` - enforces the use of the keyword `namespace` over `module` to declare custom TypeScript modules.

@@ -11,3 +11,3 @@ /**

var rule = require("../../../lib/rules/explicit-member-accessibility"),
let rule = require("../../../lib/rules/explicit-member-accessibility"),
RuleTester = require("eslint").RuleTester;

@@ -20,3 +20,3 @@

var ruleTester = new RuleTester();
let ruleTester = new RuleTester();
ruleTester.run("explicit-member-accessibility", rule, {

@@ -23,0 +23,0 @@

@@ -11,3 +11,3 @@ /**

var rule = require("../../../lib/rules/type-annotation-spacing"),
let rule = require("../../../lib/rules/type-annotation-spacing"),
RuleTester = require("eslint").RuleTester;

@@ -20,3 +20,3 @@

var ruleTester = new RuleTester();
let ruleTester = new RuleTester();
ruleTester.run("type-annotation-spacing", rule, {

@@ -26,3 +26,3 @@

{
code: "var foo: string;",
code: "let foo: string;",
parser: "typescript-eslint-parser"

@@ -35,3 +35,3 @@ },

{
code: "function foo(a:string) {}",
code: "function foo(a: string) {}",
parser: "typescript-eslint-parser"

@@ -43,5 +43,5 @@ }

{
code: "var foo : string;",
code: "let foo : string;",
parser: "typescript-eslint-parser",
output: "var foo: string;",
output: "let foo: string;",
errors: [{

@@ -54,5 +54,5 @@ message: "Unexpected space before the colon.",

{
code: "var foo:string;",
code: "let foo:string;",
parser: "typescript-eslint-parser",
output: "var foo: string;",
output: "let foo: string;",
errors: [{

@@ -75,5 +75,5 @@ message: "Expected a space after the colon.",

{
code: "var foo = function():string {}",
code: "let foo = function():string {}",
parser: "typescript-eslint-parser",
output: "var foo = function(): string {}",
output: "let foo = function(): string {}",
errors: [{

@@ -86,5 +86,5 @@ message: "Expected a space after the colon.",

{
code: "var foo = ():string => {}",
code: "let foo = ():string => {}",
parser: "typescript-eslint-parser",
output: "var foo = (): string => {}",
output: "let foo = (): string => {}",
errors: [{

@@ -91,0 +91,0 @@ message: "Expected a space after the colon.",

Sorry, the diff of this file is not supported yet

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