@open-turo/eslint-config-typescript 18.1.0-pr-440.292.1.1 → 18.1.0-pr-440.294.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  /** @import { ConfigWithExtends } from "typescript-eslint" */
4
4
  const eslint = require("@eslint/js");
5
5
  const tsParser = require("@typescript-eslint/parser");
6
+ const vitestPlugin = require("@vitest/eslint-plugin");
6
7
  const importPlugin = require("eslint-plugin-import");
7
8
  const jestPlugin = require("eslint-plugin-jest");
8
9
  const jsonPlugin = require("eslint-plugin-json");
@@ -11,7 +12,7 @@ const perfectionistPlugin = require("eslint-plugin-perfectionist");
11
12
  const prettierPluginRecommended = require("eslint-plugin-prettier/recommended");
12
13
  const sonarjsPlugin = require("eslint-plugin-sonarjs");
13
14
  const unicornPlugin = require("eslint-plugin-unicorn");
14
- const vitestPlugin = require("@vitest/eslint-plugin");
15
+ const eslintConfig = require("eslint/config");
15
16
  const tseslint = require("typescript-eslint");
16
17
 
17
18
  const FILES_JS = "**/*.?([cm])js";
@@ -40,7 +41,7 @@ const typescriptLanguageOptions = () => ({
40
41
  * @param {EcmaVersion} [ecmaVersion]
41
42
  */
42
43
  const javascriptConfig = (ecmaVersion = "latest") =>
43
- tseslint.config(eslint.configs.recommended, {
44
+ eslintConfig.defineConfig(eslint.configs.recommended, {
44
45
  files: [FILES_JS],
45
46
  languageOptions: {
46
47
  parserOptions: {
@@ -60,7 +61,7 @@ const getImportPluginFlatConfigs = () => {
60
61
  };
61
62
 
62
63
  const importConfig = () =>
63
- tseslint.config({
64
+ eslintConfig.defineConfig({
64
65
  extends: [getImportPluginFlatConfigs().recommended],
65
66
  rules: {
66
67
  "import/default": "off",
@@ -83,7 +84,7 @@ const importConfig = () =>
83
84
  });
84
85
 
85
86
  const nPluginConfig = (allowModules = ["@jest/globals", "nock"]) =>
86
- tseslint.config({
87
+ eslintConfig.defineConfig({
87
88
  extends: [
88
89
  nPlugin.configs["flat/recommended"],
89
90
  nPlugin.configs["flat/mixed-esm-and-cjs"],
@@ -101,7 +102,7 @@ const nPluginConfig = (allowModules = ["@jest/globals", "nock"]) =>
101
102
  });
102
103
 
103
104
  const sonarJsConfig = () =>
104
- tseslint.config({
105
+ eslintConfig.defineConfig({
105
106
  extends: [sonarjsPlugin.configs.recommended],
106
107
  rules: {
107
108
  // Noisy rule - we may have helpers/methods that we mark as @deprecated but aren't planning to remove in the near future. This rule also significantly adds to eslint running time, which slows down both local development and CI.
@@ -128,7 +129,7 @@ const sonarJsConfig = () =>
128
129
  });
129
130
 
130
131
  const typescriptConfig = () =>
131
- tseslint.config({
132
+ eslintConfig.defineConfig({
132
133
  extends: [
133
134
  tseslint.configs.recommendedTypeChecked,
134
135
  // @ts-expect-error -- We are inferring the types of this import from runtime, but the rule values are inferred as `string` instead of `RuleEntry` ("off" | "warn" | "error")
@@ -191,7 +192,7 @@ const jestTestConfig = (options) => {
191
192
  "jest/unbound-method": "error",
192
193
  })
193
194
  : {};
194
- return tseslint.config({
195
+ return eslintConfig.defineConfig({
195
196
  extends: [jestPlugin.configs["flat/recommended"]],
196
197
  files: FILES_TEST,
197
198
  languageOptions: {
@@ -202,22 +203,18 @@ const jestTestConfig = (options) => {
202
203
  rules: {
203
204
  ...jestPlugin.configs["flat/recommended"].rules,
204
205
  ...typescriptRules,
205
- "import/no-extraneous-dependencies": [
206
- "error",
207
- { devDependencies: FILES_TEST },
208
- ],
209
206
  "jest/no-jest-import": "off",
210
207
  },
211
208
  });
212
209
  };
213
210
 
214
211
  /**
215
- *
212
+ * Creates Vitest-specific test configuration
216
213
  * @param {object} options Configuration options
217
214
  * @param {boolean} options.typescript Whether to include typescript rules
218
215
  */
219
216
  const vitestTestConfig = (options) => {
220
- return tseslint.config({
217
+ return eslintConfig.defineConfig({
221
218
  extends: [vitestPlugin.configs.recommended],
222
219
  files: FILES_TEST,
223
220
  languageOptions: {
@@ -225,12 +222,6 @@ const vitestTestConfig = (options) => {
225
222
  ...(options.typescript ? typescriptLanguageOptions() : {}),
226
223
  },
227
224
  plugins: { vitest: vitestPlugin },
228
- rules: {
229
- "import/no-extraneous-dependencies": [
230
- "error",
231
- { devDependencies: FILES_TEST },
232
- ],
233
- },
234
225
  });
235
226
  };
236
227
 
@@ -241,17 +232,27 @@ const vitestTestConfig = (options) => {
241
232
  * @param {"jest" | "vitest"} options.testFramework Test framework to use
242
233
  */
243
234
  const testConfig = (options) => {
244
- if (options.testFramework === "vitest") {
245
- return vitestTestConfig(options);
246
- }
247
- return jestTestConfig(options);
235
+ const frameworkConfig =
236
+ options.testFramework === "vitest"
237
+ ? vitestTestConfig(options)
238
+ : jestTestConfig(options);
239
+
240
+ return eslintConfig.defineConfig(...frameworkConfig, {
241
+ files: FILES_TEST,
242
+ rules: {
243
+ "import/no-extraneous-dependencies": [
244
+ "error",
245
+ { devDependencies: FILES_TEST },
246
+ ],
247
+ },
248
+ });
248
249
  };
249
250
 
250
251
  /**
251
252
  * @param {string[]} ignores
252
253
  */
253
254
  const ignoresConfig = (ignores = []) =>
254
- tseslint.config({
255
+ eslintConfig.defineConfig({
255
256
  ignores: ["**/.yalc", "**/dist", ...ignores],
256
257
  });
257
258
 
@@ -279,7 +280,7 @@ module.exports = function config(options = {}) {
279
280
  testFramework === "vitest" ? ["nock"] : ["@jest/globals", "nock"];
280
281
  const allowModules = options.allowModules || defaultAllowModules;
281
282
 
282
- return tseslint.config(
283
+ return eslintConfig.defineConfig(
283
284
  javascriptConfig(options.ecmaVersion),
284
285
  importConfig(),
285
286
  nPluginConfig(allowModules),
package/package.json CHANGED
@@ -56,6 +56,6 @@
56
56
  "access": "public"
57
57
  },
58
58
  "repository": "https://github.com/open-turo/eslint-config-typescript",
59
- "version": "18.1.0-pr-440.292.1.1",
59
+ "version": "18.1.0-pr-440.294.1.1",
60
60
  "packageManager": "npm@11.6.1"
61
61
  }