With the following node.js code:
import { fileURLToPath } from 'node:url';
import path from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
I am seeing the following lint error relating to the import.meta.url
reference:
This snippet is to replicate __filename
and __dirname
in ESM as per node.js guidance. The same error is given when using import.meta.url
as follows... which is also in the official guidance:
import { readFileSync } from 'fs';
const buffer = readFileSync(new URL('./data.proto', import.meta.url));
I have looked at this but it doesn't solve my problem. This is specifically within the Cloud9 IDE... not the current AWS Cloud9 but a self-hosted Cloud9 based on this repo (last updated 4 years ago). The only guidance from (AWS) Cloud9 is on this page:
I can get certain basic rules to work using this .eslintrc
file, e.g.
{
rules: {
semi: ["error", "never"]
}
}
So I know that the config file is taking effect in the IDE. But can't see the appropriate rule to disable the "unexpected token import" error.
EDIT: the following seem relevant but I cannot determine if it has ever really reached a conclusion:
https://github.com/eslint/eslint/issues/12518