Skip to content

Commit

Permalink
build: refactor linting
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Aug 22, 2023
1 parent 2e40a05 commit d37632d
Show file tree
Hide file tree
Showing 72 changed files with 427 additions and 530 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*": "prettier --ignore-unknown --write",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --ext .mjs,.js,.cjs,.ts,.tsx --fix",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --fix",
"src/**.ts": "vitest related --run --config ../../vitest.config.ts"
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"eslint.workingDirectories": [{ "pattern": "./apps/*" }, { "pattern": "./packages/*" }],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.experimental.useFlatConfig": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand Down
1 change: 0 additions & 1 deletion apps/guide/.eslintignore

This file was deleted.

13 changes: 0 additions & 13 deletions apps/guide/.eslintrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions apps/guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"dev:next": "next dev",
"dev:css": "yarn generate:css --watch",
"generate:css": "unocss 'src/**/*.tsx' 'contentlayer.config.ts' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --fix --format=pretty",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "yarn format"
},
"type": "commonjs",
Expand Down Expand Up @@ -74,14 +74,14 @@
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.55.2",
"@unocss/eslint-config": "^0.55.2",
"@unocss/eslint-plugin": "^0.55.2",
"@unocss/reset": "^0.55.2",
"@vitejs/plugin-react": "^4.0.4",
"@vitest/coverage-v8": "^0.34.2",
"concurrently": "^8.2.0",
"concurrently": "^8.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.47",
"eslint-config-neon": "^0.1.54",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.10.4",
"hast-util-to-string": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion apps/website/.eslintignore

This file was deleted.

13 changes: 0 additions & 13 deletions apps/website/.eslintrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"dev:next": "next dev",
"dev:css": "yarn generate:css --watch",
"generate:css": "unocss 'src/**/*.tsx' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --fix --format=pretty",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "yarn format"
},
"type": "module",
Expand Down Expand Up @@ -83,15 +83,15 @@
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.55.2",
"@unocss/eslint-config": "^0.55.2",
"@unocss/eslint-plugin": "^0.55.2",
"@unocss/reset": "^0.55.2",
"@vitejs/plugin-react": "^4.0.4",
"@vitest/coverage-v8": "^0.34.2",
"concurrently": "^8.2.0",
"concurrently": "^8.2.1",
"cpy-cli": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.47",
"eslint-config-neon": "^0.1.54",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.10.4",
"lighthouse": "^11.0.0",
Expand Down
1 change: 0 additions & 1 deletion apps/website/src/hooks/useSystemThemeFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ export function useSystemThemeFallback() {
if (theme === 'auto') {
localStorage.setItem('theme', 'system');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}
97 changes: 97 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import unocss from '@unocss/eslint-plugin';
import common from 'eslint-config-neon/flat/common.js';
import edge from 'eslint-config-neon/flat/edge.js';
import next from 'eslint-config-neon/flat/next.js';
import node from 'eslint-config-neon/flat/node.js';
import prettier from 'eslint-config-neon/flat/prettier.js';
import react from 'eslint-config-neon/flat/react.js';
import typescript from 'eslint-config-neon/flat/typescript.js';
import deepMerge from 'ts-deepmerge';

const generalRuleset = Object.freeze(
deepMerge.withOptions({ mergeArrays: false }, ...common, ...node, ...typescript, {
files: [
'{apps,packages}/**/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'{apps,packages}/**/bin/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'{apps,packages}/**/__tests__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.eslint.json', './apps/*/tsconfig.eslint.json', './packages/*/tsconfig.eslint.json'],
},
},
rules: {
'@typescript-eslint/consistent-type-definitions': [2, 'interface'],
'jsdoc/no-undefined-types': 1,
},
}),
);

const reactRuleset = Object.freeze(
deepMerge.withOptions({ mergeArrays: false }, generalRuleset, ...react, ...next, ...edge, {
files: [
'apps/**/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'apps/**/bin/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'apps/**/__tests__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'packages/ui/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
],
plugins: {
'@unocss': unocss,
},
rules: {
'@next/next/no-html-link-for-pages': 0,
'react/react-in-jsx-scope': 0,
'react/jsx-filename-extension': [1, { extensions: ['.tsx'] }],
},
settings: {
react: {
version: 'detect',
},
},
}),
);

const prettierRuleset = Object.freeze(
deepMerge.withOptions({ mergeArrays: false }, ...prettier, {
files: [
'{apps,packages}/**/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'{apps,packages}/**/bin/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'{apps,packages}/**/__tests__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
],
}),
);

