Skip to content

Commit

Permalink
chore: replace tslint with eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed May 29, 2019
1 parent 90ad57b commit 704d4bd
Show file tree
Hide file tree
Showing 266 changed files with 4,567 additions and 904 deletions.
13 changes: 11 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"tslint.ignoreDefinitionFiles": true,
"tslint.nodePath": "./packages/build/node_modules",
"typescript.tsdk": "./packages/build/node_modules/typescript/lib"
"typescript.tsdk": "./packages/build/node_modules/typescript/lib",
"eslint.autoFixOnSave": true,
"eslint.run": "onSave",
"eslint.nodePath": "./packages/build/node_modules",
"eslint.validate": [
"javascript",
{
"language": "typescript",
"autoFix": true
}
]
}
9 changes: 5 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"args": [
"test"
],
"problemMatcher": ["$tsc", "$tslint5"]
"problemMatcher": ["$tsc", "$eslint-stylish", "$eslint-compact"]
},
{
"label": "Lint all packages",
Expand All @@ -47,10 +47,11 @@
"lint"
],
"problemMatcher": [
"$tslint5",
"$eslint-stylish",
"$eslint-compact",
{
// compilation errors - relative paths
"owner": "tslint",
"owner": "eslint",
"fileLocation": [
"relative",
"${workspaceRoot}"
Expand All @@ -66,7 +67,7 @@
},
{
// compilation errors - absolute paths
"owner": "tslint",
"owner": "eslint",
"fileLocation": "absolute",
"severity": "error",
"pattern": {
Expand Down
10 changes: 5 additions & 5 deletions benchmark/src/__tests__/benchmark.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {expect} from '@loopback/testlab';
import { expect } from '@loopback/testlab';
import * as request from 'request-promise-native';
import {Benchmark} from '..';
import {Autocannon, EndpointStats} from '../autocannon';
import { Benchmark } from '..';
import { Autocannon, EndpointStats } from '../autocannon';

const debug = require('debug')('test');

Expand All @@ -17,7 +17,7 @@ const DUMMY_STATS: EndpointStats = {

describe('Benchmark (SLOW)', function() {
// Unfortunately, the todo app requires one second to start
// tslint:disable-next-line:no-invalid-this
// eslint-disable-next-line no-invalid-this
this.timeout(5000);
it('works', async () => {
const bench = new Benchmark();
Expand All @@ -37,7 +37,7 @@ describe('Benchmark (SLOW)', function() {
async execute(
title: string,
urlPath: string,
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options?: any,
): Promise<EndpointStats> {
if (!options) options = {};
Expand Down
2 changes: 1 addition & 1 deletion benchmark/src/rest-routing/routing-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function givenRouter(router: RestRouter, spec: OpenApiSpec, count: number) {
// Make it not found
group = 'groupX';
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const request: any = {
method: 'get',
path: `/my/hello/${group}/version_${i}`,
Expand Down
25 changes: 17 additions & 8 deletions bin/sync-dev-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,28 @@ async function syncDevDeps() {
const buildDeps = require(path.join(rootPath, 'packages/build/package.json'))
.dependencies;

const masterDeps = {
typescript: buildDeps.typescript,
tslint: buildDeps.tslint,
};
const deps = [
'typescript',
'eslint',
'@typescript-eslint/eslint-plugin',
'@typescript-eslint/parser',
'eslint-plugin-eslint-plugin',
];
const masterDeps = {};
for (const d of deps) {
masterDeps[d] = buildDeps[d];
}

// Update typescript & tslint dependencies in individual packages
// Update typescript & eslint dependencies in individual packages
for (const pkg of packages) {
const data = readJsonFile(pkg.manifestLocation);
let modified = false;
for (const dep in masterDeps) {
if (data.devDependencies && dep in data.devDependencies) {
data.devDependencies[dep] = masterDeps[dep];
modified = true;
if (data.devDependencies && data.devDependencies[dep]) {
if (data.devDependencies[dep] !== masterDeps[dep]) {
data.devDependencies[dep] = masterDeps[dep];
modified = true;
}
}
}
if (!modified) continue;
Expand Down
2 changes: 1 addition & 1 deletion bin/update-greenkeeper-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if (require.main === module) updateGreenKeeperJson();
function arraysContainSameElements(actual, expected) {
return (
// Same size
actual.length == expected.length &&
actual.length === expected.length &&
// `expected` contains all elements of `actual`
actual.every(e => expected.includes(e)) &&
// `actual` contains all elements of `expected`
Expand Down
2 changes: 1 addition & 1 deletion docs/site/OpenAPI-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ additional model files are generated:
{% include code-caption.html content="src/models/perform-search-body.model.ts" %}

```ts
/* tslint:disable:no-any */
/* eslint-disable @typescript-eslint/no-explicit-any */
import {model, property} from '@loopback/repository';

/**
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Parsing-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class FileUploadController {
else {
resolve({
files: request.files,
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fields: (request as any).fields,
});
}
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Testing-your-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ const Dredd = require('dredd');

describe('API (acceptance)', () => {
let app: HelloWorldApplication;
// tslint:disable no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
let dredd: any;
before(initEnvironment);
after(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/express-composition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"devDependencies": {
"@loopback/build": "^1.5.5",
"@loopback/testlab": "^1.2.10",
"@loopback/tslint-config": "^2.0.4",
"@loopback/eslint-config": "^1.0.0-1",
"@types/express": "^4.16.1",
"@types/node": "^10.11.2",
"tslint": "^5.16.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/greeter-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@loopback/build": "^1.5.5",
"@loopback/testlab": "^1.2.10",
"@loopback/tslint-config": "^2.0.4",
"@loopback/eslint-config": "^1.0.0-1",
"@types/debug": "4.1.4",
"@types/node": "^10.11.2",
"tslint": "^5.16.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/greeter-extension/src/greeting-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class GreetingService {
* @param name - Name
*/
async greet(language: string, name: string): Promise<string> {
let greeting: string = '';
let greeting = '';

const greeter = await this.findGreeter(language);
if (greeter) {
Expand Down
132 changes: 132 additions & 0 deletions examples/hello-world/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"build:watch": "lb-tsc es2017 --outDir dist --watch",
"clean": "lb-clean *example-hello-world*.tgz dist package api-docs",
"verify": "npm pack && tar xf *example-hello-world*.tgz && tree package && npm run clean",
"lint": "npm run prettier:check && npm run tslint",
"lint:fix": "npm run tslint:fix && npm run prettier:fix",
"lint": "npm run prettier:check && npm run eslint",
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
"prettier:cli": "lb-prettier \"**/*.ts\" \"**/*.js\"",
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
"tslint": "lb-tslint",
"tslint:fix": "npm run tslint -- --fix",
"eslint": "lb-eslint",
"eslint:fix": "npm run eslint -- --fix",
"pretest": "npm run clean && npm run build",
"test": "lb-mocha --allow-console-logs \"dist/__tests__/**/*.js\"",
"posttest": "npm run lint",
Expand All @@ -43,10 +43,13 @@
"devDependencies": {
"@loopback/build": "^1.5.5",
"@loopback/testlab": "^1.2.10",
"@loopback/tslint-config": "^2.0.4",
"@loopback/eslint-config": "^1.0.0-1",
"@types/node": "^10.11.2",
"tslint": "^5.16.0",
"typescript": "^3.4.5"
"typescript": "^3.4.5",
"@typescript-eslint/eslint-plugin": "^1.4.2",
"@typescript-eslint/parser": "^1.4.2",
"eslint-plugin-eslint-plugin": "^2.0.1"
},
"keywords": [
"loopback",
Expand Down

0 comments on commit 704d4bd

Please sign in to comment.