Skip to content

Commit

Permalink
chore: Update linting and formatting
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 28, 2024
1 parent 78546af commit 5c1edca
Show file tree
Hide file tree
Showing 119 changed files with 1,269 additions and 826 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

78 changes: 0 additions & 78 deletions .eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore artifacts:
build
coverage

Ignore All Non JS
**/*.yml
**/*.md
**/*.css
**/*.scss
**/*.njk
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
28 changes: 0 additions & 28 deletions admin-client/.eslintrc.json

This file was deleted.

25 changes: 25 additions & 0 deletions admin-client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import eslintPluginSvelte from 'eslint-plugin-svelte';

export default [
{ languageOptions: { globals: { ...globals.browser, process: false } } },
{ files: ['**/*.svelte'] },
{
ignores: ['public/build', 'rollup.config.js'],
},
pluginJs.configs.recommended,
...eslintPluginSvelte.configs['flat/recommended'],
{
rules: {
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
];
12 changes: 0 additions & 12 deletions admin-client/jest.config.js

This file was deleted.

6 changes: 4 additions & 2 deletions admin-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"node": "^20.x.x"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"eslint": "^8.53.0",
"eslint": "^9.13.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-svelte3": "^3.2.0",
"eslint-plugin-svelte": "^2.46.0",
"globals": "^15.11.0",
"rollup": "^2.3.4",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-livereload": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion admin-client/src/flows/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { notification } from '../stores';
import { deactivateOrganization, activateOrganization } from '../lib/api';

async function deactivate(id, redirectTo) {
// eslint-disable-next-line no-alert
if (!window.confirm('Are you sure you want to deactivate this organization?')) { return null; }
try {
await deactivateOrganization(id);
Expand Down
1 change: 0 additions & 1 deletion admin-client/src/helpers/downloadCSV.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
export const downloadCSV = async (fetchCSV, filename) => {
const csv = await fetchCSV();
const blob = new Blob([csv], { type: 'application/octet-stream' });
Expand Down
5 changes: 2 additions & 3 deletions admin-client/src/helpers/formatter.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* eslint-disable import/prefer-default-export */
import { format, formatRelative } from 'date-fns';

export const formatDateTime = (date, relative = false) => {
try {
return relative
? formatRelative(new Date(date), new Date())
: format(new Date(date), 'yyyy-MM-dd hh:mma');
} catch (error) {
} catch (_) {
return 'N/A';
}
};

export const formatSha = (commit) => {
try {
return commit.slice(0, 7);
} catch (error) {
} catch (_) {
return 'N/A';
}
};
6 changes: 0 additions & 6 deletions admin-client/src/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
/* global API_URL */
import { notification, session } from '../stores';
import { logout as authLogout } from './auth';
Expand All @@ -13,18 +12,15 @@ const defaultOptions = {
mode: 'cors',
};

// eslint-disable-next-line no-underscore-dangle
function _setSearchString(query = {}) {
const search = new URLSearchParams();

// eslint-disable-next-line array-callback-return
Object.keys(query).map((key) => {
search.set(key, query[key]);
});
return search.toString();
}

// eslint-disable-next-line no-underscore-dangle
async function _fetch(path, fetchOpts = {}, apiOpts = { handleError: true }) {
const fetchOptions = { ...defaultOptions, ...fetchOpts };
if (!['GET', 'HEAD', 'OPTIONS'].includes(fetchOptions.method)) {
Expand Down Expand Up @@ -58,7 +54,6 @@ async function _fetch(path, fetchOpts = {}, apiOpts = { handleError: true }) {
return request;
}

// eslint-disable-next-line no-underscore-dangle
async function _fetchAttachedFile(path) {
const fetchOptions = { ...defaultOptions };
fetchOptions.headers['x-csrf-token'] = session.csrfToken();
Expand Down Expand Up @@ -125,7 +120,6 @@ function fetchBuildLogEventSource(id, onMessage) {
const es = new EventSource(`${apiUrl}/admin/builds/${id}/log`, { withCredentials: true });
es.addEventListener('message', onMessage);
es.addEventListener('error', (error) => {
// eslint-disable-next-line no-console
console.error('EventSource failed:', error);
if (es) {
es.close();
Expand Down
60 changes: 27 additions & 33 deletions admin-client/src/lib/jsonTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,6 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {
: (n >> (i + 1) << (i + 1)) | (n % (n >> i << i)) | (+b << i);
}

function squarebracketify(exp) {
return typeof exp === 'string'
? exp.replace(/\.([0-9]+)/g, '[$1]') : `${exp}`;
}

function refresh(silent) {
const expandable = type == 'object' || type == 'array';

Expand Down Expand Up @@ -487,11 +482,11 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {
let child; let
event;

while (event = domEventListeners.pop()) {
while (event === domEventListeners.pop()) {
event.element.removeEventListener(event.name, event.fn);
}

while (child = children.pop()) {
while (child === children.pop()) {
removeChild(child);
}
}
Expand Down Expand Up @@ -668,7 +663,7 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {
document.execCommand('selectAll', false, null);
}

function itemClicked(field) {
function itemClicked() {
self.emit('click', self,
!self.withRootName && self.isRoot ? [''] : [self.name], self.value);
}
Expand Down Expand Up @@ -705,7 +700,7 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {
const text = element.innerText;
try {
setValue(text === 'undefined' ? undefined : JSON.parse(text));
} catch (err) {
} catch (_) {
setValue(text);
}
}
Expand Down Expand Up @@ -800,28 +795,28 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {
}
}

function onInsertClick() {
const newName = type == 'array' ? value.length : undefined;
const child = addChild(newName, null);
if (child.parent) {
child.parent.inserting = true;
}
if (type == 'array') {
value.push(null);
child.editValue();
child.emit('append', self, [value.length - 1], 'value', null, true);
if (child.parent) {
child.parent.inserting = false;
}
} else {
child.editName();
}
}

function onDeleteClick() {
self.emit('delete', self, [self.name], self.value,
self.parent.isRoot ? self.parent.oldType : self.parent.type, false);
}
// function onInsertClick() {
// const newName = type == 'array' ? value.length : undefined;
// const child = addChild(newName, null);
// if (child.parent) {
// child.parent.inserting = true;
// }
// if (type == 'array') {
// value.push(null);
// child.editValue();
// child.emit('append', self, [value.length - 1], 'value', null, true);
// if (child.parent) {
// child.parent.inserting = false;
// }
// } else {
// child.editName();
// }
// }

// function onDeleteClick() {
// self.emit('delete', self, [self.name], self.value,
// self.parent.isRoot ? self.parent.oldType : self.parent.type, false);
// }

function onChildRename(child, keyPath, oldName, newName, original) {
const allow = newName && type != 'array' && !(newName in value) && original;
Expand All @@ -847,9 +842,8 @@ function JSONTreeView(name_, value_, parent_, isRoot_) {

if (self.withRootName || !self.isRoot) {
keyPath.unshift(name);
} else if (self.withRootName && self.isRoot) {
keyPath.unshift(name);
}

if (oldName !== undefined) {
self.emit('rename', child, keyPath, oldName, newName, false);
}
Expand Down
4 changes: 1 addition & 3 deletions admin-client/src/pages/domain/Show.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
}
async function deprovision() {
// eslint-disable-next-line no-alert
if (window.confirm('Are you sure you want to deprovision this domain?')) {
domainPromise = deprovisionDomain(id);
await domainPromise;
Expand All @@ -44,7 +43,6 @@
}
async function destroy() {
// eslint-disable-next-line no-alert
if (!window.confirm('Are you sure you want to destroy this domain?')) { return null; }
try {
await destroyDomain(id);
Expand Down Expand Up @@ -126,4 +124,4 @@
{/if}
</Await>
</Await>
</GridContainer>
</GridContainer>
2 changes: 1 addition & 1 deletion admin-client/src/stores/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const initial = {};
const { set, subscribe } = writable(initial);

export default {
setContext: ({ page, ...rest }) => set(rest),
setContext: ({ _, ...rest }) => set(rest),
subscribe,
};
Loading

0 comments on commit 5c1edca

Please sign in to comment.