Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Foehn committed Nov 16, 2020
1 parent 2e391ae commit 7323a00
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 113 deletions.
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const config = {
presets: ["next/babel"],
plugins: []
plugins: [],
};

config.env = {
production: {
plugins: [...config.plugins, "transform-react-remove-prop-types"]
}
plugins: [...config.plugins, "transform-react-remove-prop-types"],
},
};

module.exports = config;
24 changes: 12 additions & 12 deletions components/__tests__/Leases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LEASES_UPDATED_SUBSCRIPTION } from "../LastUpdated";
const mocks = [
{
request: {
query: LEASES_QUERY
query: LEASES_QUERY,
},
result: {
data: {
Expand All @@ -19,24 +19,24 @@ const mocks = [
ip: "10.137.0.110",
client: "eh",
host: "host11",
timestamp: "1568228852"
}
]
}
}
timestamp: "1568228852",
},
],
},
},
},
{
request: {
query: LEASES_UPDATED_SUBSCRIPTION
query: LEASES_UPDATED_SUBSCRIPTION,
},
result: {
data: {
leasesUpdated: {
dateUpdated: new Date().toJSON()
}
}
}
}
dateUpdated: new Date().toJSON(),
},
},
},
},
];

describe("Leases", () => {
Expand Down
36 changes: 18 additions & 18 deletions components/__tests__/StaticHosts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import { MockedProvider } from "@apollo/react-testing";
import {
STATIC_HOSTS_QUERY,
ADD_STATIC_HOST,
StaticHosts
StaticHosts,
} from "../StaticHosts";

const INPUT_HOST_STATIC_HOST = {
client: "",
host: "norris",
ip: "10.137.0.1",
leaseExpiry: "24h",
mac: "02:02:02:02:02:02"
mac: "02:02:02:02:02:02",
};

const mocks = [
{
request: {
query: STATIC_HOSTS_QUERY
query: STATIC_HOSTS_QUERY,
},
result: {
data: {
Expand All @@ -31,28 +31,28 @@ const mocks = [
ip: "10.137.0.252",
client: "",
host: "rancher",
leaseExpiry: "24h"
}
]
}
}
leaseExpiry: "24h",
},
],
},
},
},
{
request: {
query: ADD_STATIC_HOST,
variables: {
staticHost: INPUT_HOST_STATIC_HOST
}
staticHost: INPUT_HOST_STATIC_HOST,
},
},
result: {
data: {
addStaticHost: {
...INPUT_HOST_STATIC_HOST,
id: "cbb586eefc8a158e6caa5a50371f1c65c61b60fe"
}
}
}
}
id: "cbb586eefc8a158e6caa5a50371f1c65c61b60fe",
},
},
},
},
];

