Skip to content

Commit

Permalink
Remove ecmaVersion and sourceType from flat configs (#2239)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Dec 21, 2023
1 parent 65711f9 commit 85bce3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
10 changes: 0 additions & 10 deletions configs/flat-config-base.js
Original file line number Diff line number Diff line change
@@ -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,
},
};
4 changes: 0 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import * as eslintrc from '@eslint/eslintrc';
export default [
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: eslintrc.Legacy.environments.get('es2024'),
},
plugins: {
Expand All @@ -58,8 +56,6 @@ const eslintrc = require('@eslint/eslintrc');
module.exports = [
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: eslintrc.Legacy.environments.get('es2024'),
},
plugins: {
Expand Down
7 changes: 6 additions & 1 deletion test/package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 85bce3f

Please sign in to comment.