-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix/eslint newline error in model generator #2812
Open
coolsoftwaretyler
wants to merge
5
commits into
master
Choose a base branch
from
fix/eslint-newline-error-in-model-generator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
87fa2a8
fix: add ending newline to model generator
coolsoftwaretyler 148e526
fix: add ending newline to model test generator
coolsoftwaretyler cb78066
chore: disable prettier in Jest
coolsoftwaretyler 8984194
test: update generator snapshots
coolsoftwaretyler ec682f8
fix: optionally use 2 versions of prettier for Jest
coolsoftwaretyler 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
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,4 +9,4 @@ test("can be created", () => { | |
expect(instance).toBeTruthy() | ||
}) | ||
|
||
// @mst remove-file | ||
// @mst remove-file |
This file contains 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 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 |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
"husky": "^7.0.1", | ||
"jest": "^27.0.6", | ||
"prettier": "^3.3.3", | ||
"prettier-2": "npm:[email protected]", | ||
"semantic-release": "^17.4.2", | ||
"ts-jest": "^27.0.4", | ||
"ts-node": "^10.2.0", | ||
|
@@ -159,6 +160,7 @@ | |
"tsx", | ||
"js", | ||
"jsx" | ||
] | ||
], | ||
"prettierPath": "<rootDir>/node_modules/prettier-2/index.js" | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -57,37 +57,39 @@ describe("ignite-cli generate", () => { | |
" | ||
`) | ||
expect(read(`${TEMP_DIR}/app/models/Pizza.ts`)).toMatchInlineSnapshot(` | ||
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" | ||
import { withSetPropAction } from \\"./helpers/withSetPropAction\\" | ||
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" | ||
import { withSetPropAction } from \\"./helpers/withSetPropAction\\" | ||
|
||
/** | ||
* Model description here for TypeScript hints. | ||
*/ | ||
export const PizzaModel = types | ||
.model(\\"Pizza\\") | ||
.props({}) | ||
.actions(withSetPropAction) | ||
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
|
||
export interface Pizza extends Instance<typeof PizzaModel> {} | ||
export interface PizzaSnapshotOut extends SnapshotOut<typeof PizzaModel> {} | ||
export interface PizzaSnapshotIn extends SnapshotIn<typeof PizzaModel> {} | ||
export const createPizzaDefaultModel = () => types.optional(PizzaModel, {}) | ||
|
||
// @mst remove-file" | ||
`) | ||
/** | ||
* Model description here for TypeScript hints. | ||
*/ | ||
export const PizzaModel = types | ||
.model(\\"Pizza\\") | ||
.props({}) | ||
.actions(withSetPropAction) | ||
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
|
||
export interface Pizza extends Instance<typeof PizzaModel> {} | ||
export interface PizzaSnapshotOut extends SnapshotOut<typeof PizzaModel> {} | ||
export interface PizzaSnapshotIn extends SnapshotIn<typeof PizzaModel> {} | ||
export const createPizzaDefaultModel = () => types.optional(PizzaModel, {}) | ||
|
||
// @mst remove-file | ||
" | ||
Comment on lines
+78
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key snapshot diff that we do want to preserve: newline at end of file |
||
`) | ||
expect(read(`${TEMP_DIR}/app/models/Pizza.test.ts`)).toMatchInlineSnapshot(` | ||
"import { PizzaModel } from \\"./Pizza\\" | ||
"import { PizzaModel } from \\"./Pizza\\" | ||
|
||
test(\\"can be created\\", () => { | ||
const instance = PizzaModel.create({}) | ||
test(\\"can be created\\", () => { | ||
const instance = PizzaModel.create({}) | ||
|
||
expect(instance).toBeTruthy() | ||
}) | ||
expect(instance).toBeTruthy() | ||
}) | ||
|
||
// @mst remove-file" | ||
`) | ||
// @mst remove-file | ||
" | ||
`) | ||
expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(` | ||
"export * from \\"./RootStore\\" | ||
export * from \\"./helpers/getRootStore\\" | ||
|
@@ -138,37 +140,39 @@ describe("ignite-cli generate", () => { | |
" | ||
`) | ||
expect(read(`${TEMP_DIR}/app/models/PizzaStore.ts`)).toMatchInlineSnapshot(` | ||
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" | ||
import { withSetPropAction } from \\"./helpers/withSetPropAction\\" | ||
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" | ||
import { withSetPropAction } from \\"./helpers/withSetPropAction\\" | ||
|
||
/** | ||
* Model description here for TypeScript hints. | ||
*/ | ||
export const PizzaStoreModel = types | ||
.model(\\"PizzaStore\\") | ||
.props({}) | ||
.actions(withSetPropAction) | ||
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
|
||
export interface PizzaStore extends Instance<typeof PizzaStoreModel> {} | ||
export interface PizzaStoreSnapshotOut extends SnapshotOut<typeof PizzaStoreModel> {} | ||
export interface PizzaStoreSnapshotIn extends SnapshotIn<typeof PizzaStoreModel> {} | ||
export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {}) | ||
|
||
// @mst remove-file" | ||
`) | ||
/** | ||
* Model description here for TypeScript hints. | ||
*/ | ||
export const PizzaStoreModel = types | ||
.model(\\"PizzaStore\\") | ||
.props({}) | ||
.actions(withSetPropAction) | ||
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
|
||
export interface PizzaStore extends Instance<typeof PizzaStoreModel> {} | ||
export interface PizzaStoreSnapshotOut extends SnapshotOut<typeof PizzaStoreModel> {} | ||
export interface PizzaStoreSnapshotIn extends SnapshotIn<typeof PizzaStoreModel> {} | ||
export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {}) | ||
|
||
// @mst remove-file | ||
" | ||
`) | ||
expect(read(`${TEMP_DIR}/app/models/PizzaStore.test.ts`)).toMatchInlineSnapshot(` | ||
"import { PizzaStoreModel } from \\"./PizzaStore\\" | ||
"import { PizzaStoreModel } from \\"./PizzaStore\\" | ||
|
||
test(\\"can be created\\", () => { | ||
const instance = PizzaStoreModel.create({}) | ||
test(\\"can be created\\", () => { | ||
const instance = PizzaStoreModel.create({}) | ||
|
||
expect(instance).toBeTruthy() | ||
}) | ||
expect(instance).toBeTruthy() | ||
}) | ||
|
||
// @mst remove-file" | ||
`) | ||
// @mst remove-file | ||
" | ||
`) | ||
expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(` | ||
"export * from \\"./RootStore\\" | ||
export * from \\"./helpers/getRootStore\\" | ||
|
This file contains 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 |
---|---|---|
|
@@ -5718,6 +5718,11 @@ prelude-ls@^1.2.1: | |
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" | ||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== | ||
|
||
"prettier-2@npm:[email protected]": | ||
version "2.8.8" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" | ||
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== | ||
|
||
prettier@^3.3.3: | ||
version "3.3.3" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" | ||
|
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.
I would guess this whitespace diff (and a few below) came from disabling Prettier in Jest, so maybe we should find a different way to fix that, or else it will cause a lot more noisy churn after the fact with other inline snapshots.
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.
Another approach would be ec682f8, which uses the workaround of a separate Prettier version for Jest. I set
prettier-2
to benpm:[email protected]
which I saw was the last version before the update in https://github.com/infinitered/ignite/pull/2761/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519.Didn't seem to change the whitespace diff here, so maybe there's no real issue. Figured I'd at least provide the commit and we could easily drop it if the
prettierPath: null
is acceptable.