Skip to content

Commit dabeb22

Browse files
committed
Add linting
1 parent 730876e commit dabeb22

10 files changed

+5111
-1897
lines changed

.eslintrc.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"plugins": ["import", "prettier"],
3+
"extends": ["airbnb-typescript/base", "prettier"],
4+
"parserOptions": {
5+
"project": "./tsconfig.test.json"
6+
},
7+
"ignorePatterns": ["lib/__fixtures__/**/*.ts", "jest.config.ts", "dist"],
8+
"rules": {
9+
"@typescript-eslint/await-thenable": "warn",
10+
"@typescript-eslint/no-floating-promises": [
11+
"warn",
12+
{ "ignoreIIFE": true, "ignoreVoid": false }
13+
],
14+
"@typescript-eslint/no-unused-vars": [
15+
"warn",
16+
{ "argsIgnorePattern": "^_" }
17+
],
18+
"import/order": "warn",
19+
"import/no-extraneous-dependencies": [
20+
"error",
21+
{
22+
"devDependencies": true,
23+
"optionalDependencies": true,
24+
"peerDependencies": true
25+
}
26+
],
27+
"import/prefer-default-export": "off",
28+
"no-console": ["warn"],
29+
"no-plusplus": "off",
30+
"prettier/prettier": "warn",
31+
"radix": ["error", "as-needed"]
32+
}
33+
}

.github/workflows/build.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: test
2727
if: ${{ always() }}
2828
run: npm run test
29+
- name: lint
30+
if: ${{ always() }}
31+
run: npm run lint
2932
- name: style
3033
if: ${{ always() }}
3134
run: npm run format:check

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist
2+
lib/__fixtures__

lib/index.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import TypeScriptLoader from ".";
2-
import { cosmiconfig, cosmiconfigSync } from "cosmiconfig";
31
import path from "path";
2+
import { cosmiconfig, cosmiconfigSync } from "cosmiconfig";
3+
import TypeScriptLoader from ".";
44

55
describe("TypeScriptLoader", () => {
66
const fixturesPath = path.resolve(__dirname, "__fixtures__");

lib/loader.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from "fs";
22
import path from "path";
33
import { Loader } from "cosmiconfig";
4-
54
import { TypeScriptLoader } from "./loader";
65
import { TypeScriptCompileError } from "./typescript-compile-error";
76

lib/typescript-compile-error.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ describe("TypeScriptCompileError", () => {
2020
it("should replace the legacy tsc error string", () => {
2121
const testMsg =
2222
"TypeScript compiler encountered syntax errors while transpiling. Errors: ";
23-
const testError = new Error(testMsg);
24-
const tscError = TypeScriptCompileError.fromError(testError);
23+
const legacyError = new Error(testMsg);
24+
const tscError = TypeScriptCompileError.fromError(legacyError);
2525

2626
expect(tscError).not.toContainEqual(testMsg);
2727
});
2828

2929
it("should replace the tsc error string", () => {
3030
const testMsg = "⨯ Unable to compile TypeScript:";
31-
const testError = new Error(testMsg);
32-
const tscError = TypeScriptCompileError.fromError(testError);
31+
const newError = new Error(testMsg);
32+
const tscError = TypeScriptCompileError.fromError(newError);
3333

3434
expect(tscError).not.toContainEqual(testMsg);
3535
});

lib/typescript-compile-error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export class TypeScriptCompileError extends Error {
22
constructor(message: string) {
33
super(message);
4-
this.name = this.constructor.name
4+
this.name = this.constructor.name;
55
}
66

77
public static fromError(error: Error): TypeScriptCompileError {

0 commit comments

Comments
 (0)