Skip to content

build: migrate prettier config to typescript and remove eslint-plugin-prettier #540

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

Merged
merged 13 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>eslint/eslint//.github/renovate.json5"]
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>eslint/eslint//.github/renovate.json5"]
}
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,21 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
check-latest: true
- run: npm install
- run: npm run lint

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
check-latest: true
- run: npm install
- run: npm run format:check

test-remote:
name: eslint-remote-tester
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"line-length": false,
"no-inline-html": false
"no-inline-html": false,
"no-duplicate-heading": {
"siblings_only": true
}
}
3 changes: 0 additions & 3 deletions .prettierrc.js

This file was deleted.

185 changes: 73 additions & 112 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
The MIT License (MIT)
=====================
# The MIT License (MIT)

Copyright © 2016 Teddy Katz

Expand Down
4 changes: 3 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
import prettier from 'eslint-config-prettier/flat';
import markdown from 'eslint-plugin-markdown';
import pluginN from 'eslint-plugin-n';
import tseslint from 'typescript-eslint';

import eslintPlugin from './lib/index.js';

const dirname = path.dirname(fileURLToPath(import.meta.url));
Expand All @@ -25,10 +27,10 @@ export default tseslint.config([
...compat.extends(
'not-an-aardvark/node',
'plugin:@eslint-community/eslint-comments/recommended',
'plugin:prettier/recommended',
'plugin:unicorn/recommended',
),
pluginN.configs['flat/recommended'],
prettier,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we technically want to include this last to ensure it overrides any incompatible config?

eslint.config.js (flat config): Import eslint-config-prettier, and put it in the configuration array – after other configs that you want to override.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will generally put the prettier config after all of the reusable configs, but before any configs that I've created with overrides / additional rules. The idea being that anything I add myself is an intentional choice and should take precedence, which I think aligns with the spirit of that documentation. With that said, it's currently before the TS Configs, so I should at least move it to be after those (I authored this PR before adding the TS configs). Would you prefer I move it all the way to the end or just after the ts configs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your reasoning makes sense. I'll leave it up to you.

{
rules: {
'@eslint-community/eslint-comments/no-unused-disable': 'error',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"license": "MIT",
"scripts": {
"build": "tsup",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*",
"lint:docs": "markdownlint \"**/*.md\"",
"lint:eslint-docs": "npm-run-all -s build \"update:eslint-docs -- --check\"",
"lint:js": "eslint --cache --ignore-pattern \"**/*.md\" .",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the path needed?

Copy link
Contributor Author

@michaelfaith michaelfaith Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's optional. It defaults to current working directory. I can add it back, if you prefer?

https://eslint.org/docs/latest/use/command-line-interface
Image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine to use default then.

"lint:js": "eslint --cache --ignore-pattern \"**/*.md\"",
"lint:js-docs": "eslint --no-inline-config \"**/*.md\"",
"lint:package-json": "npmPkgJsonLint .",
"release": "release-it",
Expand Down Expand Up @@ -69,7 +71,6 @@
"eslint-doc-generator": "^2.2.2",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-unicorn": "^56.0.1",
"eslint-remote-tester": "^4.0.3",
"eslint-scope": "^8.0.1",
Expand All @@ -80,7 +81,7 @@
"markdownlint-cli": "^0.43.0",
"npm-package-json-lint": "^8.0.0",
"npm-run-all2": "^7.0.1",
"prettier": "^3.4.1",
"prettier": "^3.6.2",
"release-it": "^17.2.0",
"tsup": "^8.5.0",
"typescript": "^5.9.2",
Expand Down
7 changes: 7 additions & 0 deletions prettier.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { type Config } from 'prettier';

const config: Config = {
singleQuote: true,
};

export default config;
22 changes: 11 additions & 11 deletions tests/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1653,8 +1653,8 @@ describe('utils', () => {
});
});

describe('evaluateObjectProperties', function () {
it('behaves correctly with simple object expression', function () {
describe('evaluateObjectProperties', () => {
it('behaves correctly with simple object expression', () => {
const getObjectExpression = (ast: Program): ObjectExpression =>
(ast.body[0] as VariableDeclaration).declarations[0]
.init as ObjectExpression;
Expand All @@ -1670,7 +1670,7 @@ describe('utils', () => {
assert.deepEqual(result, getObjectExpression(ast).properties);
});

it('behaves correctly with spreads of objects', function () {
it('behaves correctly with spreads of objects', () => {
const getObjectExpression = (
ast: Program,
bodyElement: number,
Expand Down Expand Up @@ -1703,7 +1703,7 @@ describe('utils', () => {
]);
});

it('behaves correctly with non-variable spreads', function () {
it('behaves correctly with non-variable spreads', () => {
const getObjectExpression = (ast: Program): ObjectExpression =>
(ast.body[1] as VariableDeclaration).declarations[0]
.init as ObjectExpression;
Expand All @@ -1720,7 +1720,7 @@ describe('utils', () => {
assert.deepEqual(result, []);
});

it('behaves correctly with spread with variable that cannot be found', function () {
it('behaves correctly with spread with variable that cannot be found', () => {
const ast = espree.parse(`const obj = { ...foo };`, {
ecmaVersion: 9,
range: true,
Expand All @@ -1734,7 +1734,7 @@ describe('utils', () => {
assert.deepEqual(result, []);
});

it('behaves correctly when passed wrong node type', function () {
it('behaves correctly when passed wrong node type', () => {
const ast = espree.parse(`foo();`, {
ecmaVersion: 9,
range: true,
Expand All @@ -1745,7 +1745,7 @@ describe('utils', () => {
});
});

describe('getMessagesNode', function () {
describe('getMessagesNode', () => {
type TestCase = {
code: string;
getResult: ((ast: Program) => ObjectExpression) | (() => void);
Expand Down Expand Up @@ -1821,7 +1821,7 @@ describe('utils', () => {
});
});

describe('getMessageIdNodes', function () {
describe('getMessageIdNodes', () => {
type TestCase = {
code: string;
getResult: (ast: Program) => Property[];
Expand Down Expand Up @@ -1892,7 +1892,7 @@ describe('utils', () => {
});
});

describe('getMessageIdNodeById', function () {
describe('getMessageIdNodeById', () => {
type TestCase = {
code: string;
run: (
Expand Down Expand Up @@ -1961,7 +1961,7 @@ describe('utils', () => {
});
});

describe('findPossibleVariableValues', function () {
describe('findPossibleVariableValues', () => {
it('returns the right nodes', () => {
const code =
'let x = 123; x = 456; x = foo(); if (foo) { x = 789; } x(); console.log(x); x += "shouldIgnore"; x + "shouldIgnore";';
Expand Down Expand Up @@ -2006,7 +2006,7 @@ describe('utils', () => {
});
});

describe('isVariableFromParameter', function () {
describe('isVariableFromParameter', () => {
it('returns true for function parameter', () => {
const code =
'function myFunc(x) { if (foo) { x = "abc"; } console.log(x) }; myFunc("def");';
Expand Down