From 85bce3f9190196841c4d167fa1a2af22bde689a5 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 21 Dec 2023 11:26:58 +0800 Subject: [PATCH] Remove `ecmaVersion` and `sourceType` from flat configs (#2239) --- configs/flat-config-base.js | 10 ---------- readme.md | 4 ---- test/package.mjs | 7 ++++++- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/configs/flat-config-base.js b/configs/flat-config-base.js index 4325e66d1e..bdf7adaa7c 100644 --- a/configs/flat-config-base.js +++ b/configs/flat-config-base.js @@ -1,20 +1,10 @@ 'use strict'; const eslintrc = require('@eslint/eslintrc'); -const legacyConfigBase = require('./legacy-config-base.js'); - -const { - parserOptions: { - ecmaVersion, - sourceType, - }, -} = legacyConfigBase; const {globals} = eslintrc.Legacy.environments.get('es2024'); module.exports = { languageOptions: { - ecmaVersion, - sourceType, globals, }, }; diff --git a/readme.md b/readme.md index 080dfa6d6d..7c61334e78 100644 --- a/readme.md +++ b/readme.md @@ -32,8 +32,6 @@ import * as eslintrc from '@eslint/eslintrc'; export default [ { languageOptions: { - ecmaVersion: 'latest', - sourceType: 'module', globals: eslintrc.Legacy.environments.get('es2024'), }, plugins: { @@ -58,8 +56,6 @@ const eslintrc = require('@eslint/eslintrc'); module.exports = [ { languageOptions: { - ecmaVersion: 'latest', - sourceType: 'module', globals: eslintrc.Legacy.environments.get('es2024'), }, plugins: { diff --git a/test/package.mjs b/test/package.mjs index f4989a5957..094b7929cd 100644 --- a/test/package.mjs +++ b/test/package.mjs @@ -228,7 +228,12 @@ function getCompactConfig(config) { for (const part of compat.config(config)) { for (const [key, value] of Object.entries(part)) { if (key === 'languageOptions') { - result[key] = {...result[key], ...value}; + const languageOptions = {...result[key], ...value}; + // ESLint uses same `ecmaVersion` and `sourceType` as we recommended in the new configuration system + // https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects + delete languageOptions.ecmaVersion; + delete languageOptions.sourceType; + result[key] = languageOptions; } else if (key === 'plugins') { result[key] = undefined; } else {