From fc674369464b4264b9f0fe04f0067abca921b294 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Fri, 17 Jan 2025 20:54:04 +0000 Subject: [PATCH] chore: switch eslint config to common --- eslint.config.mjs | 118 ++-------------------------------------------- package-lock.json | 118 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 3 files changed, 124 insertions(+), 115 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index e4f13cd..41be635 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,118 +1,8 @@ -/* eslint-disable import/no-unresolved -- We don't care about resolving imports */ -// @ts-check - -import eslint from '@eslint/js'; -import eslintCommentPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs'; -import stylisticPlugin from '@stylistic/eslint-plugin'; -// @ts-expect-error importPlugin is not typed -import importPlugin from 'eslint-plugin-import'; -import tseslint from 'typescript-eslint'; +import eslintConfig from '@pretendonetwork/eslint-config'; import globals from 'globals'; -/** - * Typed to any as the type is incompatible for some reason - it works! - * @type {any} - */ -const stylisticConfig = stylisticPlugin.configs.customize({ - indent: 'tab', - quotes: 'single', - semi: true, - commaDangle: 'never', - braceStyle: '1tbs' -}); - -/** - * Typed to any as the type is incompatible for some reason - it works! - * @type {any} - */ -const eslintCommentPluginConfig = eslintCommentPlugin.recommended; - -export default tseslint.config( - { - // https://eslint.org/docs/rules/ - extends: [eslint.configs.recommended], - rules: { - 'require-atomic-updates': 'off', // This rule is widely controversial and causes false positives - 'no-console': 'off', - 'prefer-const': 'error', - 'no-var': 'error', - 'no-unused-vars': [ - 'error', - { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^ignore' } - ], - 'one-var': ['error', 'never'] - } - }, - { - // https://typescript-eslint.io/rules/ - extends: [tseslint.configs.recommended], - files: ['**/*.ts', '**/*.d.ts'], - rules: { - '@typescript-eslint/no-unused-vars': [ - 'error', - { argsIgnorePattern: '^_' } - ], - '@typescript-eslint/no-inferrable-types': 'off', - '@typescript-eslint/explicit-function-return-type': 'error', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-empty-object-type': ['off'], - '@typescript-eslint/no-import-type-side-effects': 'error', - '@typescript-eslint/consistent-type-imports': ['error', { - fixStyle: 'separate-type-imports' - }] - } - }, - { - // https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/ - extends: [eslintCommentPluginConfig], - rules: { - '@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], - '@eslint-community/eslint-comments/require-description': 'error' - } - }, - { - // https://eslint.style/rules - extends: [stylisticConfig], - rules: { - '@stylistic/no-extra-semi': 'error', - '@stylistic/yield-star-spacing': ['error', 'after'], - '@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before' } }], - '@stylistic/curly-newline': ['error', { - multiline: true, - consistent: true - }], - '@stylistic/object-curly-newline': ['error', { - multiline: true, - consistent: true - }] - } - }, - { - // https://www.npmjs.com/package/eslint-plugin-import - extends: [importPlugin.flatConfigs.recommended, importPlugin.flatConfigs.warnings], - rules: { - 'import/order': ['warn', { - 'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'], - 'newlines-between': 'never' - }], - 'import/first': 'error', - 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'] - } - }, - { - // https://www.npmjs.com/package/eslint-plugin-import - but specifically for TypeScript - extends: [importPlugin.flatConfigs.typescript], - files: ['**/*.ts', '**/*.d.ts'], - settings: { - 'import/resolver': { - typescript: { - alwaysTryTypes: true, - project: './tsconfig.json' - }, - node: true - } - } - }, +export default [ + ...eslintConfig, { // Allow browser globals in webfiles languageOptions: { @@ -161,4 +51,4 @@ export default tseslint.config( '**/*.min.js' ] } -); +]; diff --git a/package-lock.json b/package-lock.json index ea3ab19..58d917e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,7 @@ }, "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", + "@pretendonetwork/eslint-config": "^0.0.1", "@stylistic/eslint-plugin": "^2.13.0", "bmp-js": "^0.1.0", "ejs": "^3.1.10", @@ -1316,6 +1317,30 @@ "node": ">= 8" } }, + "node_modules/@nolyfill/is-core-module": { + "version": "1.0.39", + "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", + "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", + "dev": true, + "engines": { + "node": ">=12.4.0" + } + }, + "node_modules/@pretendonetwork/eslint-config": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@pretendonetwork/eslint-config/-/eslint-config-0.0.1.tgz", + "integrity": "sha512-eGFD1kL5xUiNLGIuSaBL0ArYHZ8D3CN8hPJtUJC19RNtkGTMfrC3sUEFguGt9HHKmO28D3S2ekYqAGUQ9Xn/PQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", + "@stylistic/eslint-plugin": "^2.12.1", + "@typescript-eslint/parser": "^8.20.0", + "eslint": "^9.17.0", + "eslint-import-resolver-typescript": "^3.7.0", + "eslint-plugin-import": "^2.31.0", + "typescript-eslint": "^8.19.1" + } + }, "node_modules/@pretendonetwork/grpc": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-2.0.1.tgz", @@ -3443,6 +3468,19 @@ "node": ">= 0.8" } }, + "node_modules/enhanced-resolve": { + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz", + "integrity": "sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/es-abstract": { "version": "1.23.9", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.9.tgz", @@ -3680,6 +3718,41 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.7.0.tgz", + "integrity": "sha512-Vrwyi8HHxY97K5ebydMtffsWAn1SCR9eol49eCd5fJS4O1WV7PaAjbcjmbfJJSMz/t4Mal212Uz/fQZrOB8mow==", + "dev": true, + "dependencies": { + "@nolyfill/is-core-module": "1.0.39", + "debug": "^4.3.7", + "enhanced-resolve": "^5.15.0", + "fast-glob": "^3.3.2", + "get-tsconfig": "^4.7.5", + "is-bun-module": "^1.0.2", + "is-glob": "^4.0.3", + "stable-hash": "^0.0.4" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*", + "eslint-plugin-import-x": "*" + }, + "peerDependenciesMeta": { + "eslint-plugin-import": { + "optional": true + }, + "eslint-plugin-import-x": { + "optional": true + } + } + }, "node_modules/eslint-module-utils": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz", @@ -4389,6 +4462,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -4915,6 +5000,15 @@ "node": ">=4" } }, + "node_modules/is-bun-module": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.3.0.tgz", + "integrity": "sha512-DgXeu5UWI0IsMQundYb5UAOzm6G2eVnarJ0byP6Tm55iZNKceD59LNPA2L4VvsScTtHcw0yEkVwSf7PC+QoLSA==", + "dev": true, + "dependencies": { + "semver": "^7.6.3" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -6436,6 +6530,15 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/restructure": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/restructure/-/restructure-2.0.1.tgz", @@ -6901,6 +7004,12 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" }, + "node_modules/stable-hash": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", + "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", + "dev": true + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -7069,6 +7178,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/tga": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/tga/-/tga-1.0.7.tgz", diff --git a/package.json b/package.json index b500010..7cb9aa7 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ }, "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", + "@pretendonetwork/eslint-config": "^0.0.1", "@stylistic/eslint-plugin": "^2.13.0", "bmp-js": "^0.1.0", "ejs": "^3.1.10", @@ -63,4 +64,4 @@ "typescript": "^5.7.3", "typescript-eslint": "^8.20.0" } -} \ No newline at end of file +}