Skip to content

Commit

Permalink
chore: upgrade dependencies (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjylewis authored Mar 22, 2022
1 parent a808105 commit 0c2bb75
Show file tree
Hide file tree
Showing 25 changed files with 9,145 additions and 17,268 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
34 changes: 17 additions & 17 deletions __tests__/cli/check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const { run } = require("../../lib/engine");
const log = require("../../lib/log");
const stripAnsi = require("strip-ansi");
const EsplintError = require("../../lib/EsplintError");
const git = require("simple-git/promise");
const git = require("simple-git");

jest.mock("../../lib/engine");
jest.mock("../../lib/log");
jest.mock("simple-git/promise", () => {
jest.mock("simple-git", () => {
const gitAdd = jest.fn();
return () => ({
add: gitAdd
add: gitAdd,
});
});
process.exit = jest.fn();
Expand All @@ -19,7 +19,7 @@ beforeEach(() => {
run.mockReset();
run.mockImplementation(() => ({
results: [],
hasError: false
hasError: false,
}));

process.argv = [];
Expand Down Expand Up @@ -76,7 +76,7 @@ it("should print exception and exit with error code", () => {
});

it("should print message of EsplintError and exit with error code", () => {
log.createError.mockImplementation(i => i);
log.createError.mockImplementation((i) => i);
run.mockImplementation(() => {
throw new EsplintError("this is an error");
});
Expand All @@ -90,7 +90,7 @@ it("should print message of EsplintError and exit with error code", () => {
it("should print tip and exit with error code if there was an error", async () => {
const runPromise = Promise.resolve({
results: [],
hasError: true
hasError: true,
});
run.mockReturnValue(runPromise);
cli([]);
Expand All @@ -108,10 +108,10 @@ it("should show success message if no errors", async () => {
results: [
{
type: "info",
message: "this is info"
}
message: "this is info",
},
],
hasError: false
hasError: false,
});
run.mockReturnValue(runPromise);
cli([]);
Expand All @@ -124,7 +124,7 @@ it("should show success message if no errors", async () => {
it("should show success message if the only results are info types", async () => {
const runPromise = Promise.resolve({
results: [],
hasError: false
hasError: false,
});
run.mockReturnValue(runPromise);
cli([]);
Expand All @@ -137,7 +137,7 @@ it("should show success message if the only results are info types", async () =>
it("should stage record file if flag is passed", async () => {
const runPromise = Promise.resolve({
results: [],
hasError: false
hasError: false,
});
run.mockReturnValue(runPromise);
const gitAddPromise = Promise.resolve();
Expand All @@ -153,7 +153,7 @@ it("should stage record file if flag is passed", async () => {
);
expect(git().add).toHaveBeenCalledTimes(1);
expect(git().add).toHaveBeenCalledWith([
expect.stringContaining(".esplint.rec.json")
expect.stringContaining(".esplint.rec.json"),
]);
expect(log.log).toHaveBeenCalledWith("Record file staged.");
});
Expand All @@ -163,18 +163,18 @@ it("should properly log the results", async () => {
results: [
{
type: "error",
message: "this is an error"
message: "this is an error",
},
{
type: "warning",
message: "this is an warning"
message: "this is an warning",
},
{
type: "info",
message: "this is info"
}
message: "this is info",
},
],
hasError: true
hasError: true,
});
run.mockReturnValue(runPromise);

Expand Down
40 changes: 20 additions & 20 deletions __tests__/cli/stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ beforeEach(() => {
const mockedRuleStatsWithViolations = {
"no-console": {
count: 2,
files: ["index.js", "not-index.js"]
files: ["index.js", "not-index.js"],
},
"other-rule": {
count: 100,
files: ["file.js", "other-file.js", "other-other-file.js"]
files: ["file.js", "other-file.js", "other-other-file.js"],
},
"no-violations": {
count: 0,
files: []
}
files: [],
},
};

const mockedRuleStatsWithoutViolations = {
"no-console": {
count: 0,
files: []
files: [],
},
"other-rule": {
count: 0,
files: []
files: [],
},
"no-violations": {
count: 0,
files: []
}
files: [],
},
};

it("should print warning when record file doesn't exist", () => {
Expand All @@ -65,8 +65,8 @@ it("should print the count and list files per rule", () => {
expect(log.log).toHaveBeenCalled();
const output = stripAnsi(log.log.mock.calls[0][0])
.split("\n")
.map(l => l.trim())
.filter(l => l.length > 0);
.map((l) => l.trim())
.filter((l) => l.length > 0);

const expectedOutput = [
/"no-console": 2/,
Expand All @@ -81,7 +81,7 @@ it("should print the count and list files per rule", () => {
/other-file\.js/,
/other-other-file\.js/,

/Total: 102/
/Total: 102/,
];

output.forEach((line, i) => {
Expand All @@ -96,8 +96,8 @@ it("should print the count and list files per rule", () => {
expect(log.log).toHaveBeenCalled();
const output = stripAnsi(log.log.mock.calls[0][0])
.split("\n")
.map(l => l.trim())
.filter(l => l.length > 0);
.map((l) => l.trim())
.filter((l) => l.length > 0);

const expectedOutput = [
/"no-console": 0/,
Expand All @@ -109,7 +109,7 @@ it("should print the count and list files per rule", () => {
/"other-rule": 0/,
/No files/,

/No violations!/
/No violations!/,
];

output.forEach((line, i) => {
Expand All @@ -124,15 +124,15 @@ it("should print the count and list files per rule in compact mode", () => {
expect(log.log).toHaveBeenCalled();
const output = stripAnsi(log.log.mock.calls[0][0])
.split("\n")
.map(l => l.trim())
.filter(l => l.length > 0);
.map((l) => l.trim())
.filter((l) => l.length > 0);

const expectedOutput = [
/"no-console": 2/,
/"no-violations": 0/,
/"other-rule": 100/,

/Total: 102/
/Total: 102/,
];

output.forEach((line, i) => {
Expand All @@ -147,15 +147,15 @@ it("should print the count and list files per rule in compact mode", () => {
expect(log.log).toHaveBeenCalled();
const output = stripAnsi(log.log.mock.calls[0][0])
.split("\n")
.map(l => l.trim())
.filter(l => l.length > 0);
.map((l) => l.trim())
.filter((l) => l.length > 0);

const expectedOutput = [
/"no-console": 0/,
/"no-violations": 0/,
/"other-rule": 0/,

/No violations!/
/No violations!/,
];

output.forEach((line, i) => {
Expand Down
Loading

0 comments on commit 0c2bb75

Please sign in to comment.