Skip to content
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

move husky and lintstaged setup from 'prettier' module to 'init' #10713

Merged

Conversation

fabienpuissant
Copy link
Collaborator

Fix #10701

@fabienpuissant
Copy link
Collaborator Author

It is impossible to have an empty configuration => leads to error "Configuration should not be empty"

I'm open to suggestion to handle with that. Currently I've just put a useless echo command in it

@murdos
Copy link
Contributor

murdos commented Aug 31, 2024

It is impossible to have an empty configuration => leads to error "Configuration should not be empty"

I'm open to suggestion to handle with that. Currently I've just put a useless echo command in it

Too bad... However it works with an empty lintstaged.cjs file.
I suggests that we generate and empty file lintstaged.cjs, and then in the prettier module, we do 2 optional replacements to handle the different situations:
1/ lintstaged.cjs is still empty => we can the add the whole export default = { ... },
2/ lintstaged.cjs has been configured meanwhile (either manually, or by another module) => we just add a new line after export default = {

You can find a similar situation here:

.optionalReplacements()
.in(path("tsconfig.json"))
.add(EXISTING_EXCLUSION_REPLACER_PROVIDER.apply(tsconfigExclusion), "$1, "+tsconfigExclusion+"]")
.add(EMPTY_EXCLUSION_REPLACER_PROVIDER.apply(tsconfigExclusion), "$1"+tsconfigExclusion+"]")
.add(NEW_EXCLUSION_REPLACER, newExclusionNode(properties, tsconfigExclusion))

And the corresponding unit tests in CypressModuleFactoryTest.

@fabienpuissant
Copy link
Collaborator Author

It is impossible to have an empty configuration => leads to error "Configuration should not be empty"
I'm open to suggestion to handle with that. Currently I've just put a useless echo command in it

Too bad... However it works with an empty lintstaged.cjs file. I suggests that we generate and empty file lintstaged.cjs, and then in the prettier module, we do 2 optional replacements to handle the different situations: 1/ lintstaged.cjs is still empty => we can the add the whole export default = { ... }, 2/ lintstaged.cjs has been configured meanwhile (either manually, or by another module) => we just add a new line after export default = {

You can find a similar situation here:

.optionalReplacements()
.in(path("tsconfig.json"))
.add(EXISTING_EXCLUSION_REPLACER_PROVIDER.apply(tsconfigExclusion), "$1, "+tsconfigExclusion+"]")
.add(EMPTY_EXCLUSION_REPLACER_PROVIDER.apply(tsconfigExclusion), "$1"+tsconfigExclusion+"]")
.add(NEW_EXCLUSION_REPLACER, newExclusionNode(properties, tsconfigExclusion))

And the corresponding unit tests in CypressModuleFactoryTest.

Good idea ! Thank you

@fabienpuissant fabienpuissant force-pushed the feature/move-husky-to-init-module branch from 330cbd7 to 64b92aa Compare September 2, 2024 23:05
@fabienpuissant
Copy link
Collaborator Author

I needed to rename src/main/resources/generator/init/.lintstagedrc.cjs into src/main/resources/generator/init/.lintstagedrc.template.cjs because otherwise error when commiting because configuration empty

@fabienpuissant fabienpuissant force-pushed the feature/move-husky-to-init-module branch 5 times, most recently from 5195e40 to 01f3595 Compare September 3, 2024 17:38
@fabienpuissant fabienpuissant force-pushed the feature/move-husky-to-init-module branch from 01f3595 to 40cebf6 Compare September 4, 2024 18:12
@murdos murdos merged commit f0b8f05 into jhipster:main Sep 5, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move husky and lintstaged setup from 'prettier' module to 'init'
2 participants