aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tslint-config
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-30 20:21:01 +0800
committerFabio Berger <me@fabioberger.com>2018-01-30 20:21:01 +0800
commit93a5b3f457c1211676296840c285759007a55500 (patch)
treed1682b657c207f447748e08550095bafc79b6997 /packages/tslint-config
parent4242176d291f54212797de9f5df80b1346724ebb (diff)
downloaddexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.gz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.bz2
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.lz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.xz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.zst
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.zip
Fix prettier
Diffstat (limited to 'packages/tslint-config')
-rw-r--r--packages/tslint-config/README.md2
-rw-r--r--packages/tslint-config/package.json80
-rw-r--r--packages/tslint-config/rules/asyncSuffixRule.ts6
-rw-r--r--packages/tslint-config/rules/underscorePrivatesRule.ts72
-rw-r--r--packages/tslint-config/rules/walkers/async_suffix.ts40
-rw-r--r--packages/tslint-config/tsconfig.json10
-rw-r--r--packages/tslint-config/tslint.json198
7 files changed, 199 insertions, 209 deletions
diff --git a/packages/tslint-config/README.md b/packages/tslint-config/README.md
index 8a6fa8a2f..71fdd9772 100644
--- a/packages/tslint-config/README.md
+++ b/packages/tslint-config/README.md
@@ -14,7 +14,7 @@ Add the following to your `tslint.json` file
```json
{
- "extends": ["@0xproject/tslint-config"]
+ "extends": ["@0xproject/tslint-config"]
}
```
diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json
index fc015de26..95bd67ac6 100644
--- a/packages/tslint-config/package.json
+++ b/packages/tslint-config/package.json
@@ -1,47 +1,37 @@
{
- "name": "@0xproject/tslint-config",
- "version": "0.4.4",
- "description": "Lint rules related to 0xProject for TSLint",
- "main": "tslint.json",
- "scripts": {
- "build": "tsc",
- "clean": "shx rm -rf lib",
- "lint": "tslint --project . 'rules/**/*.ts'"
- },
- "files": [
- "tslint.js",
- "README.md",
- "LICENSE"
- ],
- "repository": {
- "type": "git",
- "url": "git://github.com/0xProject/0x.js.git"
- },
- "keywords": [
- "tslint",
- "config",
- "0xProject",
- "typescript",
- "ts"
- ],
- "author": {
- "name": "Fabio Berger",
- "email": "fabio@0xproject.com"
- },
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/tslint-config/README.md",
- "devDependencies": {
- "@types/lodash": "^4.14.86",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "tslint-eslint-rules": "^4.1.1",
- "typescript": "~2.6.1"
- },
- "dependencies": {
- "lodash": "^4.17.4",
- "tslint-react": "^3.2.0"
- }
+ "name": "@0xproject/tslint-config",
+ "version": "0.4.4",
+ "description": "Lint rules related to 0xProject for TSLint",
+ "main": "tslint.json",
+ "scripts": {
+ "build": "tsc",
+ "clean": "shx rm -rf lib",
+ "lint": "tslint --project . 'rules/**/*.ts'"
+ },
+ "files": ["tslint.js", "README.md", "LICENSE"],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/0xProject/0x.js.git"
+ },
+ "keywords": ["tslint", "config", "0xProject", "typescript", "ts"],
+ "author": {
+ "name": "Fabio Berger",
+ "email": "fabio@0xproject.com"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/tslint-config/README.md",
+ "devDependencies": {
+ "@types/lodash": "^4.14.86",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "tslint-eslint-rules": "^4.1.1",
+ "typescript": "~2.6.1"
+ },
+ "dependencies": {
+ "lodash": "^4.17.4",
+ "tslint-react": "^3.2.0"
+ }
}
diff --git a/packages/tslint-config/rules/asyncSuffixRule.ts b/packages/tslint-config/rules/asyncSuffixRule.ts
index 5215c7151..8af9d88d4 100644
--- a/packages/tslint-config/rules/asyncSuffixRule.ts
+++ b/packages/tslint-config/rules/asyncSuffixRule.ts
@@ -4,7 +4,7 @@ import * as ts from 'typescript';
import { AsyncSuffixWalker } from './walkers/async_suffix';
export class Rule extends Lint.Rules.AbstractRule {
- public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
- return this.applyWithWalker(new AsyncSuffixWalker(sourceFile, this.getOptions()));
- }
+ public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
+ return this.applyWithWalker(new AsyncSuffixWalker(sourceFile, this.getOptions()));
+ }
}
diff --git a/packages/tslint-config/rules/underscorePrivatesRule.ts b/packages/tslint-config/rules/underscorePrivatesRule.ts
index 472ea09ff..4d9ee69f7 100644
--- a/packages/tslint-config/rules/underscorePrivatesRule.ts
+++ b/packages/tslint-config/rules/underscorePrivatesRule.ts
@@ -4,58 +4,58 @@ import * as ts from 'typescript';
const UNDERSCORE = '_';
type RelevantClassMember =
- | ts.MethodDeclaration
- | ts.PropertyDeclaration
- | ts.GetAccessorDeclaration
- | ts.SetAccessorDeclaration;
+ | ts.MethodDeclaration
+ | ts.PropertyDeclaration
+ | ts.GetAccessorDeclaration
+ | ts.SetAccessorDeclaration;
// Copied from: https://github.com/DanielRosenwasser/underscore-privates-tslint-rule
// The version on github is not published on npm
export class Rule extends Lint.Rules.AbstractRule {
- public static FAILURE_STRING = 'private members must be prefixed with an underscore';
+ public static FAILURE_STRING = 'private members must be prefixed with an underscore';
- public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
- return this.applyWithFunction(sourceFile, walk);
- }
+ public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
+ return this.applyWithFunction(sourceFile, walk);
+ }
}
function walk(ctx: Lint.WalkContext<void>): void {
- traverse(ctx.sourceFile);
+ traverse(ctx.sourceFile);
- function traverse(node: ts.Node): void {
- checkNodeForViolations(ctx, node);
- return ts.forEachChild(node, traverse);
- }
+ function traverse(node: ts.Node): void {
+ checkNodeForViolations(ctx, node);
+ return ts.forEachChild(node, traverse);
+ }
}
function checkNodeForViolations(ctx: Lint.WalkContext<void>, node: ts.Node): void {
- if (!isRelevantClassMember(node)) {
- return;
- }
- // The declaration might have a computed property name or a numeric name.
- const name = node.name;
- if (!nameIsIdentifier(name)) {
- return;
- }
- if (!nameStartsWithUnderscore(name.text) && memberIsPrivate(node)) {
- ctx.addFailureAtNode(name, Rule.FAILURE_STRING);
- }
+ if (!isRelevantClassMember(node)) {
+ return;
+ }
+ // The declaration might have a computed property name or a numeric name.
+ const name = node.name;
+ if (!nameIsIdentifier(name)) {
+ return;
+ }
+ if (!nameStartsWithUnderscore(name.text) && memberIsPrivate(node)) {
+ ctx.addFailureAtNode(name, Rule.FAILURE_STRING);
+ }
}
function isRelevantClassMember(node: ts.Node): node is RelevantClassMember {
- switch (node.kind) {
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.GetAccessor:
- case ts.SyntaxKind.SetAccessor:
- return true;
- default:
- return false;
- }
+ switch (node.kind) {
+ case ts.SyntaxKind.MethodDeclaration:
+ case ts.SyntaxKind.PropertyDeclaration:
+ case ts.SyntaxKind.GetAccessor:
+ case ts.SyntaxKind.SetAccessor:
+ return true;
+ default:
+ return false;
+ }
}
function nameStartsWithUnderscore(text: string) {
- return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
+ return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
}
function memberIsPrivate(node: ts.Declaration) {
- return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword);
+ return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword);
}
function nameIsIdentifier(node: ts.Node): node is ts.Identifier {
- return node.kind === ts.SyntaxKind.Identifier;
+ return node.kind === ts.SyntaxKind.Identifier;
}
diff --git a/packages/tslint-config/rules/walkers/async_suffix.ts b/packages/tslint-config/rules/walkers/async_suffix.ts
index eaec9c5f6..e1138de8d 100644
--- a/packages/tslint-config/rules/walkers/async_suffix.ts
+++ b/packages/tslint-config/rules/walkers/async_suffix.ts
@@ -3,24 +3,24 @@ import * as Lint from 'tslint';
import * as ts from 'typescript';
export class AsyncSuffixWalker extends Lint.RuleWalker {
- public static FAILURE_STRING = 'async functions must have an Async suffix';
- public visitMethodDeclaration(node: ts.MethodDeclaration): void {
- const methodNameNode = node.name;
- const methodName = methodNameNode.getText();
- if (!_.isUndefined(node.type)) {
- if (node.type.kind === ts.SyntaxKind.TypeReference) {
- // tslint:disable-next-line:no-unnecessary-type-assertion
- const returnTypeName = (node.type as ts.TypeReferenceNode).typeName.getText();
- if (returnTypeName === 'Promise' && !methodName.endsWith('Async')) {
- const failure = this.createFailure(
- methodNameNode.getStart(),
- methodNameNode.getWidth(),
- AsyncSuffixWalker.FAILURE_STRING,
- );
- this.addFailure(failure);
- }
- }
- }
- super.visitMethodDeclaration(node);
- }
+ public static FAILURE_STRING = 'async functions must have an Async suffix';
+ public visitMethodDeclaration(node: ts.MethodDeclaration): void {
+ const methodNameNode = node.name;
+ const methodName = methodNameNode.getText();
+ if (!_.isUndefined(node.type)) {
+ if (node.type.kind === ts.SyntaxKind.TypeReference) {
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ const returnTypeName = (node.type as ts.TypeReferenceNode).typeName.getText();
+ if (returnTypeName === 'Promise' && !methodName.endsWith('Async')) {
+ const failure = this.createFailure(
+ methodNameNode.getStart(),
+ methodNameNode.getWidth(),
+ AsyncSuffixWalker.FAILURE_STRING,
+ );
+ this.addFailure(failure);
+ }
+ }
+ }
+ super.visitMethodDeclaration(node);
+ }
}
diff --git a/packages/tslint-config/tsconfig.json b/packages/tslint-config/tsconfig.json
index 15da53092..83db0fcd2 100644
--- a/packages/tslint-config/tsconfig.json
+++ b/packages/tslint-config/tsconfig.json
@@ -1,7 +1,7 @@
{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./rules/**/*"]
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./rules/**/*"]
}
diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json
index 971588b08..f2a9558b9 100644
--- a/packages/tslint-config/tslint.json
+++ b/packages/tslint-config/tslint.json
@@ -1,101 +1,101 @@
{
- "extends": ["tslint:latest", "tslint-react", "tslint-eslint-rules"],
- "rules": {
- "adjacent-overload-signatures": true,
- "arrow-parens": [true, "ban-single-arg-parens"],
- "arrow-return-shorthand": true,
- "async-suffix": true,
- "await-promise": true,
- "binary-expression-operand-order": true,
- "callable-types": true,
- "class-name": true,
- "completed-docs": [
- true,
- {
- "functions": { "visibilities": ["exported"] },
- "methods": { "locations": "instance", "privacies": ["public", "protected"] }
- }
- ],
- "curly": true,
- "eofline": true,
- "encoding": true,
- "import-spacing": true,
- "indent": [true, "spaces", 4],
- "interface-name": false,
- "interface-over-type-literal": true,
- "linebreak-style": [true, "LF"],
- "max-classes-per-file": false,
- "max-classes-per-file": [true, 1],
- "max-line-length": false,
- "max-file-line-count": [true, 500],
- "member-access": true,
- "member-ordering": [true, "public-before-private", "static-before-instance", "variables-before-functions"],
- "newline-before-return": false,
- "new-parens": true,
- "no-angle-bracket-type-assertion": true,
- "no-boolean-literal-compare": true,
- "no-default-export": true,
- "no-empty-interface": false,
- "no-floating-promises": true,
- "no-non-null-assertion": true,
- "no-parameter-reassignment": true,
- "no-redundant-jsdoc": true,
- "no-return-await": true,
- "no-string-throw": true,
- "no-submodule-imports": false,
- "no-unnecessary-type-assertion": true,
- "no-unused-variable": [true, { "ignore-pattern": "^_\\d*" }],
- "no-implicit-dependencies": [true, "dev"],
- "number-literal-format": true,
- "object-literal-sort-keys": false,
- "object-literal-key-quotes": false,
- "ordered-imports": [
- true,
- {
- "grouped-imports": true
- }
- ],
- "prefer-const": true,
- "prefer-for-of": true,
- "prefer-function-over-method": true,
- "promise-function-async": true,
- "quotemark": [true, "single", "avoid-escape", "jsx-double"],
- "restrict-plus-operands": true,
- "semicolon": [true, "always"],
- "space-before-function-paren": [
- true,
- {
- "anonymous": "never",
- "named": "never",
- "method": "never",
- "constructor": "never",
- "asyncArrow": "always"
- }
- ],
- "space-within-parens": false,
- "type-literal-delimiter": true,
- "underscore-privates": true,
- "variable-name": [true, "ban-keywords", "allow-pascal-case"],
- "whitespace": [
- true,
- "check-branch",
- "check-decl",
- "check-operator",
- "check-separator",
- "check-rest-spread",
- "check-type",
- "check-typecast",
- "check-preblock"
- ],
- "jsx-alignment": true,
- "jsx-boolean-value": true,
- "jsx-curly-spacing": [true, "never"],
- "jsx-no-lambda": true,
- "jsx-no-multiline-js": false,
- "jsx-no-string-ref": true,
- "jsx-self-close": true,
- "jsx-wrap-multiline": false,
- "jsx-no-bind": false
- },
- "rulesDirectory": "lib"
+ "extends": ["tslint:latest", "tslint-react", "tslint-eslint-rules"],
+ "rules": {
+ "adjacent-overload-signatures": true,
+ "arrow-parens": [true, "ban-single-arg-parens"],
+ "arrow-return-shorthand": true,
+ "async-suffix": true,
+ "await-promise": true,
+ "binary-expression-operand-order": true,
+ "callable-types": true,
+ "class-name": true,
+ "completed-docs": [
+ true,
+ {
+ "functions": { "visibilities": ["exported"] },
+ "methods": { "locations": "instance", "privacies": ["public", "protected"] }
+ }
+ ],
+ "curly": true,
+ "eofline": true,
+ "encoding": true,
+ "import-spacing": true,
+ "indent": [true, "spaces", 4],
+ "interface-name": false,
+ "interface-over-type-literal": true,
+ "linebreak-style": [true, "LF"],
+ "max-classes-per-file": false,
+ "max-classes-per-file": [true, 1],
+ "max-line-length": false,
+ "max-file-line-count": [true, 500],
+ "member-access": true,
+ "member-ordering": [true, "public-before-private", "static-before-instance", "variables-before-functions"],
+ "newline-before-return": false,
+ "new-parens": true,
+ "no-angle-bracket-type-assertion": true,
+ "no-boolean-literal-compare": true,
+ "no-default-export": true,
+ "no-empty-interface": false,
+ "no-floating-promises": true,
+ "no-non-null-assertion": true,
+ "no-parameter-reassignment": true,
+ "no-redundant-jsdoc": true,
+ "no-return-await": true,
+ "no-string-throw": true,
+ "no-submodule-imports": false,
+ "no-unnecessary-type-assertion": true,
+ "no-unused-variable": [true, { "ignore-pattern": "^_\\d*" }],
+ "no-implicit-dependencies": [true, "dev"],
+ "number-literal-format": true,
+ "object-literal-sort-keys": false,
+ "object-literal-key-quotes": false,
+ "ordered-imports": [
+ true,
+ {
+ "grouped-imports": true
+ }
+ ],
+ "prefer-const": true,
+ "prefer-for-of": true,
+ "prefer-function-over-method": true,
+ "promise-function-async": true,
+ "quotemark": [true, "single", "avoid-escape", "jsx-double"],
+ "restrict-plus-operands": true,
+ "semicolon": [true, "always"],
+ "space-before-function-paren": [
+ true,
+ {
+ "anonymous": "never",
+ "named": "never",
+ "method": "never",
+ "constructor": "never",
+ "asyncArrow": "always"
+ }
+ ],
+ "space-within-parens": false,
+ "type-literal-delimiter": true,
+ "underscore-privates": true,
+ "variable-name": [true, "ban-keywords", "allow-pascal-case"],
+ "whitespace": [
+ true,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-separator",
+ "check-rest-spread",
+ "check-type",
+ "check-typecast",
+ "check-preblock"
+ ],
+ "jsx-alignment": true,
+ "jsx-boolean-value": true,
+ "jsx-curly-spacing": [true, "never"],
+ "jsx-no-lambda": true,
+ "jsx-no-multiline-js": false,
+ "jsx-no-string-ref": true,
+ "jsx-self-close": true,
+ "jsx-wrap-multiline": false,
+ "jsx-no-bind": false
+ },
+ "rulesDirectory": "lib"
}