Skip to content

Commit 44185a7

Browse files
committed
feat: replace tslint with eslint
See https://github.com/typescript-eslint/typescript-eslint
1 parent 8a6c072 commit 44185a7

File tree

327 files changed

+9169
-1703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+9169
-1703
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist/
33
coverage/
44
api-docs/
55
/sandbox
6+
**/*.d.ts

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ matrix:
2727
env: TASK=code-lint
2828
# Running Code Linter -- Requires @loopback/build so it's bootstrapped
2929
script:
30-
- lerna bootstrap --scope @loopback/build --scope @loopback/tslint-config --scope @loopback/eslint-config
30+
- lerna bootstrap --scope @loopback/build --scope @loopback/eslint-config
3131
- npm run lint
3232
- node_js: "8"
3333
os: linux

.vscode/settings.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
},
2727
"files.insertFinalNewline": true,
2828
"files.trimTrailingWhitespace": true,
29-
"tslint.ignoreDefinitionFiles": true,
30-
"tslint.nodePath": "./packages/build/node_modules",
31-
"typescript.tsdk": "./packages/build/node_modules/typescript/lib"
29+
"typescript.tsdk": "./packages/build/node_modules/typescript/lib",
30+
"eslint.autoFixOnSave": true,
31+
"eslint.run": "onSave",
32+
"eslint.nodePath": "./packages/build/node_modules",
33+
"eslint.validate": [
34+
"javascript",
35+
{
36+
"language": "typescript",
37+
"autoFix": true
38+
}
39+
]
3240
}

.vscode/tasks.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"args": [
3535
"test"
3636
],
37-
"problemMatcher": ["$tsc", "$tslint5"]
37+
"problemMatcher": ["$tsc", "$eslint-stylish", "$eslint-compact"]
3838
},
3939
{
4040
"label": "Lint all packages",
@@ -47,10 +47,11 @@
4747
"lint"
4848
],
4949
"problemMatcher": [
50-
"$tslint5",
50+
"$eslint-stylish",
51+
"$eslint-compact",
5152
{
5253
// compilation errors - relative paths
53-
"owner": "tslint",
54+
"owner": "eslint",
5455
"fileLocation": [
5556
"relative",
5657
"${workspaceRoot}"
@@ -66,7 +67,7 @@
6667
},
6768
{
6869
// compilation errors - absolute paths
69-
"owner": "tslint",
70+
"owner": "eslint",
7071
"fileLocation": "absolute",
7172
"severity": "error",
7273
"pattern": {

benchmark/src/__tests__/benchmark.integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const DUMMY_STATS: EndpointStats = {
1717

1818
describe('Benchmark (SLOW)', function() {
1919
// Unfortunately, the todo app requires one second to start
20-
// tslint:disable-next-line:no-invalid-this
20+
// eslint-disable-next-line no-invalid-this
2121
this.timeout(5000);
2222
it('works', async () => {
2323
const bench = new Benchmark();
@@ -37,7 +37,7 @@ describe('Benchmark (SLOW)', function() {
3737
async execute(
3838
title: string,
3939
urlPath: string,
40-
// tslint:disable-next-line:no-any
40+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4141
options?: any,
4242
): Promise<EndpointStats> {
4343
if (!options) options = {};

benchmark/src/rest-routing/routing-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function givenRouter(router: RestRouter, spec: OpenApiSpec, count: number) {
9090
// Make it not found
9191
group = 'groupX';
9292
}
93-
// tslint:disable-next-line:no-any
93+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9494
const request: any = {
9595
method: 'get',
9696
path: `/my/hello/${group}/version_${i}`,

bin/build-docs-site.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ REPO_ROOT=$DIR/..
2222
pushd $REPO_ROOT >/dev/null
2323

2424
# Update apidocs
25-
lerna bootstrap --scope @loopback/tsdocs
25+
lerna bootstrap
2626
lerna run --scope @loopback/docs prepack
2727

2828
# Clean up sandbox/loopback.io directory
@@ -31,8 +31,8 @@ rm -rf sandbox/loopback.io/
3131
# Shadow clone the `strongloop/loopback.io` github repo
3232
git clone --depth 1 https://github.com/strongloop/loopback.io.git sandbox/loopback.io
3333

34-
# Bootstrap the `loopback.io` package
35-
lerna bootstrap --scope loopback.io-workflow-scripts --scope @loopback/docs
34+
# Add loopback.io-workflow-scripts with @loopback/docs linked
35+
lerna bootstrap --scope @loopback/docs --scope loopback.io-workflow-scripts
3636

3737
pushd $REPO_ROOT/sandbox/loopback.io/ >/dev/null
3838

bin/run-lerna.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function run(argv, options) {
1919
const rootPath = project.rootPath;
2020

2121
process.env.LERNA_ROOT_PATH = rootPath;
22-
let args = argv.slice(2);
22+
const args = argv.slice(2);
2323

2424
return build.runCLI('lerna/cli', args, options);
2525
}

bin/sync-dev-deps.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,27 @@ async function syncDevDeps() {
2525
const buildDeps = require(path.join(rootPath, 'packages/build/package.json'))
2626
.dependencies;
2727

28-
const masterDeps = {
29-
typescript: buildDeps.typescript,
30-
tslint: buildDeps.tslint,
31-
};
28+
const deps = [
29+
'typescript',
30+
'eslint',
31+
'@typescript-eslint/eslint-plugin',
32+
'@typescript-eslint/parser',
33+
'eslint-plugin-eslint-plugin',
34+
];
35+
const masterDeps = {};
36+
for (const d of deps) {
37+
if (buildDeps[d] == null) {
38+
console.error(
39+
'Dependency %s is missing in packages/build/package.json',
40+
d,
41+
);
42+
}
43+
masterDeps[d] = buildDeps[d];
44+
}
3245

33-
// Update typescript & tslint dependencies in individual packages
46+
// Update typescript & eslint dependencies in individual packages
3447
for (const pkg of packages) {
48+
if (pkg.name === '@loopback/build') continue;
3549
const pkgFile = pkg.manifestLocation;
3650
updatePackageJson(pkgFile, masterDeps);
3751
}
@@ -48,9 +62,20 @@ async function syncDevDeps() {
4862
*/
4963
function updatePackageJson(pkgFile, masterDeps) {
5064
const data = readJsonFile(pkgFile);
65+
const isExample = data.name.startsWith('@loopback/example-');
66+
const isRoot = data.name === 'loopback-next';
67+
5168
let modified = false;
69+
if (isExample && data.devDependencies && data.devDependencies.tslint) {
70+
delete data.devDependencies.tslint;
71+
modified = true;
72+
}
5273
for (const dep in masterDeps) {
53-
if (data.devDependencies && dep in data.devDependencies) {
74+
if (
75+
data.devDependencies &&
76+
// Force update for examples and loopback-next
77+
(isExample || isRoot || dep in data.devDependencies)
78+
) {
5479
modified = modified || data.devDependencies[dep] !== masterDeps[dep];
5580
data.devDependencies[dep] = masterDeps[dep];
5681
}

docs/site/Application-generator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lb4 [app] [options] [<name>]
2222

2323
`--outDir` : Project root directory for the application.
2424

25-
`--tslint` : Add TSLint to LoopBack4 application project.
25+
`--eslint` : Add ESLint to LoopBack4 application project.
2626

2727
`--prettier` : Add Prettier to LoopBack4 application project.
2828

@@ -65,7 +65,7 @@ The tool will prompt you for:
6565
help format, test, and build a LoopBack4 application. Defaults to `true` for
6666
all of the modules. The prompted modules are:
6767

68-
- [`tslint`](https://www.npmjs.com/package/tslint)
68+
- [`eslint`](https://www.npmjs.com/package/eslint)
6969
- [`prettier`](https://www.npmjs.com/package/prettier)
7070
- [`mocha`](https://www.npmjs.com/package/mocha)
7171
- [`@loopback/build`](https://www.npmjs.com/package/@loopback/build)

0 commit comments

Comments
 (0)