Remove lint.legacyEslintInterop and compiler.legacyBabelInterop project config options
MODIFY
packages/@romejs/core/master/project/ProjectManager.ts
packages/@romejs/core/master/project/ProjectManager.ts
@@ -442,17 +442,6 @@ export default class ProjectManager {
}
}
- warnProjectInteropOption(
- projectFolder: AbsoluteFilePath,
- optionPath: string,
- externalName: string,
- ourComponentName: string,
- ) {
- this.master.connectedReporters.warn(
- `Project <filelink emphasis target="${projectFolder.join()}" /> uses the <emphasis>${optionPath}</emphasis> option. This adds ${externalName} integration to the Rome ${ourComponentName}. This is intended to be migratory, and not a long-term solution. Please port your configuration.`,
- );
- }
-
findProjectConfigConsumer(
def: ProjectDefinition,
test: (consumer: Consumer) => undefined | Consumer,
@@ -494,25 +483,6 @@ export default class ProjectManager {
meta: ProjectConfigMeta;
config: ProjectConfig;
}): Promise<ProjectDefinition> {
- // Warn on interop options - no this log will not be removed, nor will there be an option to disable it
- // They are gross hacks that should not be used long-term
- if (config.compiler.legacyBabelInterop) {
- this.warnProjectInteropOption(
- projectFolder,
- 'compiler.legacyBabelInterop',
- 'Babel',
- 'compiler',
- );
- }
- if (config.lint.legacyEslintInterop) {
- this.warnProjectInteropOption(
- projectFolder,
- 'lint.legacyEslintInterop',
- 'ESLint',
- 'linter',
- );
- }
-
// Make sure there's no project with the same `name` as us
for (const project of this.projects.values()) {
if (project.config.name === config.name) {

MODIFY
packages/@romejs/js-compiler/api/compile.ts
packages/@romejs/js-compiler/api/compile.ts
*/
import {Mappings} from '@romejs/codec-source-map';
-import {PartialDiagnostics, PartialDiagnostic} from '@romejs/diagnostics';
+import {PartialDiagnostics} from '@romejs/diagnostics';
import {CompileRequest} from '../types';
import {Cache} from '@romejs/js-compiler';
import generate from '@romejs/js-generator';
import transform from '../methods/transform';
import lint from './lint';
-import {requireGlobal} from '@romejs/node';
-import {Position} from '@romejs/parser-core';
-import {coerce1, coerce0} from '@romejs/ob1';
-import {isPlainObject} from '@romejs/typescript-helpers';
export type CompileResult = {
code: string;
@@ -27,109 +23,6 @@ export type CompileResult = {
const compileCache: Cache<CompileResult> = new Cache();
-// Validate passed error is BabelSyntaxError
-function extractPositionFromBabelSyntaxError(
- err: unknown,
-): undefined | Position {
- if (!isPlainObject(err)) {
- return;
- }
-
- const {pos} = err;
- if (typeof pos !== 'number') {
- return;
- }
-
- const {loc} = err;
- if (!isPlainObject(loc)) {
- return;
- }
-
- const {line, column} = loc;
- if (typeof line !== 'number') {
- return;
- }
- if (typeof column !== 'number') {
- return;
- }
-
- return {
- line: coerce1(line),
- column: coerce0(column),
- index: coerce0(pos),
- };
-}
-
-function babelInterop(req: CompileRequest, res: CompileResult): CompileResult {
- const {filename} = req.ast;
-
- try {
- const babelResult = requireGlobal(
- 'babel-core',
- req.project.folder,
- ).transform(res.code, {
- filename,
- });
-
- const generatorResult = requireGlobal(
- 'babel-generator',
- req.project.folder,
- ).default(
- babelResult.ast,
- {
- sourceMaps: true,
- },
- res.code,
- );
-
- return {
- ...res,
- code: generatorResult.code,
- mappings: generatorResult.rawMappings,
- };
- } catch (err) {
- const pos = extractPositionFromBabelSyntaxError(err);
- if (pos === undefined) {
- throw err;
- }
-
- // Clean message
- const message = err.message
- // Remove filename
- .replace(/^(.*?):/, '')
- // Remove location
- .replace(/ \(\d+:\d+\)/, '')
- // Use only the first line, the rest are redundant codeframes
- .split('\n')[0]
- .trim();
-
- const babelDiagnostic: PartialDiagnostic = {
- filename,
- category: 'babel',
- message,
- // Embed compiled Rome code as the Babel error will point to it and not the source on disk
- sourceText: res.code,
- start: pos,
- end: pos,
- advice: [
- {
- type: 'log',
- category: 'warn',
- message:
- 'You are using Babel interop mode. This error is from Babel running over Rome emitted code',
- },
- ],
- };
-
- return {
- ...res,
- // TODO add any .babelrc dependencies
- cacheDependencies: [...res.cacheDependencies],
- diagnostics: [...res.diagnostics, babelDiagnostic],
- };
- }
-}
-
export default async function compile(
req: CompileRequest,
): Promise<CompileResult> {
@@ -175,10 +68,5 @@ export default async function compile(
};
compileCache.set(query, res);
- // BABEL HACK loool
- if (req.project.config.compiler.legacyBabelInterop) {
- res = babelInterop(req, res);
- }
-
return res;
}

MODIFY
packages/@romejs/project/load.ts
packages/@romejs/project/load.ts
@@ -289,12 +289,6 @@ export function normalizeProjectConfig(
if (lint.has('globals')) {
config.lint.globals = arrayOfStrings(lint.get('globals'));
}
-
- if (lint.has('legacyEslintInterop')) {
- config.lint.legacyEslintInterop = lint
- .get('legacyBabelInterop')
- .asBoolean();
- }
}
const format = consumer.get('format');
@@ -355,11 +349,6 @@ export function normalizeProjectConfig(
const compiler = consumer.get('compiler');
if (compiler.exists()) {
- if (compiler.has('legacyBabelInterop')) {
- config.compiler.legacyBabelInterop = compiler
- .get('legacyBabelInterop')
- .asBoolean();
- }
}
const targets = consumer.get('targets');

MODIFY
packages/@romejs/project/types.ts
packages/@romejs/project/types.ts
@@ -39,9 +39,7 @@ export type ProjectConfigObjects = {
resolver: {};
- compiler: {
- legacyBabelInterop: boolean;
- };
+ compiler: {};
bundler: {
mode: BundlerMode;
@@ -54,7 +52,6 @@ export type ProjectConfigObjects = {
lint: {
enabled: boolean;
- legacyEslintInterop: boolean;
globals: Array<string>;
ignore: PathPatterns;
};
@@ -196,9 +193,7 @@ export const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
mode: 'modern',
},
- compiler: {
- legacyBabelInterop: false,
- },
+ compiler: {},
resolver: {},
@@ -223,7 +218,6 @@ export const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
lint: {
enabled: false,
- legacyEslintInterop: false,
ignore: [],
globals: [],
},

Remove lint.legacyEslintInterop and compiler.legacyBabelInterop project config options