npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acdh-oeaw/prettier-config

v2.0.0

Published

Shared configuration preset for [`prettier`](https://prettier.io/).

Downloads

287

Readme

acdh-oeaw prettier config

Shared configuration preset for prettier.

How to install

npm install -D prettier @acdh-oeaw/prettier-config

Add the config to package.json:

{
	"prettier": "@acdh-oeaw/prettier-config"
}

If you absolutely need to extend the shared config, create a .prettierrc.js file in the root folder of your project:

const sharedConfig = require("@acdh-oeaw/prettier-config");

const config = {
	...sharedConfig,
	overrides: [
		{
			files: ["*.svg"],
			options: {
				parser: "html",
			},
		},
	],
};

module.exports = config;

How to use

Add a script to package.json:

{
	"scripts": {
		"format:check": "prettier . --cache --check --ignore-path .gitignore",
		"format:fix": "npm run format:check -- --write"
	}
}

You can then run npm run format:check to check code formatting, and npm run format:fix to auto-fix formatting errors.

How to auto-format with Git hooks

npm install -D lint-staged simple-git-hooks

To auto-format on every Git commit, and to check formatting on every Git push, add the following to package.json:

{
	"scripts": {
		"format:check": "prettier . --cache --check --ignore-path .gitignore",
		"format:fix": "npm run format:check -- --write",
		"prepare": "npm run setup",
		"setup": "simple-git-hooks || exit 0",
		"validate": "npm run format:check"
	},
	"lint-staged": {
		"*": "prettier --cache --ignore-unknown --write"
	},
	"simple-git-hooks": {
		"pre-commit": "npx lint-staged",
		"pre-push": "npm run validate"
	}
}

Editor integrations

VS Code

Install the VS Code prettier-vscode plugin by pressing Ctrl+P and pasting the following command:

ext install esbenp.prettier-vscode

Also, make sure to add prettier-vscode to the list of recommended plugins for your project in .vscode/extensions.json:

{
	"recommendations": ["esbenp.prettier-vscode"]
}

You may also want to enable "Format on Save" in .vscode/settings.json:

{
	"editor.defaultFormatter": "esbenp.prettier-vscode",
	"editor.formatOnSave": true
}

WebStorm

The WebStorm default installation should already contain the JetBrains Prettier plugin.

If you install this acdh config via the embedded terminal (Alt+F12) as suggested here the plugin should configure itself automagically. Alternately you may adjust its settings via the Settings/Preferences dialog (Ctrl+Alt+S), under Languages & Frameworks | JavaScript | Prettier . It's highly recommended to check both On code reformat and On Save there as well. (See this section for alternate/additional automation possibilities).

By default the set glob pattern will only match JavaScript, TypeScript, JSX and TSX files. Depending on your stack it's recommended to extend it to

{**/*,*}.{js,json,ts,jsx,tsx,vue}

To ship this config with your project, commit/include the prettier.xml in your .idea config folder:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="PrettierConfiguration">
    <option name="myRunOnSave" value="true" />
    <option name="myRunOnReformat" value="true" />
    <option name="myFilesPattern" value="{**/*,*}.{js,json,ts,jsx,tsx,vue,css,scss,sass}" />
  </component>
</project>

For more detailed instructions see the WebStorm docs on Prettier and Vue.js formatting

How to adjust tab width

We use tabs, not spaces, for indentation because of their accessibility benefits. Users are then free to configure their preferred tab width in their text editors.

Adding an .editorconfig file to the root of a project provides a way to adjust the tab width, which is understood by most text editors automatically (VS Code requires a separate plugin).

In VS Code, you can adjust the tab width by changing the following in a user's settings.json:

{
	"editor.insertSpaces": false,
	"editor.tabSize": 2
}

On https://github.com you can adjust the tab width in the appearance settings.

In your terminal, you should be able to use the tabs command to set tab width, e.g. tabs 4.

For the output of git diff, you need to adjust the tab width of your pager. When using the default less, you can set git config --global core.pager 'less -x4'.