Skip to content

Commit d107e8e

Browse files
committed
build: migrate prettier config to typescript and remove eslint-plugin-prettier
This change moves from using `eslint-prettier-plugin` to using `eslint-config-prettier` and prettier directly for format checking. A result of us never running prettier on the root files, is that there were some adjustments needed. I ran prettier on the repo and have added those changes too. Lastly, I moved the config to `typescript`.
1 parent 2127dab commit d107e8e

File tree

12 files changed

+119
-135
lines changed

12 files changed

+119
-135
lines changed

.github/renovate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["github>eslint/eslint//.github/renovate.json5"]
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["github>eslint/eslint//.github/renovate.json5"]
44
}

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
node-version: 'lts/*'
3535
- run: npm install
3636
- run: npm run lint
37+
- run: npm run format:check
3738

3839
test-remote:
3940
name: eslint-remote-tester

.markdownlint.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"line-length": false,
3-
"no-inline-html": false
3+
"no-inline-html": false,
4+
"no-duplicate-heading": {
5+
"siblings_only": true
6+
}
47
}

CHANGELOG.md

Lines changed: 73 additions & 112 deletions
Large diffs are not rendered by default.

LICENSE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
The MIT License (MIT)
2-
=====================
1+
# The MIT License (MIT)
32

43
Copyright © 2016 Teddy Katz
54

eslint.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { fileURLToPath } from 'node:url';
33
import js from '@eslint/js';
44
import { FlatCompat } from '@eslint/eslintrc';
55
import { defineConfig } from 'eslint/config';
6+
import prettier from 'eslint-config-prettier/flat';
67
import markdown from 'eslint-plugin-markdown';
78
import pluginN from 'eslint-plugin-n';
9+
import unicorn from 'eslint-plugin-unicorn';
10+
811
import eslintPlugin from './lib/index.js';
912

1013
const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -25,9 +28,8 @@ export default defineConfig([
2528
...compat.extends(
2629
'not-an-aardvark/node',
2730
'plugin:@eslint-community/eslint-comments/recommended',
28-
'plugin:prettier/recommended',
29-
'plugin:unicorn/recommended',
3031
),
32+
unicorn.configs.recommended,
3133
pluginN.configs['flat/recommended'],
3234
{
3335
rules: {
@@ -82,4 +84,5 @@ export default defineConfig([
8284
'unicorn/filename-case': 'off',
8385
},
8486
},
87+
prettier,
8588
]);

lib/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ import testCaseShorthandStrings from './rules/test-case-shorthand-strings.js';
4141

4242
const require = createRequire(import.meta.url);
4343

44-
const packageMetadata = require("../package.json") as {
45-
name: string;
46-
version: string;
44+
const packageMetadata = require('../package.json') as {
45+
name: string;
46+
version: string;
4747
};
4848

4949
const PLUGIN_NAME = packageMetadata.name.replace(/^eslint-plugin-/, '');

lib/rules/no-only-tests.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ const rule: Rule.RuleModule = {
5656
sourceCode.getTokenBefore(onlyProperty);
5757
const tokenAfter =
5858
sourceCode.getTokenAfter(onlyProperty);
59-
if ((tokenBefore && tokenAfter) &&
59+
if (
60+
tokenBefore &&
61+
tokenAfter &&
6062
((isCommaToken(tokenBefore) &&
6163
isCommaToken(tokenAfter)) || // In middle of properties
62-
(isOpeningBraceToken(tokenBefore) &&
63-
isCommaToken(tokenAfter))) // At beginning of properties
64+
(isOpeningBraceToken(tokenBefore) &&
65+
isCommaToken(tokenAfter))) // At beginning of properties
6466
) {
6567
yield fixer.remove(tokenAfter); // Remove extra comma.
6668
}
67-
if ((tokenBefore && tokenAfter) &&
69+
if (
70+
tokenBefore &&
71+
tokenAfter &&
6872
isCommaToken(tokenBefore) &&
6973
isClosingBraceToken(tokenAfter)
7074
) {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"license": "MIT",
1313
"scripts": {
1414
"build": "tsup",
15+
"format": "prettier --write .",
16+
"format:check": "prettier --check .",
1517
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*",
1618
"lint:docs": "markdownlint \"**/*.md\"",
1719
"lint:eslint-docs": "npm-run-all -s build \"update:eslint-docs -- --check\"",
@@ -68,8 +70,7 @@
6870
"eslint-doc-generator": "^2.2.2",
6971
"eslint-plugin-markdown": "^5.1.0",
7072
"eslint-plugin-n": "^17.21.0",
71-
"eslint-plugin-prettier": "^5.5.3",
72-
"eslint-plugin-unicorn": "^56.0.1",
73+
"eslint-plugin-unicorn": "^60.0.0",
7374
"eslint-remote-tester": "^4.0.3",
7475
"eslint-scope": "^8.0.1",
7576
"espree": "^10.0.1",
@@ -79,7 +80,7 @@
7980
"markdownlint-cli": "^0.43.0",
8081
"npm-package-json-lint": "^8.0.0",
8182
"npm-run-all2": "^7.0.1",
82-
"prettier": "^3.4.1",
83+
"prettier": "^3.6.2",
8384
"release-it": "^17.2.0",
8485
"tsup": "^8.5.0",
8586
"typescript": "^5.9.2",

prettier.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export default {
1+
import { type Config } from 'prettier';
2+
3+
const config: Config = {
24
singleQuote: true,
35
};
6+
7+
export default config;

0 commit comments

Comments
 (0)