From 239d4ecb770f6aed97449e1e84a8627a0c3a2d36 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Wed, 2 Feb 2022 18:56:54 +0100 Subject: [PATCH] feat: add ESM-specific rules (#441) --- .eslintrc.cjs | 1 + .eslintrc_esm.cjs | 15 +++++++++++++++ README.md | 1 + package.json | 2 ++ 4 files changed, 19 insertions(+) create mode 100644 .eslintrc_esm.cjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 207b88c1..d226a384 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -377,6 +377,7 @@ module.exports = { // Documentation might import dependencies not in package.json 'node/no-unpublished-require': 0, 'node/no-extraneous-require': 0, + 'node/no-extraneous-import': 0, 'import/no-extraneous-dependencies': 0, }, }, diff --git a/.eslintrc_esm.cjs b/.eslintrc_esm.cjs new file mode 100644 index 00000000..23ed580c --- /dev/null +++ b/.eslintrc_esm.cjs @@ -0,0 +1,15 @@ +const baseEslintrc = require('./.eslintrc') + +// ESLint configuration for packages using pure ES modules. +// This should be merged to the main `.eslintrc.js` once all our repositories +// have migrated to pure ES modules. +module.exports = { + ...baseEslintrc, + parserOptions: { + sourceType: 'module', + }, + rules: { + ...baseEslintrc.rules, + 'import/extensions': [2, 'ignorePackages'], + }, +} diff --git a/README.md b/README.md index 56f7d4c8..d8dd2472 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ If you're creating a new repository, you can use the specific project. ```js +// Use '@netlify/eslint-config-node/esm' if the repository is using pure ES modules const { overrides } = require('@netlify/eslint-config-node') module.exports = { diff --git a/package.json b/package.json index 680eb4fe..2ddc881f 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,13 @@ "type": "commonjs", "exports": { ".": "./.eslintrc.cjs", + "./esm": "./.eslintrc_esm.cjs", "./.prettierrc.json": "./.prettierrc.json" }, "main": "./.eslintrc.cjs", "files": [ ".eslintrc.cjs", + ".eslintrc_esm.cjs", ".prettierrc.json", ".editorconfig", ".gitattributes",