/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
{
ignores: ['**/.next', '**/coverage', '**/dist', '**/node_modules', '**/.contentlayer', '**/template'],
},
generalRuleset,
reactRuleset,
{
files: [
'packages/rest/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'packages/rest/__tests__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
],
rules: {
'n/prefer-global/url': 0,
'n/prefer-global/url-search-params': 0,
'n/prefer-global/buffer': 0,
'n/prefer-global/process': 0,
'no-restricted-globals': 0,
'unicorn/prefer-node-protocol': 0,
},
},
{
files: [
'packages/voice/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'packages/voice/__tests__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
'packages/voice/__mocks__/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}',
],
rules: {
'import/extensions': 0,
'no-restricted-globals': 0,
},
},
prettierRuleset,
];
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "A powerful library for interacting with the Discord API",
"private": true,
"scripts": {
"lint:fast": "eslint .",
"build": "turbo run build",
"build:affected": "turbo run build --filter='...[origin/main]'",
"build:apps": "turbo run build:local --filter='...{apps/*}'",
Expand All @@ -23,6 +24,7 @@
"update": "yarn upgrade-interactive",
"create-package": "node packages/scripts/src/packageScript.mjs"
},
"type": "module",
"contributors": [
"Crawl <icrawltogo@gmail.com>",
"Amish Shah <amishshah.2k@gmail.com>",
Expand Down Expand Up @@ -51,10 +53,14 @@
"@commitlint/config-angular": "^17.7.0",
"@favware/cliff-jumper": "^2.1.1",
"@favware/npm-deprecate": "^1.0.7",
"@unocss/eslint-plugin": "^0.55.2",
"conventional-changelog-cli": "^3.0.0",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.54",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"lint-staged": "^14.0.1",
"ts-deepmerge": "^6.2.0",
"tsup": "^7.2.0",
"turbo": "^1.10.12",
"typescript": "^5.1.6",
Expand Down
4 changes: 0 additions & 4 deletions packages/actions/.eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
"fmt": "yarn format"
},
"type": "module",
Expand Down Expand Up @@ -51,7 +51,7 @@
"@vitest/coverage-v8": "^0.34.2",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.47",
"eslint-config-neon": "^0.1.54",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^3.0.2",
"tsup": "^7.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/actions/src/formatTag/formatTag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export function formatTag(tag: string) {
// eslint-disable-next-line unicorn/no-unsafe-regex
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);

Expand Down
4 changes: 0 additions & 4 deletions packages/api-extractor-utils/.eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/api-extractor-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"private": true,
"scripts": {
"build": "tsup",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.ts --fix --format=pretty",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "yarn format"
},
"exports": {
Expand Down Expand Up @@ -52,7 +52,7 @@
"@types/node": "16.18.41",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.47",
"eslint-config-neon": "^0.1.54",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^3.0.2",
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function generatePath(items: readonly ApiItem[], version: string) {
}
}

// eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex
// eslint-disable-next-line prefer-named-capture-group
return path.replace(/@discordjs\/(.*)\/(.*)?/, `$1/${version}/$2`);
}

Expand Down
4 changes: 0 additions & 4 deletions packages/brokers/.eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/brokers/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const mockRedisClient = {
} as unknown as Redis;

test('pubsub with custom encoding', async () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const encode = vi.fn((data) => data);

const broker = new PubSubRedisBroker({ redisClient: mockRedisClient, encode });
Expand Down
6 changes: 3 additions & 3 deletions packages/brokers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc -p tsconfig.docs.json",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
"fmt": "yarn format",
"docs": "yarn build:docs && api-extractor run --local && api-extractor run --local --config ./api-extractor-docs.json",
"prepack": "yarn lint && yarn test && yarn build",
Expand Down Expand Up @@ -77,7 +77,7 @@
"@vitest/coverage-v8": "^0.34.2",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.47",
"eslint-config-neon": "^0.1.54",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^3.0.2",
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/brokers/src/brokers/redis/BaseRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export abstract class BaseRedisBroker<TEvents extends Record<string, any>>
}

this.listening = true;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

while (true) {
try {
const data = await this.streamReadClient.xreadgroupBuffer(
Expand Down
4 changes: 0 additions & 4 deletions packages/builders/.eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ describe('Application Command toJSON() results', () => {
min_value: -1,
autocomplete: true,
// TODO
// @ts-expect-error You *can* send an empty array with autocomplete: true, should correct that in types
choices: [],
});

Expand Down Expand Up @@ -147,7 +146,6 @@ describe('Application Command toJSON() results', () => {
min_value: -1.23,
autocomplete: true,
// TODO
// @ts-expect-error You *can* send an empty array with autocomplete: true, should correct that in types
choices: [],
});

Expand Down Expand Up @@ -190,7 +188,6 @@ describe('Application Command toJSON() results', () => {
required: true,
autocomplete: true,
// TODO
// @ts-expect-error you *can* send an empty array with autocomplete: true, should correct that in types
choices: [],
});

Expand Down
Loading

2 comments on commit d37632d

@vercel
Copy link

@vercel vercel bot commented on d37632d Aug 22, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on d37632d Aug 22, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.