Skip to content

Commit

Permalink
spaces not tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Oct 19, 2024
1 parent ade1c87 commit b6a1b5a
Show file tree
Hide file tree
Showing 33 changed files with 1,059 additions and 1,062 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"useTabs": true,
"useTabs": false,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
Expand Down
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

75 changes: 38 additions & 37 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,42 @@ import tsParser from '@typescript-eslint/parser';
import globals from 'globals';

export default [
{
ignores: ['.DS_Store', 'node_modules', 'build/', '.svelte-kit/', 'index.js']
},
js.configs.recommended,
...tsEslint.configs.strict,
...eslintPluginSvelte.configs['flat/recommended'],
eslintPluginPrettierRecommended, // must be last to override conflicting rules.
{
languageOptions: {
globals: {
...globals.node,
...globals.browser
}
}
},
{
rules: {
'no-console': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: tsParser
}
},
rules: {
'svelte/no-target-blank': 'error',
'svelte/no-at-debug-tags': 'error',
'svelte/no-reactive-functions': 'error',
'svelte/no-reactive-literals': 'error',
'svelte/no-at-html-tags': 'off'
}
}
{
ignores: ['.DS_Store', 'node_modules', 'build/', '.svelte-kit/', 'index.js']
},
js.configs.recommended,
...tsEslint.configs.strict,
...eslintPluginSvelte.configs['flat/recommended'],
eslintPluginPrettierRecommended, // must be last to override conflicting rules.
{
languageOptions: {
globals: {
...globals.node,
...globals.browser
}
}
},
{
rules: {
'no-console': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: tsParser
}
},
rules: {
'svelte/no-target-blank': 'error',
'svelte/no-at-debug-tags': 'error',
'svelte/no-reactive-functions': 'error',
'svelte/no-reactive-literals': 'error',
'svelte/no-at-html-tags': 'off'
}
}
];
8 changes: 4 additions & 4 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
72 changes: 36 additions & 36 deletions scripts/integrity-enforcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ import peopleRaw from '../static/people.json?raw';
import type { Paper, Person } from '../src/lib/app-types';

async function generateIndex() {
const people = JSON.parse(peopleRaw) as Person[];
const personMap = Object.fromEntries(people.map((p) => [`${p.first_name} ${p.last_name}`, p]));
const paperList = await fs.readdir('./static/papers');
const people = JSON.parse(peopleRaw) as Person[];
const personMap = Object.fromEntries(people.map((p) => [`${p.first_name} ${p.last_name}`, p]));
const paperList = await fs.readdir('./static/papers');

const papers = [] as Paper[];
for (const paper of paperList) {
const paperRaw = await fs
.readFile(`./static/papers/${paper}`, 'utf8')
.then((x) => JSON.parse(x) as Paper);
const updatedAuthors = paperRaw.authors.map((author) => {
const key = `${author.first_name} ${author.last_name}`;
const { url, display_name } = personMap[key] || {};
return {
...author,
display_name: display_name || undefined,
url: url || undefined
};
});
const updatedPaper = {
...paperRaw,
authors: updatedAuthors
};
if (updatedPaper.visible) {
papers.push(updatedPaper);
}
await fs.writeFile(`./static/papers/${paper}`, JSON.stringify(updatedPaper, null, 2));
}
papers.sort((a, b) => {
const ad = a.mod_date;
const bd = b.mod_date;
const at = a.title;
const bt = b.title;
// sort by reverse mod date, break ties by alphabetic title order
return ad < bd ? 1 : ad > bd ? -1 : at < bt ? -1 : at > bt ? 1 : 0;
});
await fs.writeFile('./static/papers-index.json', JSON.stringify(papers, null, 2));
const papers = [] as Paper[];
for (const paper of paperList) {
const paperRaw = await fs
.readFile(`./static/papers/${paper}`, 'utf8')
.then((x) => JSON.parse(x) as Paper);
const updatedAuthors = paperRaw.authors.map((author) => {
const key = `${author.first_name} ${author.last_name}`;
const { url, display_name } = personMap[key] || {};
return {
...author,
display_name: display_name || undefined,
url: url || undefined
};
});
const updatedPaper = {
...paperRaw,
authors: updatedAuthors
};
if (updatedPaper.visible) {
papers.push(updatedPaper);
}
await fs.writeFile(`./static/papers/${paper}`, JSON.stringify(updatedPaper, null, 2));
}
papers.sort((a, b) => {
const ad = a.mod_date;
const bd = b.mod_date;
const at = a.title;
const bt = b.title;
// sort by reverse mod date, break ties by alphabetic title order
return ad < bd ? 1 : ad > bd ? -1 : at < bt ? -1 : at > bt ? 1 : 0;
});
await fs.writeFile('./static/papers-index.json', JSON.stringify(papers, null, 2));
}

async function main() {
await generateIndex();
await generateIndex();
}
main();
14 changes: 7 additions & 7 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {};
164 changes: 82 additions & 82 deletions src/data-integrity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,106 +22,106 @@ const news = JSON.parse(newsRaw) as Paper[];
const courses = JSON.parse(courseRaw) as Course[];

test('Web names should be unique', () => {
const webNames = new Set(papers.map((paper) => paper.web_name));
expect(webNames.size).toBe(papers.length);
const webNames = new Set(papers.map((paper) => paper.web_name));
expect(webNames.size).toBe(papers.length);
});

