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

Small upgrades for the config #2

Closed
andrewmcodes opened this issue Apr 8, 2023 · 1 comment
Closed

Small upgrades for the config #2

andrewmcodes opened this issue Apr 8, 2023 · 1 comment

Comments

@andrewmcodes
Copy link
Owner

  • Create a new Node.js module in your preferred directory structure.
  • Install Prettier as a dev dependency:
npm install --save-dev prettier

Create a new file in the root of your module called .prettierrc.js:
javascript
Copy code
module.exports = {
trailingComma: 'es5',
tabWidth: 2,
semi: true,
singleQuote: true,
};
This file exports an object with your preferred Prettier configuration.
Create a new file in the root of your module called index.js:
javascript
Copy code
module.exports = require('./.prettierrc.js');
This file exports the Prettier configuration object you just created.
In your package.json, add a prettier field that points to your configuration file:
json
Copy code
{
"name": "@company/prettier-config",
"version": "1.0.0",
"description": "Shareable Prettier configuration for @Company projects",
"main": "index.js",
"prettier": "./.prettierrc.js",
"devDependencies": {
"prettier": "^2.4.1"
}
}
Finally, publish your module to NPM:
bash
Copy code
npm publish --access public
That's it! Now anyone can install and use your shareable Prettier configuration in their own projects:

bash
Copy code
npm install --save-dev @company/prettier-config
And then they can use it in their .prettierrc.js file:

javascript
Copy code
module.exports = require('@company/prettier-config');

@andrewmcodes
Copy link
Owner Author

Fixed by #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant