Skip to content

Commit

Permalink
feat: add ESM-specific rules (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Feb 2, 2022
1 parent 9f9ffdc commit 239d4ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
15 changes: 15 additions & 0 deletions .eslintrc_esm.cjs
Original file line number Diff line number Diff line change
@@ -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'],
},
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 239d4ec

Please sign in to comment.