test('All papers should have corresponding venues', () => {
const venuesSet = new Set(papers.map((paper) => paper.venue));
const venues = featuredVenues.map((venue) => venue.venue_nickname);
const missingVenues = venues.filter((venue) => !venuesSet.has(venue));
expect(missingVenues).toEqual([]);
const venuesSet = new Set(papers.map((paper) => paper.venue));
const venues = featuredVenues.map((venue) => venue.venue_nickname);
const missingVenues = venues.filter((venue) => !venuesSet.has(venue));
expect(missingVenues).toEqual([]);
});

test('All venue nicknames should be unique', () => {
const venueNicknames = new Set(venues.map((venue) => venue.nickname));
expect(venueNicknames.size).toBe(venues.length);
const venueNicknames = new Set(venues.map((venue) => venue.nickname));
expect(venueNicknames.size).toBe(venues.length);
});

test('All papers should have corresponding people', () => {
const peopleSet = new Set(people.map((person) => `${person.first_name} ${person.last_name}`));
const paperAuthors = papers
.flatMap((paper) => paper.authors.map((author) => `${author.first_name} ${author.last_name}`))
.filter((author) => !peopleSet.has(author));
expect(paperAuthors).toEqual([]);
const peopleSet = new Set(people.map((person) => `${person.first_name} ${person.last_name}`));
const paperAuthors = papers
.flatMap((paper) => paper.authors.map((author) => `${author.first_name} ${author.last_name}`))
.filter((author) => !peopleSet.has(author));
expect(paperAuthors).toEqual([]);
});

test('All papers should have urls for their authors if possible', () => {
const authorUrls = Object.fromEntries(
people
.filter((person) => (person?.url || '').length)
.map((person) => [`${person.first_name} ${person.last_name}`, person.url])
);
const updatedPapers = papers.map((paper) => {
const authors = paper.authors.map((author) => {
return {
...author,
url: authorUrls[`${author.first_name} ${author.last_name}`]
};
});
return {
...paper,
authors
};
});
expect(updatedPapers).toEqual(papers);
const authorUrls = Object.fromEntries(
people
.filter((person) => (person?.url || '').length)
.map((person) => [`${person.first_name} ${person.last_name}`, person.url])
);
const updatedPapers = papers.map((paper) => {
const authors = paper.authors.map((author) => {
return {
...author,
url: authorUrls[`${author.first_name} ${author.last_name}`]
};
});
return {
...paper,
authors
};
});
expect(updatedPapers).toEqual(papers);
});

[
{ key: 'Paper', dataset: papers, accessor: (paper: Paper): string => paper.web_name },
{
key: 'Person',
dataset: people,
accessor: (person: Person): string => `${person.first_name} ${person.last_name}`
},
{
key: 'Spotlight',
dataset: spotlight,
accessor: (spotlight: Spotlight): string => spotlight.title
},
{
key: 'FeaturedVenue',
dataset: featuredVenues,
accessor: (venue: FeaturedVenue): string => venue.desc
},
{
key: 'News',
dataset: news,
accessor: (x: News): string => x.text
},
{
key: 'Venue',
dataset: venues,
accessor: (venue: Venue): string => venue.nickname
},
{
key: 'Course',
dataset: courses as Course[],
accessor: (course: Course): string => course.name
}
{ key: 'Paper', dataset: papers, accessor: (paper: Paper): string => paper.web_name },
{
key: 'Person',
dataset: people,
accessor: (person: Person): string => `${person.first_name} ${person.last_name}`
},
{
key: 'Spotlight',
dataset: spotlight,
accessor: (spotlight: Spotlight): string => spotlight.title
},
{
key: 'FeaturedVenue',
dataset: featuredVenues,
accessor: (venue: FeaturedVenue): string => venue.desc
},
{
key: 'News',
dataset: news,
accessor: (x: News): string => x.text
},
{
key: 'Venue',
dataset: venues,
accessor: (venue: Venue): string => venue.nickname
},
{
key: 'Course',
dataset: courses as Course[],
accessor: (course: Course): string => course.name
}
].forEach(({ key, dataset, accessor }) => {
test(`All ${key} values should be filled out`, () => {
const ajv = new Ajv({ allErrors: true });
test(`All ${key} values should be filled out`, () => {
const ajv = new Ajv({ allErrors: true });

const config = {
path: 'src/lib/app-types.ts',
tsconfig: 'tsconfig.json',
type: key,
additionalProperties: false
};
const config = {
path: 'src/lib/app-types.ts',
tsconfig: 'tsconfig.json',
type: key,
additionalProperties: false
};

const schema = tsj.createGenerator(config).createSchema(config.type);
const schema = tsj.createGenerator(config).createSchema(config.type);

dataset.forEach((unit) => {
const result = ajv.validate(schema, unit);
if (!result) {
console.log(ajv.errors);
}
dataset.forEach((unit) => {
const result = ajv.validate(schema, unit);
if (!result) {
console.log(ajv.errors);
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const unitName = accessor(unit);
expect(result, `${key}: "${unitName}" is invalid`).toBe(true);
});
});
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const unitName = accessor(unit);
expect(result, `${key}: "${unitName}" is invalid`).toBe(true);
});
});
});
Loading

0 comments on commit b6a1b5a

Please sign in to comment.