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

Release v2 #9

Merged
merged 9 commits into from
May 13, 2024
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [2.0.0-next.1](https://github.com/boehringer-ingelheim/prettier-config/compare/v1.0.0...v2.0.0-next.1) (2024-05-09)


### Features

* **single-quote:** adjust single-quote option to true ([851cb09](https://github.com/boehringer-ingelheim/prettier-config/commit/851cb094b6f2879c929629fe64c8237fadc7e67c))


### BREAKING CHANGES

* **single-quote:** adjust single-quote option to true

# 1.0.0 (2022-12-01)


Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prettier Configuration

> Prettier is an opinionated code formatter and removes all original styling and ensures that all outputted code conforms to a consistent code style across your entire codebase. - https://prettier.io/docs/en/index.html
> Prettier is an opinionated code formatter and removes all original styling and ensures that all outputted code conforms to a consistent code style across your entire codebase. - <https://prettier.io/docs/en/index.html>

This is the shared prettier configuration used at [Boehringer Ingelheim](https://github.com/orgs/Boehringer-Ingelheim) for code formatting.

Expand Down Expand Up @@ -56,6 +56,16 @@ Specify the line length that the printer will wrap on.
printWidth: 120;
```

### Single Quotes

Use single quotes instead of double quotes. (This only applies if there are the same number of single quotes as double quotes in the string. See the [strings rationale in the prettier docs](https://prettier.io/docs/en/rationale#strings) for more information)

*We have chosen single quotes over double quotes, as it is the most common option for JS/TS (open-source) projects. Reference: <https://bytearcher.com/articles/single-or-double-quotes-strings-javascript/>*

```js
singleQuote: true;
```

## Local Development

### Install Dependencies
Expand Down Expand Up @@ -104,12 +114,12 @@ Give a ⭐️ if this project helped you!

## License

Copyright © 2024 [Boehringer Ingelheim](https://github.com/boehringer-ingelheim).<br />
Copyright © 2024 [Boehringer Ingelheim](https://github.com/boehringer-ingelheim).\
This project is [MIT](https://github.com/boehringer-ingelheim/prettier-config/blob/master/LICENSE) licensed.

## Resources

- https://prettier.io/
- https://conventionalcommits.org/en/v1.0.0/
- https://semantic-release.gitbook.io/
- https://semver.org/
- <https://prettier.io/>
- <https://conventionalcommits.org/en/v1.0.0/>
- <https://semantic-release.gitbook.io/>
- <https://semver.org/>
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import('prettier').Config} */
module.exports = {
printWidth: 120,
singleQuote: true,
};
32 changes: 26 additions & 6 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const configFile = require("./index");
const test = require('node:test');
const assert = require('node:assert/strict');
const configFile = require('./index');
const prettier = require('prettier');

test("Prettier Configuration File", () => {
assert.ok(configFile, "is valid module export");
assert.ok(typeof configFile === "object", "is type of object");
test('Prettier Configuration File', () => {
assert.ok(configFile, 'is valid module export');
assert.ok(typeof configFile === 'object', 'is type of object');
});

test('Line length', async () => {
const candidate1 = "console.log('Test');\n";
assert.ok(await prettier.check(candidate1, { ...configFile, filepath: './index.js' }));

const candidate2 = `console.log('${'a'.repeat(104)}');\n`;
assert.ok(await prettier.check(candidate2, { ...configFile, filepath: './index.js' }));

const candidate3 = `console.log('${'a'.repeat(105)}');\n`;
assert.strictEqual(await prettier.check(candidate3, { ...configFile, filepath: './index.js' }), false);
});

test('Single quotes', async () => {
const candidate1 = "console.log('Test');\n";
assert.ok(await prettier.check(candidate1, { ...configFile, filepath: './index.js' }));

const candidate2 = 'console.log("Test");\n';
assert.strictEqual(await prettier.check(candidate2, { ...configFile, filepath: './index.js' }), false);
});
Loading