2.1.0 • Published 1 year ago

@logicer/prettier-config v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Logicer's Prettier Base Configuration

npm (scoped) GitHub Workflow Status (with event) GitHub commit activity (branch) Type Coverage

Logicer's Prettier configuration for use in other projects. Able to be built upon for the project's specific needs.

An accompanying recommended .editorconfig file is available here

Install

npm install --save-dev --save-exact prettier
npm install --save-dev @logicer/prettier-config

Usage

In any valid Prettier config file, make its sole export the string:

"@logicer/prettier-config"

You can also extend upon the configuration by adding importing it into a .prettierrc.js file. For example:

import logicerPrettierConfig from "@logicer/prettier-config";

export default {
  ...logicerPrettierConfig,
  // ... Your modifications
};

Advanced

This modules also exports prettierConfigGenerator(options). This produces a prettier config with appropriate plugins enabled and configured based the the options provided. The options should match those passed to @logicer/eslint-plugin's configGenerator()

For example, in your .prettierrc.js:

import {options} from "./eslint.config.js";
import {prettierConfigGenerator} from "@logicer/prettier-config";

export default prettierConfigGenerator(options);

If you create multiple generator instances in your eslint.config.js, it is recommended you either make use of overrides or pass a combination of the option sets, choosing the most featureful settings where appropriate

For example, in your .prettierrc.js:

import {prettierConfigGenerator} from "@logicer/prettier-config";

const optionsA = {
  ecmaVersion: 2017,
  javascript: true,
  jest: true
};

const optionsB = {
  ecmaVersion: 2017,
  javascript: true,
  jsdoc: true,
  prettier: true,
  typescript: true
};

const resultingOptions = {
  // Use the highest ecmaVersion used in the configs.
  ecmaVersion: 2020,
  // Keep identical options as is.
  javascript: true,
  // Enable options that are enabled in at least one option set.
  jest: true,
  jsdoc: true,
  prettier: true,
  typescript: true

  // Omitted options remain disabled by default.
  // svelte: false
};

export default prettierConfigGenerator(resultingOptions);
2.1.0

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago