-
Notifications
You must be signed in to change notification settings - Fork 0
Format #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Format #53
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d15897d
add formatting config and dependencies
interim17 5445511
push formatting fixes
interim17 845a2ec
expand formatting glob to js files
interim17 e5a8cbc
run format on js files
interim17 c39b0c7
Merge branch 'main' of https://github.com/AllenCell/idea-board into f…
interim17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
| "printWidth": 80, | ||
| "tabWidth": 4, | ||
| "importOrder": ["^react", "^gatsby", "^[^./]", "^[./]"], | ||
| "importOrderSeparation": true, | ||
| "importOrderSortSpecifiers": true | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ const SOFTWARE_PATH = `software`; | |
| module.exports = { | ||
| DATASET_PATH, | ||
| SOFTWARE_PATH, | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,109 +1,112 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { resolveSlug, resolveSoftwareTools } from '../gatsby-resolver-utils'; | ||
| import { DATASET_PATH, SOFTWARE_PATH } from '../constants'; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| describe('resolveSlug', () => { | ||
| it('should return null when id is falsy', () => { | ||
| expect(resolveSlug(null, 'software')).toBe(null); | ||
| expect(resolveSlug(undefined, 'software')).toBe(null); | ||
| expect(resolveSlug('', 'software')).toBe(null); | ||
| import { DATASET_PATH, SOFTWARE_PATH } from "../constants"; | ||
| import { resolveSlug, resolveSoftwareTools } from "../gatsby-resolver-utils"; | ||
|
|
||
| describe("resolveSlug", () => { | ||
| it("should return null when id is falsy", () => { | ||
| expect(resolveSlug(null, "software")).toBe(null); | ||
| expect(resolveSlug(undefined, "software")).toBe(null); | ||
| expect(resolveSlug("", "software")).toBe(null); | ||
| }); | ||
|
|
||
| it('should build a slug from id and directory', () => { | ||
| it("should build a slug from id and directory", () => { | ||
| expect(resolveSlug("released-emt-dataset", DATASET_PATH)).toBe( | ||
| "/dataset/released-emt-dataset/" | ||
| "/dataset/released-emt-dataset/", | ||
| ); | ||
| }); | ||
|
|
||
| it('should slugify the id to lowercase', () => { | ||
| it("should slugify the id to lowercase", () => { | ||
| expect(resolveSlug("UPPERCASE", DATASET_PATH)).toBe( | ||
| "/dataset/uppercase/" | ||
| "/dataset/uppercase/", | ||
| ); | ||
| }); | ||
|
|
||
| it('should handle special characters in id', () => { | ||
| it("should handle special characters in id", () => { | ||
| expect(resolveSlug("Tool & Library", SOFTWARE_PATH)).toBe( | ||
| "/software/tool-and-library/" | ||
| "/software/tool-and-library/", | ||
| ); | ||
| expect(resolveSlug("Some/Path/Name", SOFTWARE_PATH)).toBe( | ||
| "/software/somepathname/" | ||
| "/software/somepathname/", | ||
| ); | ||
| }); | ||
|
|
||
| it('should handle ids with leading/trailing spaces', () => { | ||
| expect(resolveSlug(' trimmed ', 'software')).toBe('/software/trimmed/'); | ||
| it("should handle ids with leading/trailing spaces", () => { | ||
| expect(resolveSlug(" trimmed ", "software")).toBe( | ||
| "/software/trimmed/", | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('resolveSoftwareTools', () => { | ||
| it('should return empty array for non-array inputs', () => { | ||
| describe("resolveSoftwareTools", () => { | ||
| it("should return empty array for non-array inputs", () => { | ||
| expect(resolveSoftwareTools(null)).toEqual([]); | ||
| expect(resolveSoftwareTools(undefined)).toEqual([]); | ||
| expect(resolveSoftwareTools('string')).toEqual([]); | ||
| expect(resolveSoftwareTools("string")).toEqual([]); | ||
| expect(resolveSoftwareTools({})).toEqual([]); | ||
| expect(resolveSoftwareTools(123)).toEqual([]); | ||
| }); | ||
|
|
||
| it('should return empty array for empty array', () => { | ||
| it("should return empty array for empty array", () => { | ||
| expect(resolveSoftwareTools([])).toEqual([]); | ||
| }); | ||
|
|
||
| it('should filter out invalid items', () => { | ||
| const input = [null, undefined, 'string', {}, { other: 'prop' }]; | ||
| it("should filter out invalid items", () => { | ||
| const input = [null, undefined, "string", {}, { other: "prop" }]; | ||
| expect(resolveSoftwareTools(input)).toEqual([]); | ||
| }); | ||
|
|
||
| it('should transform valid items with softwareTool', () => { | ||
| const input = [{ softwareTool: 'Simularium' }]; | ||
| it("should transform valid items with softwareTool", () => { | ||
| const input = [{ softwareTool: "Simularium" }]; | ||
| expect(resolveSoftwareTools(input)).toEqual([ | ||
| { | ||
| softwareTool: '/software/simularium/', | ||
| softwareTool: "/software/simularium/", | ||
| customDescription: null, | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should preserve customDescription when provided', () => { | ||
| it("should preserve customDescription when provided", () => { | ||
| const input = [ | ||
| { | ||
| softwareTool: 'Simularium', | ||
| customDescription: 'Custom description here', | ||
| softwareTool: "Simularium", | ||
| customDescription: "Custom description here", | ||
| }, | ||
| ]; | ||
| expect(resolveSoftwareTools(input)).toEqual([ | ||
| { | ||
| softwareTool: '/software/simularium/', | ||
| customDescription: 'Custom description here', | ||
| softwareTool: "/software/simularium/", | ||
| customDescription: "Custom description here", | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should return null for empty customDescription', () => { | ||
| const input = [{ softwareTool: 'Simularium', customDescription: '' }]; | ||
| it("should return null for empty customDescription", () => { | ||
| const input = [{ softwareTool: "Simularium", customDescription: "" }]; | ||
| expect(resolveSoftwareTools(input)).toEqual([ | ||
| { | ||
| softwareTool: '/software/simularium/', | ||
| softwareTool: "/software/simularium/", | ||
| customDescription: null, | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should handle mixed valid and invalid items', () => { | ||
| it("should handle mixed valid and invalid items", () => { | ||
| const input = [ | ||
| null, | ||
| { softwareTool: 'Simularium' }, | ||
| { other: 'invalid' }, | ||
| { softwareTool: 'TFE', customDescription: 'Time explorer' }, | ||
| { softwareTool: "Simularium" }, | ||
| { other: "invalid" }, | ||
| { softwareTool: "TFE", customDescription: "Time explorer" }, | ||
| ]; | ||
| expect(resolveSoftwareTools(input)).toEqual([ | ||
| { | ||
| softwareTool: '/software/simularium/', | ||
| softwareTool: "/software/simularium/", | ||
| customDescription: null, | ||
| }, | ||
| { | ||
| softwareTool: '/software/tfe/', | ||
| customDescription: 'Time explorer', | ||
| softwareTool: "/software/tfe/", | ||
| customDescription: "Time explorer", | ||
| }, | ||
| ]); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this is configuring line width: is 80 the convention? We've been using 88 or 100, because 80 was a bit too restrictive/short
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure what is considered standard, It's 80 in cell-catalog. I'm looking around now and seeing 100 some places (BFF), and 120 in other (vole-app, tfe), so 80 does seem small.
I might just go ahead with this for now and I'm happy to revisit it later. I do wonder if style/formatting guidelines are a good topic for reusable workflows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for pre-commit hooks we can attach it. POC for that is ongoing in cell-catalog we are trying to get
lefthookto work in place ofhuskyas it's friendlier to polyglot repos.