Skip to content

Commit 575cb27

Browse files
authored
build: migrate prettier config to typescript and remove eslint-plugin-prettier (eslint-community#540)
* git mv prettier config * 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`. * revert unicorn plugin update * revert unicorn plugin update * force latest check for setup-node * temporarily run in sequence to find bad script * temporarily run in sequence to find bad script * undo temporary debug * force latest check for setup-node * add explicit config flag * remove script * add it back * address lint violations in utils tests
1 parent 18f9ae6 commit 575cb27

File tree

10 files changed

+117
-135
lines changed

10 files changed

+117
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,21 @@ jobs:
3232
- uses: actions/setup-node@v4
3333
with:
3434
node-version: 'lts/*'
35+
check-latest: true
3536
- run: npm install
3637
- run: npm run lint
3738

39+
format:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: 'lts/*'
46+
check-latest: true
47+
- run: npm install
48+
- run: npm run format:check
49+
3850
test-remote:
3951
name: eslint-remote-tester
4052
runs-on: ubuntu-latest

.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
}

.prettierrc.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import path from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import js from '@eslint/js';
44
import { FlatCompat } from '@eslint/eslintrc';
5+
import prettier from 'eslint-config-prettier/flat';
56
import markdown from 'eslint-plugin-markdown';
67
import pluginN from 'eslint-plugin-n';
78
import tseslint from 'typescript-eslint';
9+
810
import eslintPlugin from './lib/index.js';
911

1012
const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -25,10 +27,10 @@ export default tseslint.config([
2527
...compat.extends(
2628
'not-an-aardvark/node',
2729
'plugin:@eslint-community/eslint-comments/recommended',
28-
'plugin:prettier/recommended',
2930
'plugin:unicorn/recommended',
3031
),
3132
pluginN.configs['flat/recommended'],
33+
prettier,
3234
{
3335
rules: {
3436
'@eslint-community/eslint-comments/no-unused-disable': 'error',

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
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\"",
18-
"lint:js": "eslint --cache --ignore-pattern \"**/*.md\" .",
20+
"lint:js": "eslint --cache --ignore-pattern \"**/*.md\"",
1921
"lint:js-docs": "eslint --no-inline-config \"**/*.md\"",
2022
"lint:package-json": "npmPkgJsonLint .",
2123
"release": "release-it",
@@ -69,7 +71,6 @@
6971
"eslint-doc-generator": "^2.2.2",
7072
"eslint-plugin-markdown": "^5.1.0",
7173
"eslint-plugin-n": "^17.21.0",
72-
"eslint-plugin-prettier": "^5.5.3",
7374
"eslint-plugin-unicorn": "^56.0.1",
7475
"eslint-remote-tester": "^4.0.3",
7576
"eslint-scope": "^8.0.1",
@@ -80,7 +81,7 @@
8081
"markdownlint-cli": "^0.43.0",
8182
"npm-package-json-lint": "^8.0.0",
8283
"npm-run-all2": "^7.0.1",
83-
"prettier": "^3.4.1",
84+
"prettier": "^3.6.2",
8485
"release-it": "^17.2.0",
8586
"tsup": "^8.5.0",
8687
"typescript": "^5.9.2",

prettier.config.ts

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

tests/lib/utils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,8 @@ describe('utils', () => {
16531653
});
16541654
});
16551655

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

1673-
it('behaves correctly with spreads of objects', function () {
1673+
it('behaves correctly with spreads of objects', () => {
16741674
const getObjectExpression = (
16751675
ast: Program,
16761676
bodyElement: number,
@@ -1703,7 +1703,7 @@ describe('utils', () => {
17031703
]);
17041704
});
17051705

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

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

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

1748-
describe('getMessagesNode', function () {
1748+
describe('getMessagesNode', () => {
17491749
type TestCase = {
17501750
code: string;
17511751
getResult: ((ast: Program) => ObjectExpression) | (() => void);
@@ -1821,7 +1821,7 @@ describe('utils', () => {
18211821
});
18221822
});
18231823

1824-
describe('getMessageIdNodes', function () {
1824+
describe('getMessageIdNodes', () => {
18251825
type TestCase = {
18261826
code: string;
18271827
getResult: (ast: Program) => Property[];
@@ -1892,7 +1892,7 @@ describe('utils', () => {
18921892
});
18931893
});
18941894

1895-
describe('getMessageIdNodeById', function () {
1895+
describe('getMessageIdNodeById', () => {
18961896
type TestCase = {
18971897
code: string;
18981898
run: (
@@ -1961,7 +1961,7 @@ describe('utils', () => {
19611961
});
19621962
});
19631963

1964-
describe('findPossibleVariableValues', function () {
1964+
describe('findPossibleVariableValues', () => {
19651965
it('returns the right nodes', () => {
19661966
const code =
19671967
'let x = 123; x = 456; x = foo(); if (foo) { x = 789; } x(); console.log(x); x += "shouldIgnore"; x + "shouldIgnore";';
@@ -2006,7 +2006,7 @@ describe('utils', () => {
20062006
});
20072007
});
20082008

2009-
describe('isVariableFromParameter', function () {
2009+
describe('isVariableFromParameter', () => {
20102010
it('returns true for function parameter', () => {
20112011
const code =
20122012
'function myFunc(x) { if (foo) { x = "abc"; } console.log(x) }; myFunc("def");';

0 commit comments

Comments
 (0)