You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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');
The text was updated successfully, but these errors were encountered: