Skip to content

Commit 06b73d6

Browse files
authored
Meta: Replace XO with raw ESLint config (refined-github#7752)
1 parent 62624fa commit 06b73d6

77 files changed

Lines changed: 3677 additions & 2905 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ jobs:
9595
- run: npm run build:bundle
9696
- uses: maxim-lobanov/setup-xcode@v1
9797
with:
98-
xcode-version: '15.0.1'
98+
xcode-version: 15.0.1
9999
- run: npm run pack:safari

.xo-config.json

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

build/features.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {existsSync, readdirSync, readFileSync} from 'node:fs';
22
import path from 'node:path';
33
import {test, describe, assert} from 'vitest';
4-
import regexJoin from 'regex-join';
4+
import {regexJoinWithSeparator} from 'regex-join';
55
import fastIgnore from 'fast-ignore';
66

77
import {isFeaturePrivate} from '../source/helpers/feature-utils.js';
@@ -49,7 +49,7 @@ const imageRegex = /\.(png|gif)$/;
4949

5050
const rghUploadsRegex = /refined-github[/]refined-github[/]assets[/]/;
5151

52-
const screenshotRegex = regexJoin(imageRegex, /|/, rghUploadsRegex);
52+
const screenshotRegex = regexJoinWithSeparator('|', [imageRegex, rghUploadsRegex]);
5353

5454
class FeatureFile {
5555
readonly id: FeatureID;
@@ -63,7 +63,7 @@ class FeatureFile {
6363
return existsSync(this.path);
6464
}
6565

66-
// eslint-disable-next-line @typescript-eslint/ban-types -- Just passing it
66+
// eslint-disable-next-line node/prefer-global/buffer, ts/no-restricted-types -- Just passing it
6767
contents(): Buffer {
6868
return readFileSync(this.path);
6969
}

build/manifest.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable camelcase */
21
import {existsSync, readFileSync, writeFileSync} from 'node:fs';
32
import path from 'node:path';
43

build/readme-parser.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/// <reference types="../source/globals.js" />
22

3-
import regexJoin from 'regex-join';
3+
import {regexJoinWithSeparator} from 'regex-join';
44
import {existsSync, readFileSync} from 'node:fs';
55
import parseMarkdown from 'snarkdown';
66

77
// Group names must be unique because they will be merged
8-
const simpleFeatureRegex = /^- \[]\(# "(?<simpleId>[^"]+)"\)(?: 🔥)? (?<simpleDescription>.+)$/gm;
9-
const highlightedFeatureRegex = /<p><a title="(?<highlightedId>[^"]+)"><\/a> (?<highlightedDescripion>.+?)\n\t+<p><img src="(?<highlightedImage>.+?)">/g;
10-
const featureRegex = regexJoin(simpleFeatureRegex, /|/, highlightedFeatureRegex);
8+
const simpleFeatureRegex = /^- \[\]\(# "(?<simpleId>[^"]+)"\)(?: 🔥)? (?<simpleDescription>.+)$/gm;
9+
const highlightedFeatureRegex = /<p><a title="(?<highlightedId>[^"]+)"><\/a> (?<highlightedDescripion>.+)\n\t+<p><img src="(?<highlightedImage>.+?)">/g;
10+
const featureRegex = regexJoinWithSeparator('|', [simpleFeatureRegex, highlightedFeatureRegex]);
1111
const imageRegex = /\.\w{3}$/; // 3 since .png and .gif have 3 letters
1212
const rghUploadsRegex = /refined-github[/]refined-github[/]assets[/]/;
13-
const screenshotRegex = regexJoin(imageRegex, /|/, rghUploadsRegex);
13+
const screenshotRegex = regexJoinWithSeparator('|', [imageRegex, rghUploadsRegex]);
1414

1515
function extractDataFromMatch(match: RegExpMatchArray): FeatureMeta {
1616
const {
@@ -34,7 +34,7 @@ function extractDataFromMatch(match: RegExpMatchArray): FeatureMeta {
3434
return title;
3535
}
3636

37-
const linkLessMarkdownDescription = simpleDescription.replaceAll(/\[(.+?)]\((.+?)\)/g, urlExtracter);
37+
const linkLessMarkdownDescription = simpleDescription.replaceAll(/\[(.+?)\]\((.+?)\)/g, urlExtracter);
3838
return {
3939
id: simpleId as FeatureID,
4040
description: parseMarkdown(linkLessMarkdownDescription),

eslint.config.js

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
import antfu from '@antfu/eslint-config';
2+
3+
export default antfu(
4+
{
5+
react: true,
6+
stylistic: {
7+
indent: 'tab',
8+
},
9+
unicorn: {
10+
allRecommended: true,
11+
},
12+
globals: [
13+
'browser',
14+
],
15+
typescript: {
16+
overrides: {
17+
'ts/method-signature-style': 'off', // Disagree and it breaks types https://github.com/typescript-eslint/typescript-eslint/issues/1991
18+
'ts/consistent-type-definitions': 'off', // Review later
19+
'ts/explicit-function-return-type': [
20+
'error',
21+
{
22+
allowExpressions: true,
23+
},
24+
],
25+
},
26+
},
27+
rules: {
28+
'react-refresh/only-export-components': 'off', // N/A
29+
'react/no-missing-key': 'off', // N/A
30+
31+
'no-irregular-whitespace': 'off', // We do want to use non-breaking spaces
32+
'jsdoc/check-alignment': 'off', // Can't autofix, tedious manual fix
33+
'style/jsx-tag-spacing': 'off', // TODO: Later, together with JSX single quotes
34+
35+
// Antfu style disagreements
36+
'regexp/no-useless-character-class': 'off', // [/] is more readable than \/
37+
'style/object-curly-spacing': ['error', 'never'], // Unnecessary change for now
38+
'style/block-spacing': ['error', 'never'], // Same
39+
'jsonc/array-bracket-spacing': 'off', // Same
40+
'style/brace-style': ['error', '1tbs'], // Naw, man
41+
'style/semi': ['error', 'always'],
42+
'style/member-delimiter-style': ['error', {
43+
multiline: {
44+
delimiter: 'semi',
45+
},
46+
}],
47+
'style/arrow-parens': ['error', 'as-needed'],
48+
'prefer-template': 'off', // When there's a single `+` templates are less readable
49+
'style/jsx-one-expression-per-line': 'off', // Terrible for inline elements, e.g. text
50+
51+
// Disable some unicorn rules
52+
'unicorn/expiring-todo-comments': 'off', // We just got too many, too much noise
53+
'unicorn/no-nested-ternary': 'off',
54+
'unicorn/better-regex': 'off',
55+
'unicorn/prefer-top-level-await': 'off',
56+
'unicorn/prefer-dom-node-dataset': 'off',
57+
'unicorn/prefer-ternary': 'off', // Unreadable https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1633
58+
'unicorn/no-null': 'off', // TODO: Later
59+
'unicorn/prevent-abbreviations': [
60+
'error',
61+
{
62+
replacements: {
63+
props: false,
64+
ref: false,
65+
nav: false,
66+
},
67+
},
68+
],
69+
70+
// Restore errors
71+
'no-await-in-loop': 'error',
72+
'new-cap': [
73+
'error',
74+
{
75+
newIsCap: true,
76+
capIsNew: true,
77+
},
78+
],
79+
80+
'test/consistent-test-it': 'off',
81+
'sort-imports': 'off',
82+
'antfu/top-level-function': 'off', // Maybe later
83+
'unused-imports/no-unused-vars': 'off', // Buggy
84+
'no-console': 'off',
85+
'jsonc/sort-keys': 'off',
86+
87+
'ts/no-restricted-types': [
88+
'error',
89+
{
90+
types: {
91+
'object': {
92+
message: 'The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848',
93+
fixWith: 'Record<string, unknown>',
94+
},
95+
'null': {
96+
message: 'Use `undefined` instead. See: https://github.com/sindresorhus/meta/issues/7',
97+
fixWith: 'undefined',
98+
},
99+
'Buffer': {
100+
message: 'Use Uint8Array instead. See: https://sindresorhus.com/blog/goodbye-nodejs-buffer',
101+
suggest: [
102+
'Uint8Array',
103+
],
104+
},
105+
'[]': 'Don\'t use the empty array type `[]`. It only allows empty arrays. Use `SomeType[]` instead.',
106+
'[[]]': 'Don\'t use `[[]]`. It only allows an array with a single element which is an empty array. Use `SomeType[][]` instead.',
107+
'[[[]]]': 'Don\'t use `[[[]]]`. Use `SomeType[][][]` instead.',
108+
'[[[[]]]]': 'ur drunk 🤡',
109+
'[[[[[]]]]]': '🦄💥',
110+
},
111+
},
112+
],
113+
'no-restricted-syntax': [
114+
'error',
115+
{
116+
selector:
117+
':matches([callee.name=delegate], [callee.name=$], [callee.name=$$], [callee.name=observe], [callee.property.name=querySelector], [callee.property.name=querySelectorAll], [callee.property.name=closest])[arguments.0.value=/,/][arguments.0.value.length>=20]:not([arguments.0.value=/:has|:is/])',
118+
message: 'Instead of a single string, pass an array of selectors and add comments to each selector',
119+
},
120+
{
121+
selector:
122+
':matches([callee.name=delegate], [callee.name=$], [callee.name=$$], [callee.name=observe], [callee.property.name=querySelector], [callee.property.name=querySelectorAll], [callee.property.name=closest])[arguments.0.type=ArrayExpression][arguments.0.elements.length=1]:not([arguments.0.value=/:has|:is/])',
123+
message: 'Instead of a single string, pass an array of selectors and add comments to each selector',
124+
},
125+
],
126+
'jsx-quotes': [
127+
'error',
128+
'prefer-double',
129+
],
130+
'no-alert': 'off',
131+
'ts/no-unsafe-assignment': 'off',
132+
'ts/no-unsafe-argument': 'off',
133+
'ts/no-unsafe-member-access': 'off',
134+
'ts/no-unsafe-return': 'off',
135+
'ts/no-unsafe-call': 'off',
136+
'ts/consistent-type-imports': 'off',
137+
'n/prefer-global/process': 'off',
138+
'import/no-cycle': 'off', // Slow, Rollup handles this
139+
'import/no-unassigned-import': 'off',
140+
'import/prefer-default-export': 'error',
141+
'import/order': [
142+
'error',
143+
{
144+
'groups': [
145+
[
146+
'builtin',
147+
'external',
148+
],
149+
],
150+
'newlines-between': 'always-and-inside-groups',
151+
},
152+
],
153+
// TODO: Enable after https://github.com/Rel1cx/eslint-react/issues/739
154+
// "react/function-component-definition": [
155+
// "error",
156+
// {
157+
// "namedComponents": "function-declaration"
158+
// }
159+
// ]
160+
},
161+
},
162+
{
163+
files: [
164+
'build/*',
165+
],
166+
rules: {
167+
'ts/triple-slash-reference': 'off',
168+
'unicorn/prefer-module': 'off',
169+
},
170+
},
171+
{
172+
files: [
173+
'source/features/*',
174+
],
175+
rules: {
176+
'import/prefer-default-export': 'off',
177+
},
178+
},
179+
{
180+
files: [
181+
'**/*.md',
182+
],
183+
rules: {
184+
'style/no-multiple-empty-lines': 'off',
185+
},
186+
},
187+
{
188+
files: [
189+
'.github/**',
190+
],
191+
rules: {
192+
'unicorn/filename-case': 'off',
193+
},
194+
},
195+
// https://eslint.org/docs/latest/use/configure/ignore#ignoring-files
196+
{
197+
ignores: ['safari'],
198+
},
199+
);

0 commit comments

Comments
 (0)