Skip to content

Commit

Permalink
Trunk linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsargent committed Jun 12, 2024
1 parent be25f98 commit 5c247eb
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 63 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ module.exports = {
// 'svelte/rule-name': 'error'
},
parser: "@typescript-eslint/parser",
parserOptions: {
// ...
project: "tsconfig.json",
extraFileExtensions: [".svelte"], // This is a required setting in `@typescript-eslint/parser` v4.24.0.
},
overrides: [
{
files: ["*.svelte"],
Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

custom: ["https://electionscience.org/donate"]
custom: [https://electionscience.org/donate]
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: npm # See documentation for possible values
directory: / # Location of package manifests
schedule:
interval: "weekly"
interval: weekly
3 changes: 2 additions & 1 deletion .trunk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
shims
tmp
27 changes: 13 additions & 14 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
version: 0.1
cli:
version: 1.10.0
version: 1.22.2
plugins:
sources:
- id: trunk
ref: v0.0.17
ref: v1.6.0
uri: https://github.com/trunk-io/plugins
lint:
disabled:
- gitleaks
enabled:
- eslint@8.42.0
- yamllint@1.32.0
- actionlint@1.6.24
- eslint@8.57.0
- yamllint@1.35.1
- actionlint@1.7.1
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
disabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
runtimes:
enabled:
- [email protected]
- go@1.19.5
- go@1.21.0
- [email protected]
actions:
disabled:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ To add to the report, edit `./load-report.js` with the data from the election.
Submit a pull request with the updated `data.db`.

## Deployment

The site is hosted on github pages. Merge to main and it'll auto deploy.
Site is hosted on github pages. Merge to main and it'll auto-deploy.

16 changes: 11 additions & 5 deletions load-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ function addReportAndCandidates(report, candidates) {
report.notes,
report.ballotCount,
report.path,
report.hidden
report.hidden,
);

// Get the last inserted row ID
const reportId = result.lastInsertRowid;

// Insert candidates
for (const candidate of candidates) {
insertCandidate.run(reportId, candidate.name, candidate.votes, candidate.winner);
insertCandidate.run(
reportId,
candidate.name,
candidate.votes,
candidate.winner,
);
}
});

Expand All @@ -61,11 +66,12 @@ const report = {
officeName: "City Commissioner",
jurisdictionName: "Fargo, ND",
electionName: "Primary Election",
website: "https://results.sos.nd.gov/resultsSW.aspx?text=All&type=CIALL&map=CTY&area=Fargo&name=Fargo",
website:
"https://results.sos.nd.gov/resultsSW.aspx?text=All&type=CIALL&map=CTY&area=Fargo&name=Fargo",
notes: "",
ballotCount: 14781,
path: "us/nd/fargo/2024/06",
hidden: 0
hidden: 0,
};

const candidates = [
Expand All @@ -76,7 +82,7 @@ const candidates = [
{ name: "Anna Johnson", votes: 3545, winner: 0 },
{ name: "Delson Saintal", votes: 2378, winner: 0 },
{ name: "Nathan Pullen", votes: 1879, winner: 0 },
{ name: "write-in", votes: 85, winner: 0 }
{ name: "write-in", votes: 85, winner: 0 },
];

// Add the report and candidates to the database
Expand Down
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cy:run": "cypress run",
"cy:open": "cypress open",
"test": "run-p --race dev cy:run",
"lint": "prettier --check --plugin-search-dir=. .",
"lint": "trunk check",
"format": "prettier --write --plugin-search-dir=. .",
"svelte-check": "svelte-check"
},
Expand All @@ -28,16 +28,7 @@
"@sveltejs/kit": "^1.30.4",
"@tsconfig/svelte": "^3.0.0",
"@types/better-sqlite3": "^7.6.4",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"eslint": "^8.42.0",
"eslint-config-standard-with-typescript": "^35.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-svelte": "^2.30.0",
"marked": "^4.0.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"rollup": "^2.79.1",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
Expand Down
31 changes: 20 additions & 11 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="theme-color" content="#437527"/>
<link rel="manifest" crossorigin="use-credentials" href="manifest.json" />
<meta name="description" content="approval.vote: detailed reports on approval voting elections.">
<meta name="theme-color" content="#437527" />
<link rel="manifest" crossorigin="use-credentials" href="/manifest.json" />
<meta
name="description"
content="approval.vote: detailed reports on approval voting elections."
/>
<!-- Google tag (gtag.js) -->

%sveltekit.head%
</head>
<div style="display: contents">%sveltekit.body%</div>
<script defer async src="https://www.googletagmanager.com/gtag/js?id=G-9FXGFEC813"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<script
defer
async
src="https://www.googletagmanager.com/gtag/js?id=G-9FXGFEC813"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag('config', 'G-9FXGFEC813');
</script>
gtag("config", "G-9FXGFEC813");
</script>
</html>
4 changes: 2 additions & 2 deletions src/lib/components/report_components/VoteCounts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
class={candidate.winner === true ? '' : 'eliminated'}
transform={`translate(0 ${outerHeight * (i + 0.5)})`}
>
<text font-size="12" text-anchor="end" dominant-baseline="middle">
<text font-size="90%" text-anchor="end" dominant-baseline="middle">
{candidate.name}
</text>
<g transform={`translate(5 ${-innerHeight / 2 - 1})`}>
Expand All @@ -61,7 +61,7 @@
/>
</g>
<text
font-size="12"
font-size="90%"
dominant-baseline="middle"
x={10 + scale * candidate.votes}
>
Expand Down
10 changes: 5 additions & 5 deletions src/lib/server/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function createElection(row: IElectionIndexEntry, contest: IContestIndexEntry) {
// Helper function to add a contest to an existing election
function addContestToElection(
election: IElectionIndexEntry,
contest: IContestIndexEntry
contest: IContestIndexEntry,
) {
election.contests.push(contest);
election.contests.sort((b: IContestIndexEntry, a: IContestIndexEntry) => {
Expand Down Expand Up @@ -93,7 +93,7 @@ export function getIndex(): IReportIndex {
const electionsByYear = rows.reduce(
(
grouped: IReportIndexByYear,
row: IElectionIndexEntry
row: IElectionIndexEntry,
): IReportIndexByYear => {
const year = new Date(row.date).getFullYear();
const winners = getWinners(row.id); // get winners for this report
Expand All @@ -104,7 +104,7 @@ export function getIndex(): IReportIndex {
}

const existingElectionIndex = grouped[year].findIndex(
(election: IElectionIndexEntry) => election.path === row.path
(election: IElectionIndexEntry) => election.path === row.path,
);

if (existingElectionIndex === -1) {
Expand All @@ -115,11 +115,11 @@ export function getIndex(): IReportIndex {

return grouped;
},
{}
{},
);

const groupedArray = Object.entries(
electionsByYear as IReportIndexByYear
electionsByYear as IReportIndexByYear,
).sort((a, b) => parseInt(b[0]) - parseInt(a[0]));

// Convert the reversed array back to a Map
Expand Down
2 changes: 1 addition & 1 deletion src/routes/card/[...path]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export async function load({ params }) {
message: "Not found",
});
}
return { report: report, path: params.path };
return { report, path: params.path };
}
7 changes: 5 additions & 2 deletions src/routes/report/[...path]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { getReport } from "$lib/server/reports";
export async function load({ params }) {
try {
const report = getReport(params.path);
return { report: report, path: params.path };
if (!report) {
throw error(404, { message: "Not found" });
}
return { report, path: params.path };
} catch (err) {
return error(404, { message: "Not found" });
throw error(404, { message: "Not found" });
}
}
2 changes: 1 addition & 1 deletion static/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body {

h3 {
padding: 30px;
font-size: 30pt;
font-size: 200%;
margin-bottom: 20px;
}

Expand Down
Binary file modified static/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"

},
{
"src": "icons/icon-512x512.png",
Expand Down

0 comments on commit 5c247eb

Please sign in to comment.