Skip to content

Commit 3d9fe38

Browse files
fix(cli): fix missing newlines in model generator (#2910 by @coolsoftwaretyler)
* fix: missing newline in model generator * test: update snapshots * fix: prettier v3/jest issue
1 parent 5ea9c7a commit 3d9fe38

File tree

4 files changed

+60
-55
lines changed

4 files changed

+60
-55
lines changed

boilerplate/ignite/templates/model/NAME.test.ts.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ test("can be created", () => {
99
expect(instance).toBeTruthy()
1010
})
1111

12-
// @mst remove-file
12+
// @mst remove-file

boilerplate/ignite/templates/model/NAME.ts.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ export interface <%= props.pascalCaseName %>SnapshotOut extends SnapshotOut<type
3131
export interface <%= props.pascalCaseName %>SnapshotIn extends SnapshotIn<typeof <%= props.pascalCaseName %>Model> {}
3232
export const create<%= props.pascalCaseName %>DefaultModel = () => types.optional(<%= props.pascalCaseName %>Model, {})
3333

34-
// @mst remove-file
34+
// @mst remove-file

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
"tsx",
160160
"js",
161161
"jsx"
162-
]
162+
],
163+
"prettierPath": null
163164
}
164165
}

test/vanilla/ignite-generate.test.ts

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,39 @@ describe("ignite-cli generate", () => {
5757
"
5858
`)
5959
expect(read(`${TEMP_DIR}/app/models/Pizza.ts`)).toMatchInlineSnapshot(`
60-
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\"
61-
import { withSetPropAction } from \\"./helpers/withSetPropAction\\"
60+
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\"
61+
import { withSetPropAction } from \\"./helpers/withSetPropAction\\"
6262
63-
/**
64-
* Model description here for TypeScript hints.
65-
*/
66-
export const PizzaModel = types
67-
.model(\\"Pizza\\")
68-
.props({})
69-
.actions(withSetPropAction)
70-
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
71-
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
72-
73-
export interface Pizza extends Instance<typeof PizzaModel> {}
74-
export interface PizzaSnapshotOut extends SnapshotOut<typeof PizzaModel> {}
75-
export interface PizzaSnapshotIn extends SnapshotIn<typeof PizzaModel> {}
76-
export const createPizzaDefaultModel = () => types.optional(PizzaModel, {})
77-
78-
// @mst remove-file"
79-
`)
63+
/**
64+
* Model description here for TypeScript hints.
65+
*/
66+
export const PizzaModel = types
67+
.model(\\"Pizza\\")
68+
.props({})
69+
.actions(withSetPropAction)
70+
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
71+
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
72+
73+
export interface Pizza extends Instance<typeof PizzaModel> {}
74+
export interface PizzaSnapshotOut extends SnapshotOut<typeof PizzaModel> {}
75+
export interface PizzaSnapshotIn extends SnapshotIn<typeof PizzaModel> {}
76+
export const createPizzaDefaultModel = () => types.optional(PizzaModel, {})
77+
78+
// @mst remove-file
79+
"
80+
`)
8081
expect(read(`${TEMP_DIR}/app/models/Pizza.test.ts`)).toMatchInlineSnapshot(`
81-
"import { PizzaModel } from \\"./Pizza\\"
82+
"import { PizzaModel } from \\"./Pizza\\"
8283
83-
test(\\"can be created\\", () => {
84-
const instance = PizzaModel.create({})
84+
test(\\"can be created\\", () => {
85+
const instance = PizzaModel.create({})
8586
86-
expect(instance).toBeTruthy()
87-
})
87+
expect(instance).toBeTruthy()
88+
})
8889
89-
// @mst remove-file"
90-
`)
90+
// @mst remove-file
91+
"
92+
`)
9193
expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(`
9294
"export * from \\"./RootStore\\"
9395
export * from \\"./helpers/getRootStore\\"
@@ -138,37 +140,39 @@ describe("ignite-cli generate", () => {
138140
"
139141
`)
140142
expect(read(`${TEMP_DIR}/app/models/PizzaStore.ts`)).toMatchInlineSnapshot(`
141-
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\"
142-
import { withSetPropAction } from \\"./helpers/withSetPropAction\\"
143+
"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\"
144+
import { withSetPropAction } from \\"./helpers/withSetPropAction\\"
143145
144-
/**
145-
* Model description here for TypeScript hints.
146-
*/
147-
export const PizzaStoreModel = types
148-
.model(\\"PizzaStore\\")
149-
.props({})
150-
.actions(withSetPropAction)
151-
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
152-
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
153-
154-
export interface PizzaStore extends Instance<typeof PizzaStoreModel> {}
155-
export interface PizzaStoreSnapshotOut extends SnapshotOut<typeof PizzaStoreModel> {}
156-
export interface PizzaStoreSnapshotIn extends SnapshotIn<typeof PizzaStoreModel> {}
157-
export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {})
158-
159-
// @mst remove-file"
160-
`)
146+
/**
147+
* Model description here for TypeScript hints.
148+
*/
149+
export const PizzaStoreModel = types
150+
.model(\\"PizzaStore\\")
151+
.props({})
152+
.actions(withSetPropAction)
153+
.views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
154+
.actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
155+
156+
export interface PizzaStore extends Instance<typeof PizzaStoreModel> {}
157+
export interface PizzaStoreSnapshotOut extends SnapshotOut<typeof PizzaStoreModel> {}
158+
export interface PizzaStoreSnapshotIn extends SnapshotIn<typeof PizzaStoreModel> {}
159+
export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {})
160+
161+
// @mst remove-file
162+
"
163+
`)
161164
expect(read(`${TEMP_DIR}/app/models/PizzaStore.test.ts`)).toMatchInlineSnapshot(`
162-
"import { PizzaStoreModel } from \\"./PizzaStore\\"
165+
"import { PizzaStoreModel } from \\"./PizzaStore\\"
163166
164-
test(\\"can be created\\", () => {
165-
const instance = PizzaStoreModel.create({})
167+
test(\\"can be created\\", () => {
168+
const instance = PizzaStoreModel.create({})
166169
167-
expect(instance).toBeTruthy()
168-
})
170+
expect(instance).toBeTruthy()
171+
})
169172
170-
// @mst remove-file"
171-
`)
173+
// @mst remove-file
174+
"
175+
`)
172176
expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(`
173177
"export * from \\"./RootStore\\"
174178
export * from \\"./helpers/getRootStore\\"

0 commit comments

Comments
 (0)