describe("StaticHosts", () => {
Expand Down Expand Up @@ -88,13 +88,13 @@ describe("StaticHosts", () => {
await waitFor(() => screen.getByLabelText(/IP Address/));

fireEvent.change(screen.getByLabelText(/IP Address/), {
target: { value: INPUT_HOST_STATIC_HOST.ip }
target: { value: INPUT_HOST_STATIC_HOST.ip },
});
fireEvent.change(screen.getByLabelText(/Host Name/), {
target: { value: INPUT_HOST_STATIC_HOST.host }
target: { value: INPUT_HOST_STATIC_HOST.host },
});
fireEvent.change(screen.getByLabelText(/MAC Address/i), {
target: { value: INPUT_HOST_STATIC_HOST.mac }
target: { value: INPUT_HOST_STATIC_HOST.mac },
});

fireEvent.click(screen.getByText("Add"));
Expand Down
16 changes: 8 additions & 8 deletions hooks/useForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("useForm", () => {
const { result } = renderHook(() =>
useForm(submitMock, {
firstname: "",
lastname: ""
lastname: "",
})
);

Expand All @@ -18,15 +18,15 @@ describe("useForm", () => {
expect(() =>
result.current.handleChange()({
persist: () => {},
target: { value: "blah" }
target: { value: "blah" },
})
).toThrow();
});

act(() => {
result.current.handleChange({
persist: () => {},
target: { id: "firstname", value: "bill" }
target: { id: "firstname", value: "bill" },
});
});

Expand All @@ -48,14 +48,14 @@ describe("useForm", () => {
{
firstname: "",
lastname: "",
title: ""
title: "",
},
object({
firstname: string().required("First Name is Required"),
lastname: string(),
title: string()
.required("Title is Required")
.oneOf(["mr", "mrs", "ms"])
.oneOf(["mr", "mrs", "ms"]),
})
)
);
Expand All @@ -73,7 +73,7 @@ describe("useForm", () => {
act(() => {
result.current.handleChange({
persist: () => {},
target: { id: "firstname", value: "bill" }
target: { id: "firstname", value: "bill" },
});
});

Expand All @@ -83,7 +83,7 @@ describe("useForm", () => {
act(() => {
result.current.handleChange({
persist: () => {},
target: { id: "title", value: "dr" }
target: { id: "title", value: "dr" },
});
});

Expand All @@ -92,7 +92,7 @@ describe("useForm", () => {
act(() => {
result.current.handleChange({
persist: () => {},
target: { id: "title", value: "mr" }
target: { id: "title", value: "mr" },
});
});

Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
"!**/vendor/**",
"!**.config.js",
"!./coverage/**",
"!./server/**"
"!./server/**",
],

// The directory where Jest should output its coverage files
Expand Down Expand Up @@ -129,7 +129,7 @@ module.exports = {
testPathIgnorePatterns: [
"<rootDir>/server/",
"<rootDir>/.next/",
"<rootDir>/node_modules/"
"<rootDir>/node_modules/",
],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
Expand All @@ -139,7 +139,7 @@ module.exports = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "jsdom"
testEnvironment: "jsdom",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down
8 changes: 4 additions & 4 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const env = Object.entries(process.env)
const nextConfig = {
dev,
env: {
...env
...env,
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
Expand All @@ -29,15 +29,15 @@ const nextConfig = {
loader: "eslint-loader",
options: {
fix: true,
cache: true
}
cache: true,
},
});
}

// Example using webpack option
config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//));
return config;
}
},
};

module.exports = withOffline(nextConfig);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"lint-staged": {
"*.{js,jsx}": [
"eslint --fix ./",
"eslint ./",
"pretty-quick --staged"
]
},
Expand Down
8 changes: 4 additions & 4 deletions server/graphql/dhcp-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ module.exports.typeDef = gql`
}
`;

module.exports.resolvers = initialData => {
module.exports.resolvers = (initialData) => {
let dhcpRange = { ...initialData };

return {
Query: {
dhcpRange: () => dhcpRange
dhcpRange: () => dhcpRange,
},
Mutation: {
saveDHCPRange: (parent, args) => {
Expand All @@ -38,7 +38,7 @@ module.exports.resolvers = initialData => {
pubsub.publish(CONFIG_DHCP_RANGE_UPDATED, dhcpRange);

return dhcpRange;
}
}
},
},
};
};
8 changes: 4 additions & 4 deletions server/graphql/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ module.exports.typeDef = gql`
}
`;

module.exports.resolvers = initialData => {
module.exports.resolvers = (initialData) => {
let domain = { ...initialData };

return {
Query: {
domain: () => domain
domain: () => domain,
},
Mutation: {
saveDomain: (parent, args) => {
Expand All @@ -33,7 +33,7 @@ module.exports.resolvers = initialData => {
pubsub.publish(CONFIG_DOMAIN_UPDATED, domain);

return domain;
}
}
},
},
};
};
28 changes: 15 additions & 13 deletions server/graphql/leases.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports.typeDef = gql`
}
`;

const renameDnsMasqId = lease => {
const renameDnsMasqId = (lease) => {
let result = ["timestamp", "mac", "ip", "host"].reduce((obj, key) => {
obj[key] = lease[key];
return obj;
Expand All @@ -68,13 +68,15 @@ const getLeases = () => {
module.exports.resolvers = () => {
let leases = getLeases();

chokidar.watch(LEASE_FILE, { awaitWriteFinish: true }).on("change", path => {
leases = getLeases();
pubsub.publish(LEASES_UPDATED_TOPIC, {
leasesUpdated: { dateUpdated: new Date() }
chokidar
.watch(LEASE_FILE, { awaitWriteFinish: true })
.on("change", (path) => {
leases = getLeases();
pubsub.publish(LEASES_UPDATED_TOPIC, {
leasesUpdated: { dateUpdated: new Date() },
});
logInfo("leases updated");
});
logInfo("leases updated");
});

return {
DateTime,
Expand All @@ -83,20 +85,20 @@ module.exports.resolvers = () => {
const keys = Object.keys(args);

if (keys.length > 0) {
return leases.filter(l => {
return leases.filter((l) => {
let found = false;
keys.forEach(k => (found = found || l[k] === args[k]));
keys.forEach((k) => (found = found || l[k] === args[k]));
return found;
});
} else {
return leases;
}
}
},
},
Subscription: {
leasesUpdated: {
subscribe: () => pubsub.asyncIterator([LEASES_UPDATED_TOPIC])
}
}
subscribe: () => pubsub.asyncIterator([LEASES_UPDATED_TOPIC]),
},
},
};
};
Loading

0 comments on commit 7323a00

Please sign in to comment.