Skip to content

Commit

Permalink
chore: Run prettier formatting on codebase
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Burnes <andrew.burnes@gsa.gov>
  • Loading branch information
apburnes committed Oct 29, 2024
1 parent 0819597 commit cbdde6d
Show file tree
Hide file tree
Showing 666 changed files with 21,731 additions and 12,948 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"presets": [
[
"@babel/preset-env", {
"@babel/preset-env",
{
"targets": {
"browsers": "last 2 versions"
}
Expand Down
32 changes: 20 additions & 12 deletions .cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@
"schema_pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w \\-'])+([\\s\\S]*)",
"bump_pattern": "^(.+!|BREAKING CHANGE|chore|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\-\\.]+\\))?:",
"bump_map": {
".+!": "MAJOR",
"BREAKING CHANGE": "MAJOR",
"feat": "MINOR",
"fix": "PATCH",
"chore": "PATCH",
"docs": "PATCH",
"perf": "PATCH",
"refactor": "PATCH",
"revert": "MINOR",
"style": "PATCH",
"test": "PATCH"
".+!": "MAJOR",
"BREAKING CHANGE": "MAJOR",
"feat": "MINOR",
"fix": "PATCH",
"chore": "PATCH",
"docs": "PATCH",
"perf": "PATCH",
"refactor": "PATCH",
"revert": "MINOR",
"style": "PATCH",
"test": "PATCH"
},
"change_type_order": ["Breaking Changes", "Added", "Fixed", "Performance", "Reverted", "Maintenance", "Documentation"],
"change_type_order": [
"Breaking Changes",
"Added",
"Fixed",
"Performance",
"Reverted",
"Maintenance",
"Documentation"
],
"commit_parser": "^((?P<change_type>chore|docs|feat|fix|perf|refactor|revert|style|test|BREAKING CHANGE)(?:\\((?P<scope>[^()\r\n]*)\\)|\\()?(?P<breaking>!)?|\\w+!):\\s(?P<message>.*)?",
"changelog_pattern": "^(.+!|BREAKING CHANGE|chore|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\-\\.]+\\))?:",
"change_type_map": {
Expand Down
9 changes: 2 additions & 7 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"reporter": [
"lcov",
"html"
],
"extension": [
".jsx"
],
"reporter": ["lcov", "html"],
"extension": [".jsx"],
"cache": true
}
5 changes: 4 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"singleQuote": true
"singleQuote": true,
"printWidth": 90,
"useTabs": false,
"tabWidth": 2
}
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ lint-client: ## Lint admin client code

lint: lint-server lint-client ## Lint project

lint-fix: ## lint and fix
lint-fix: ## lint and fix
docker compose run --rm app yarn lint --fix

format:
docker compose run --rm app yarn format

format-check:
docker compose run --rm app yarn format:check

migrate: ## Run database migrations
docker compose run --rm app yarn migrate:up

Expand Down Expand Up @@ -70,4 +76,4 @@ everything: # When you switch to a new branch and need to rebuild everything
make install
make migrate
make seed
make start
make start
9 changes: 8 additions & 1 deletion admin-client/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import pluginJs from '@eslint/js';
import eslintPluginSvelte from 'eslint-plugin-svelte';

export default [
{ languageOptions: { globals: { ...globals.browser, process: false } } },
{
languageOptions: {
globals: {
...globals.browser,
process: false,
},
},
},
{ files: ['**/*.svelte'] },
{
ignores: ['public/build', 'rollup.config.js'],
Expand Down
27 changes: 13 additions & 14 deletions admin-client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<!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='#333333'>
<link rel="shortcut icon" href="/favicon.ico">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="theme-color" content="#333333" />
<link rel="shortcut icon" href="/favicon.ico" />

<title>Pages Admin</title>
<link rel='stylesheet' href='/uswds.min.css'>
<link rel='stylesheet' href='/devtools.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<title>Pages Admin</title>
<link rel="stylesheet" href="/uswds.min.css" />
<link rel="stylesheet" href="/devtools.css" />
<link rel="stylesheet" href="/build/bundle.css" />

<script type="module" defer src='/build/bundle.js'></script>
</head>
<body>
</body>
<script type="module" defer src="/build/bundle.js"></script>
</head>
<body></body>
</html>
5 changes: 1 addition & 4 deletions admin-client/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export default {
dest: 'public',
},
{
src: [
`${uswds}/css/uswds.min.css`,
`${uswds}/css/uswds.min.css.map`,
],
src: [`${uswds}/css/uswds.min.css`, `${uswds}/css/uswds.min.css.map`],
dest: 'public',
},
],
Expand Down
4 changes: 3 additions & 1 deletion admin-client/src/flows/destroySite.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ function destroy(site) {
try {
await destroySite(site.id);
page('/sites');
return notification.setSuccess(`Site ${site.id}: ${site.repository} deleted successfully!`);
return notification.setSuccess(
`Site ${site.id}: ${site.repository} deleted successfully!`,
);
} catch (error) {
return notification.setError(`Unable to delete site ${site.id}: ${error.message}`);
}
Expand Down
12 changes: 9 additions & 3 deletions admin-client/src/flows/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { notification } from '../stores';
import { deactivateOrganization, activateOrganization } from '../lib/api';

async function deactivate(id, redirectTo) {
if (!window.confirm('Are you sure you want to deactivate this organization?')) { return null; }
if (!window.confirm('Are you sure you want to deactivate this organization?')) {
return null;
}
try {
await deactivateOrganization(id);
page(redirectTo);
return notification.setSuccess(`Organization ${id} deactivated successfully!`);
} catch (error) {
return notification.setError(`Unable to deactivate organization ${id}: ${error.message}`);
return notification.setError(
`Unable to deactivate organization ${id}: ${error.message}`,
);
}
}

Expand All @@ -19,7 +23,9 @@ async function activate(id, redirectTo) {
page(redirectTo);
return notification.setSuccess(`Organization ${id} activated successfully!`);
} catch (error) {
return notification.setError(`Unable to activate organization ${id}: ${error.message}`);
return notification.setError(
`Unable to activate organization ${id}: ${error.message}`,
);
}
}

Expand Down
4 changes: 3 additions & 1 deletion admin-client/src/helpers/downloadCSV.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const downloadCSV = async (fetchCSV, filename) => {
const csv = await fetchCSV();
const blob = new Blob([csv], { type: 'application/octet-stream' });
const blob = new Blob([csv], {
type: 'application/octet-stream',
});
const aElement = document.createElement('a');
aElement.setAttribute('download', filename);
const href = URL.createObjectURL(blob);
Expand Down
98 changes: 61 additions & 37 deletions admin-client/src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,35 @@ function _setSearchString(query = {}) {
return search.toString();
}

async function _fetch(path, fetchOpts = {}, apiOpts = { handleError: true }) {
const fetchOptions = { ...defaultOptions, ...fetchOpts };
async function _fetch(
path,
fetchOpts = {},
apiOpts = {
handleError: true,
},
) {
const fetchOptions = {
...defaultOptions,
...fetchOpts,
};
if (!['GET', 'HEAD', 'OPTIONS'].includes(fetchOptions.method)) {
fetchOptions.headers['x-csrf-token'] = session.csrfToken();
}

let request = fetch(`${apiUrl}/admin${path}`, fetchOptions)
.then(async (r) => {
if (r.ok) return r.json();
if (r.status === 401) {
authLogout();
return null;
}
if (r.status === 422) {
const json = await r.json();
const error = new Error(json.message || r.statusText);
error.errors = json.errors;
throw error;
}
throw new Error(r.statusText);
});
let request = fetch(`${apiUrl}/admin${path}`, fetchOptions).then(async (r) => {
if (r.ok) return r.json();
if (r.status === 401) {
authLogout();
return null;
}
if (r.status === 422) {
const json = await r.json();
const error = new Error(json.message || r.statusText);
error.errors = json.errors;
throw error;
}
throw new Error(r.statusText);
});

if (apiOpts.handleError) {
request = request.catch((e) => {
Expand All @@ -55,24 +63,25 @@ async function _fetch(path, fetchOpts = {}, apiOpts = { handleError: true }) {
}

async function _fetchAttachedFile(path) {
const fetchOptions = { ...defaultOptions };
const fetchOptions = {
...defaultOptions,
};
fetchOptions.headers['x-csrf-token'] = session.csrfToken();

let request = fetch(`${apiUrl}/admin${path}`, fetchOptions)
.then(async (r) => {
if (r.ok) return r.text();
if (r.status === 401) {
authLogout();
return null;
}
if (r.status === 422) {
const json = await r.json();
const error = new Error(json.message || r.statusText);
error.errors = json.errors;
throw error;
}
throw new Error(r.statusText);
});
let request = fetch(`${apiUrl}/admin${path}`, fetchOptions).then(async (r) => {
if (r.ok) return r.text();
if (r.status === 401) {
authLogout();
return null;
}
if (r.status === 422) {
const json = await r.json();
const error = new Error(json.message || r.statusText);
error.errors = json.errors;
throw error;
}
throw new Error(r.statusText);
});

request = request.catch((e) => {
notification.setError(`API request failed: ${e.message}`);
Expand All @@ -84,7 +93,10 @@ async function _fetchAttachedFile(path) {
}

function destroy(path, body) {
return _fetch(path, { method: 'DELETE', body: JSON.stringify(body) });
return _fetch(path, {
method: 'DELETE',
body: JSON.stringify(body),
});
}

function get(path, query) {
Expand All @@ -101,11 +113,21 @@ function getAttachedFile(path) {
}

function post(path, body = {}, opts = {}) {
return _fetch(path, { method: 'POST', body: JSON.stringify(body) }, opts);
return _fetch(
path,
{
method: 'POST',
body: JSON.stringify(body),
},
opts,
);
}

function put(path, body) {
return _fetch(path, { method: 'PUT', body: JSON.stringify(body) });
return _fetch(path, {
method: 'PUT',
body: JSON.stringify(body),
});
}

async function destroySite(id) {
Expand All @@ -117,7 +139,9 @@ async function fetchMe() {
}

function fetchBuildLogEventSource(id, onMessage) {
const es = new EventSource(`${apiUrl}/admin/builds/${id}/log`, { withCredentials: true });
const es = new EventSource(`${apiUrl}/admin/builds/${id}/log`, {
withCredentials: true,
});
es.addEventListener('message', onMessage);
es.addEventListener('error', (error) => {
console.error('EventSource failed:', error);
Expand Down
12 changes: 2 additions & 10 deletions admin-client/src/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ function externalAuth(path, action, hidden = false) {
if (hidden) {
opts = 'width=1,height=1,top=0,left=0';
} else {
const {
width, height, top, left,
} = calcWindow();
const { width, height, top, left } = calcWindow();
opts = `resizable=yes,scrollbars=yes,width=${width},height=${height},top=${top},left=${left}`;
}

Expand Down Expand Up @@ -76,10 +74,4 @@ function logout() {
page('/login');
}

export {
authenticate,
deauthenticate,
init,
login,
logout,
};
export { authenticate, deauthenticate, init, login, logout };
Loading

0 comments on commit cbdde6d

Please sign in to comment.