From 43189a384868e6edaee1cd2e878c384057fbcf29 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Tue, 3 Dec 2024 11:12:47 +0100 Subject: [PATCH] chore(betterer): make it work, again --- .betterer.cjs | 10 +++++----- ...rer.eslint.config.js => .betterer.eslint.config.cjs | 0 .betterer.results | 8 +++++++- eslint.config.js => eslint.config.cjs | 4 ++-- public/test/setupTests.ts | 2 +- scripts/webpack/{env-util.js => env-util.cjs} | 0 tsconfig.json | 9 ++++----- 7 files changed, 19 insertions(+), 14 deletions(-) rename .betterer.eslint.config.js => .betterer.eslint.config.cjs (100%) rename eslint.config.js => eslint.config.cjs (98%) rename scripts/webpack/{env-util.js => env-util.cjs} (100%) diff --git a/.betterer.cjs b/.betterer.cjs index ec7839de7c2..4f053c06c80 100644 --- a/.betterer.cjs +++ b/.betterer.cjs @@ -1,7 +1,7 @@ // @ts-check -import { BettererFileTest } from '@betterer/betterer'; -import { ESLint } from 'eslint'; -import { promises as fs } from 'fs'; +const { BettererFileTest } = require('@betterer/betterer'); +const fs = require('fs/promises'); +const { ESLint } = require('eslint'); // Why are we ignoring these? // They're all deprecated/being removed so doesn't make sense to fix types @@ -13,7 +13,7 @@ const eslintPathsToIgnore = [ ]; // Avoid using functions that report the position of the issues, as this causes a lot of merge conflicts -export default { +module.exports = { 'better eslint': () => countEslintErrors() .include('**/*.{ts,tsx}') @@ -82,7 +82,7 @@ function countEslintErrors() { } const runner = new ESLint({ - overrideConfigFile: './.betterer.eslint.config.js', + overrideConfigFile: './.betterer.eslint.config.cjs', warnIgnored: false, }); diff --git a/.betterer.eslint.config.js b/.betterer.eslint.config.cjs similarity index 100% rename from .betterer.eslint.config.js rename to .betterer.eslint.config.cjs diff --git a/.betterer.results b/.betterer.results index b160a20bc23..7fd478bc3d7 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1,5 +1,5 @@ // BETTERER RESULTS V2. -// +// // If this file contains merge conflicts, use `betterer merge` to automatically resolve them: // https://phenomnomnominal.github.io/betterer/docs/results-file/#merge // @@ -1151,6 +1151,9 @@ exports[`better eslint`] = { [0, 0, 0, "Do not re-export imported variable (\`profiler\`)", "6"], [0, 0, 0, "Do not re-export imported variable (\`updateLegendValues\`)", "7"] ], + "public/app/core/internationalization/constants.ts:5381": [ + [0, 0, 0, "Do not re-export imported variable (\`LocaleFileLoader\`)", "0"] + ], "public/app/core/navigation/GrafanaRouteError.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"] @@ -7869,6 +7872,9 @@ exports[`better eslint`] = { [0, 0, 0, "\'@grafana/ui/src/themes/_variables.dark.scss.tmpl\' import is restricted from being used by a pattern. Import from the public export instead.", "0"], [0, 0, 0, "\'@grafana/ui/src/themes/_variables.light.scss.tmpl\' import is restricted from being used by a pattern. Import from the public export instead.", "1"], [0, 0, 0, "\'@grafana/ui/src/themes/_variables.scss.tmpl\' import is restricted from being used by a pattern. Import from the public export instead.", "2"] + ], + "vite.config.ts:5381": [ + [0, 0, 0, "Do not use any type assertions.", "0"] ] }` }; diff --git a/eslint.config.js b/eslint.config.cjs similarity index 98% rename from eslint.config.js rename to eslint.config.cjs index 8cb43242eee..8977d99b25a 100644 --- a/eslint.config.js +++ b/eslint.config.cjs @@ -13,8 +13,8 @@ const unicornPlugin = require('eslint-plugin-unicorn'); const grafanaConfig = require('@grafana/eslint-config/flat'); const grafanaPlugin = require('@grafana/eslint-plugin'); -const bettererConfig = require('./.betterer.eslint.config'); -const getEnvConfig = require('./scripts/webpack/env-util'); +const bettererConfig = require('./.betterer.eslint.config.cjs'); +const getEnvConfig = require('./scripts/webpack/env-util.cjs'); /** * @type {Record} diff --git a/public/test/setupTests.ts b/public/test/setupTests.ts index 56896e26c2a..2e6fdd48857 100644 --- a/public/test/setupTests.ts +++ b/public/test/setupTests.ts @@ -7,7 +7,7 @@ import i18next from 'i18next'; import failOnConsole from 'jest-fail-on-console'; import { initReactI18next } from 'react-i18next'; -import getEnvConfig from '../../scripts/webpack/env-util'; +import getEnvConfig from '../../scripts/webpack/env-util.cjs'; import { matchers } from './matchers'; diff --git a/scripts/webpack/env-util.js b/scripts/webpack/env-util.cjs similarity index 100% rename from scripts/webpack/env-util.js rename to scripts/webpack/env-util.cjs diff --git a/tsconfig.json b/tsconfig.json index 39f2e6e3fb5..7cbb5beeaef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,9 +16,10 @@ /* Linting */ "strict": true, - // "noUnusedLocals": true, // Standard vite config but disabled because of typecheck errors - // "noUnusedParameters": true, // Standard vite config but disabled because typecheck errors - // "noFallthroughCasesInSwitch": true, // Standard vite config but disabled because of typecheck errors + // Standard vite config but disabled because of typecheck errors + // "noUnusedLocals": true, + // "noUnusedParameters": true, + // "noFallthroughCasesInSwitch": true, "baseUrl": "public/", "outDir": "public/dist", @@ -26,8 +27,6 @@ "allowJs": true, "useUnknownInCatchVariables": true, "incremental": true, - "isolatedModules": true, - "moduleResolution": "bundler", "tsBuildInfoFile": "./tsconfig.tsbuildinfo", "paths": { "@grafana/schema/dist/esm/*": ["../packages/grafana-schema/src/*"]