Skip to content

Commit

Permalink
Eslint (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo committed Oct 27, 2020
1 parent b676cf5 commit adac94c
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/ban-ts-comment": ["off"],
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "none" } }],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-use-before-define": ["error", "nofunc"]
}
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docs: # runs the documentation tests
# node_modules/.bin/text-run --offline --format dot

fix:
tslint --project tsconfig.json --fix
${CURDIR}/node_modules/.bin/eslint . --ext .ts --fix
prettier --write src/*.ts
prettier --write test/*.ts
prettier --write *.md
Expand All @@ -22,7 +22,7 @@ help: # prints all make targets

lint: # lints all files
node_modules/.bin/tsc --noEmit
node_modules/.bin/tslint --project .
${CURDIR}/node_modules/.bin/eslint --ext .ts .
node_modules/.bin/prettier -c "src/*.ts"
node_modules/.bin/prettier -c "test/*.ts"
node_modules/.bin/prettier -c "*.md"
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
"@types/diff": "4.0.2",
"@types/mocha": "8.0.3",
"@types/node": "14.14.5",
"@typescript-eslint/eslint-plugin": "4.5.0",
"@typescript-eslint/parser": "4.5.0",
"coveralls": "3.1.0",
"eslint": "7.12.0",
"eslint-config-prettier": "6.14.0",
"mocha": "8.2.0",
"nyc": "15.1.0",
"prettier": "2.1.2",
"source-map-support": "0.5.19",
"strip-ansi": "6.0.0",
"ts-node": "9.0.0",
"tslint": "6.1.3",
"typescript": "4.0.5"
},
"files": [
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as diff from "diff"
* Checks the two given strings character-by-character for equality.
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
*/
export function chars(actual: string, expected: string, message = "mismatching strings") {
export function chars(actual: string, expected: string, message = "mismatching strings"): void {
if (actual == null) {
throw new Error("AssertNoDiff: actual value not provided")
}
Expand All @@ -22,7 +22,11 @@ export function chars(actual: string, expected: string, message = "mismatching s
* Checks the two given Objects for equality.
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
*/
export function json(actual: object, expected: object, message = "mismatching objects") {
export function json(
actual: Record<string, unknown>,
expected: Record<string, unknown>,
message = "mismatching objects"
): void {
if (!actual) {
throw new Error("AssertNoDiff: actual value not provided")
}
Expand All @@ -40,7 +44,7 @@ export function json(actual: object, expected: object, message = "mismatching ob
* Extra whitespace is ignored.
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
*/
export function trimmedLines(actual: string, expected: string, message = "mismatching lines") {
export function trimmedLines(actual: string, expected: string, message = "mismatching lines"): void {
if (actual == null) {
throw new Error("AssertNoDiff: actual value not provided")
}
Expand All @@ -57,7 +61,7 @@ export function trimmedLines(actual: string, expected: string, message = "mismat
* Checks the two given strings word-by-word for equality treating whitespace as significant.
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
*/
export function wordsWithSpace(actual: string, expected: string, message = "mismatching words") {
export function wordsWithSpace(actual: string, expected: string, message = "mismatching words"): void {
if (actual == null) {
throw new Error("AssertNoDiff: actual value not provided")
}
Expand Down
10 changes: 0 additions & 10 deletions tslint.yml

This file was deleted.

Loading

0 comments on commit adac94c

Please sign in to comment.