Skip to content

Commit 2f0837d

Browse files
committed
chore: workaround for unicorn-x with ESLint v8 compatibility
1 parent 5300425 commit 2f0837d

File tree

11 files changed

+152
-59
lines changed

11 files changed

+152
-59
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
if: ${{ matrix.eslint < 9 }}
4545
run: |
4646
yarn add -D eslint@${{ matrix.eslint }} @types/eslint@9
47-
yarn set resolution eslint-plugin-unicorn@npm:^58.0.0 npm:^56
47+
yarn set resolution eslint-plugin-unicorn-x@npm:eslint-plugin-unicorn@^59.0.1 npm:npm:eslint-plugin-unicorn@^56
4848
4949
- name: Build, Lint and Test
5050
run: |

eslint.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ export default config([
1616
'@typescript-eslint/no-unnecessary-condition': 'off',
1717
'sonarjs/fixme-tag': 'off',
1818
'sonarjs/todo-tag': 'off',
19-
'unicorn-x/prefer-export-from': [
19+
'unicorn/prefer-export-from': [
2020
'error',
2121
{
2222
ignoreUsedVariables: true,
2323
},
2424
],
25-
'unicorn-x/template-indent': 'off',
2625
},
2726
},
2827
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"resolutions": {
6262
"eslint-mdx": "link:packages/eslint-mdx",
6363
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx",
64+
"eslint-plugin-unicorn-x": "npm:eslint-plugin-unicorn@^59.0.1",
6465
"prettier": "^3.5.3",
6566
"synckit": "^0.11.2"
6667
},

packages/eslint-mdx/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const arrayify = <T, R = T extends Array<infer S> ? S : T>(
1111
...args: T[]
1212
) =>
1313
args.reduce<R[]>((arr, curr) => {
14-
// eslint-disable-next-line sonarjs/no-nested-conditional, unicorn-x/no-nested-ternary
14+
// eslint-disable-next-line sonarjs/no-nested-conditional
1515
arr.push(...(Array.isArray(curr) ? curr : curr == null ? [] : [curr]))
1616
return arr
1717
}, [])

packages/eslint-mdx/src/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable unicorn-x/no-await-expression-member */
1+
/* eslint-disable unicorn/no-await-expression-member */
22

33
import path from 'node:path'
44
import { pathToFileURL } from 'node:url'

packages/eslint-plugin-mdx/src/processors/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ESLinter.prototype.verify = function (
4141
/* istanbul ignore next */
4242
const settings = ((
4343
config.extractConfig?.(
44-
// eslint-disable-next-line unicorn-x/no-typeof-undefined
44+
// eslint-disable-next-line unicorn/no-typeof-undefined
4545
typeof options === 'undefined' || typeof options === 'string'
4646
? options
4747
: options.filename,

packages/eslint-plugin-mdx/src/rules/remark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const remark: Rule.RuleModule = {
7171
} of messages) {
7272
// https://github.com/remarkjs/remark-lint/issues/65#issuecomment-220800231
7373
/* istanbul ignore next */
74-
// eslint-disable-next-line sonarjs/no-nested-conditional, unicorn-x/no-nested-ternary
74+
// eslint-disable-next-line sonarjs/no-nested-conditional
7575
const severity = fatal ? 2 : fatal == null ? 0 : 1
7676
/* istanbul ignore if */
7777
if (!severity) {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
diff --git a/node_modules/@1stg/eslint-config/base.js b/node_modules/@1stg/eslint-config/base.js
2+
index 8e0b6f5..68a5e50 100644
3+
--- a/node_modules/@1stg/eslint-config/base.js
4+
+++ b/node_modules/@1stg/eslint-config/base.js
5+
@@ -34,7 +34,7 @@ export const base = tseslint.config([
6+
promise.configs['flat/recommended'],
7+
regexp.configs['flat/recommended'],
8+
sonarjs.configs.recommended,
9+
- unicornX.configs.recommended,
10+
+ unicornX.configs['flat/recommended'],
11+
prettierExtends,
12+
isEslintNodeDepsEnabled && isPkgAvailable('eslint-plugin-node-dependencies')
13+
? [
14+
@@ -131,7 +131,7 @@ export const base = tseslint.config([
15+
},
16+
],
17+
'no-negated-condition': 2,
18+
- 'no-process-exit': 0, // suspended by unicorn-x/no-process-exit
19+
+ 'no-process-exit': 0, // suspended by unicorn/no-process-exit
20+
21+
// The following rules are duplicate with `eslint-plugin-import-x`
22+
'n/no-extraneous-import': 0,
23+
@@ -146,15 +146,15 @@ export const base = tseslint.config([
24+
'prefer-const': [2, { destructuring: 'all' }],
25+
'prefer-object-spread': 2,
26+
'simple-import-sort/exports': 2,
27+
- 'unicorn-x/catch-error-name': [
28+
+ 'unicorn/catch-error-name': [
29+
2,
30+
{
31+
name: 'error',
32+
ignore: ['^e(rr)?$'],
33+
},
34+
],
35+
- 'unicorn-x/consistent-function-scoping': 0,
36+
- 'unicorn-x/filename-case': [
37+
+ 'unicorn/consistent-function-scoping': 0,
38+
+ 'unicorn/filename-case': [
39+
2,
40+
{
41+
cases: {
42+
@@ -165,13 +165,13 @@ export const base = tseslint.config([
43+
ignore: [/^[A-Z](([\dA-Z]+_)*[\dA-Z]+)?\.(mdx?|ya?ml)$/],
44+
},
45+
],
46+
- 'unicorn-x/no-array-reduce': 0,
47+
- 'unicorn-x/no-null': 0,
48+
- 'unicorn-x/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
49+
- 'unicorn-x/prefer-module': 0,
50+
- 'unicorn-x/prefer-object-from-entries': 0,
51+
- 'unicorn-x/prevent-abbreviations': 0,
52+
- 'unicorn-x/prefer-export-from': [2, { ignoreUsedVariables: true }],
53+
+ 'unicorn/no-array-reduce': 0,
54+
+ 'unicorn/no-null': 0,
55+
+ 'unicorn/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
56+
+ 'unicorn/prefer-module': 0,
57+
+ 'unicorn/prefer-object-from-entries': 0,
58+
+ 'unicorn/prevent-abbreviations': 0,
59+
+ 'unicorn/prefer-export-from': [2, { ignoreUsedVariables: true }],
60+
},
61+
},
62+
{
63+
diff --git a/node_modules/@1stg/eslint-config/ts-base.js b/node_modules/@1stg/eslint-config/ts-base.js
64+
index 18bb9f2..214471d 100644
65+
--- a/node_modules/@1stg/eslint-config/ts-base.js
66+
+++ b/node_modules/@1stg/eslint-config/ts-base.js
67+
@@ -129,10 +129,10 @@ export const tsBase = tseslint.config({
68+
'promise/always-return': 0,
69+
'promise/catch-or-return': 0,
70+
// ts itself has guaranteed it
71+
- 'unicorn-x/no-array-callback-reference': 0,
72+
+ 'unicorn/no-array-callback-reference': 0,
73+
// covered by @typescript-eslint/no-extraneous-class
74+
- 'unicorn-x/no-static-only-class': 0,
75+
+ 'unicorn/no-static-only-class': 0,
76+
// covered by @typescript-eslint/no-this-alias
77+
- 'unicorn-x/no-this-assignment': 0,
78+
+ 'unicorn/no-this-assignment': 0,
79+
},
80+
})

test/__snapshots__/fixtures.test.ts.snap

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,7 @@ exports[`fixtures lint code blocks should work as expected: code-blocks/278.md 1
4848
"message": "Prefer \`Array#flat()\` over \`[].concat()\` to flatten an array.",
4949
"messageId": "prefer-array-flat",
5050
"nodeType": "CallExpression",
51-
"ruleId": "unicorn-x/prefer-array-flat",
52-
"severity": 2,
53-
},
54-
{
55-
"column": 21,
56-
"endColumn": 27,
57-
"endLine": 12,
58-
"fix": {
59-
"range": [
60-
141,
61-
152,
62-
],
63-
"text": "a]",
64-
},
65-
"line": 12,
66-
"message": "Prefer the spread operator over \`Array#concat(…)\`.",
67-
"messageId": "array-concat",
68-
"nodeType": "Identifier",
69-
"ruleId": "unicorn-x/prefer-spread",
51+
"ruleId": "unicorn/prefer-array-flat",
7052
"severity": 2,
7153
},
7254
{
@@ -239,7 +221,7 @@ exports[`fixtures lint code blocks should work as expected: code-blocks/455.mdx
239221
"message": "Prefer \`.at(…)\` over \`[….length - index]\`.",
240222
"messageId": "negative-index",
241223
"nodeType": "BinaryExpression",
242-
"ruleId": "unicorn-x/prefer-at",
224+
"ruleId": "unicorn/prefer-at",
243225
"severity": 2,
244226
},
245227
]
@@ -472,7 +454,7 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = `
472454
"message": "The variable \`num\` should be named \`number_\`. A more descriptive name will do too.",
473455
"messageId": "replace",
474456
"nodeType": "Identifier",
475-
"ruleId": "unicorn-x/prevent-abbreviations",
457+
"ruleId": "unicorn/prevent-abbreviations",
476458
"severity": 2,
477459
},
478460
{
@@ -483,10 +465,11 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = `
483465
"message": "Prefer the spread operator over \`Array#concat(…)\`.",
484466
"messageId": "array-concat",
485467
"nodeType": "Identifier",
486-
"ruleId": "unicorn-x/prefer-spread",
468+
"ruleId": "unicorn/prefer-spread",
487469
"severity": 2,
488470
"suggestions": [
489471
{
472+
"data": {},
490473
"desc": "First argument is an \`array\`.",
491474
"fix": {
492475
"range": [
@@ -500,6 +483,7 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = `
500483
"messageId": "argument-is-spreadable",
501484
},
502485
{
486+
"data": {},
503487
"desc": "First argument is not an \`array\`.",
504488
"fix": {
505489
"range": [
@@ -529,7 +513,7 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = `
529513
"message": "The variable \`i\` should be named \`index\`. A more descriptive name will do too.",
530514
"messageId": "replace",
531515
"nodeType": "Identifier",
532-
"ruleId": "unicorn-x/prevent-abbreviations",
516+
"ruleId": "unicorn/prevent-abbreviations",
533517
"severity": 2,
534518
},
535519
{
@@ -547,7 +531,7 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = `
547531
"message": "Prefer \`.at(…)\` over \`[….length - index]\`.",
548532
"messageId": "negative-index",
549533
"nodeType": "BinaryExpression",
550-
"ruleId": "unicorn-x/prefer-at",
534+
"ruleId": "unicorn/prefer-at",
551535
"severity": 2,
552536
},
553537
]

test/fixtures.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ const getCli = (lintCodeBlocks = false, fix?: boolean) =>
1717
overrideConfig: config(
1818
eslintJs.configs.recommended,
1919
...configs.recommended,
20-
unicornX.configs.recommended,
20+
// eslint-disable-next-line sonarjs/deprecation -- for ESLint v8 compatibility
21+
unicornX.configs['flat/recommended'],
2122
mdx.configs.flat,
2223
mdx.configs.flatCodeBlocks,
2324
prettierRecommended,
24-
{
25-
rules: {
26-
'unicorn-x/template-indent': 'off',
27-
},
28-
},
2925
{
3026
files: ['**/*.{js,jsx,md,mdx,ts,tsx}'],
3127
extends: [react.configs.flat.recommended],

0 commit comments

Comments
 (0)