From ab34fd8427b41356d4955a3d662e881a05174b6a Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 20 Jun 2024 10:17:52 +0900 Subject: [PATCH] chore: add proper globals for node scripts --- eslint.config.js | 74 +++++++++++++++----------------- postcss.config.cjs | 2 - scripts/sync-manifest-version.ts | 1 - webpack.config.js | 1 - 4 files changed, 34 insertions(+), 44 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 3dfb898e24..54e16c2aaa 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -15,12 +15,8 @@ export default [ ...tseslint.configs.recommended, ...tailwind.configs['flat/recommended'], { - plugins: { vitest }, - languageOptions: { - globals: { - ...globals.browser, - }, + globals: { ...globals.browser }, parser: tsParser, ecmaVersion: 2022, @@ -35,39 +31,16 @@ export default [ rules: { curly: 'error', 'linebreak-style': ['error', 'unix'], - - 'no-constant-condition': [ - 'error', - { - checkLoops: false, - }, - ], - + 'no-constant-condition': ['error', { checkLoops: false }], 'no-prototype-builtins': 'off', - - 'prefer-const': [ - 'error', - { - destructuring: 'all', - }, - ], - - quotes: [ - 'error', - 'single', - { - avoidEscape: true, - }, - ], - + 'prefer-const': ['error', { destructuring: 'all' }], + quotes: ['error', 'single', { avoidEscape: true }], semi: ['error', 'always'], - 'sort-imports': [ 'error', { ignoreCase: true, ignoreDeclarationSort: true, - ignoreMemberSort: false, allowSeparatedGroups: true, }, ], @@ -75,9 +48,6 @@ export default [ 'tailwindcss/classnames-order': 'off', 'tailwindcss/no-custom-classname': 'off', - ...vitest.configs.recommended.rules, - 'vitest/no-identical-title': ['error'], - '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-floating-promises': [ @@ -100,20 +70,44 @@ export default [ }, }, { - files: ['**/*.js', '**/*.mjs', 'tests/**/*', 'scripts/**/*'], - + files: ['src/**/*.test.ts'], + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/no-identical-title': ['error'], + }, + }, + { + files: [ + '*.{cjs,js,ts}', + 'scripts/**/*.{cjs,js,ts}', + 'tests/**/*.{cjs,js,ts}', + ], languageOptions: { - ecmaVersion: 2022, - sourceType: 'module', - parserOptions: { project: null, }, }, - rules: { '@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/no-misused-promises': 'off', }, }, + { + files: ['*.cjs', 'scripts/**/*.cjs'], + languageOptions: { + globals: { + ...globals.node, + }, + sourceType: 'commonjs', + }, + }, + { + files: ['*.{js,ts}', 'scripts/**/*.{js,ts}'], + languageOptions: { + globals: { + ...globals.nodeBuiltin, + }, + }, + }, ]; diff --git a/postcss.config.cjs b/postcss.config.cjs index e85d5fae3b..b870c7fff8 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,5 +1,3 @@ -/* eslint-env node */ - module.exports = { plugins: { tailwindcss: {}, diff --git a/scripts/sync-manifest-version.ts b/scripts/sync-manifest-version.ts index 591526ff82..cac0d3c0ee 100644 --- a/scripts/sync-manifest-version.ts +++ b/scripts/sync-manifest-version.ts @@ -1,4 +1,3 @@ -/* eslint-env node */ import * as fs from 'node:fs'; import * as url from 'node:url'; import { parseSemVer } from 'semver-parser'; diff --git a/webpack.config.js b/webpack.config.js index c935d8e245..5435395840 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,3 @@ -/* eslint-env node */ /* eslint @typescript-eslint/no-var-requires: 0 */ import CopyWebpackPlugin from 'copy-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin';