Skip to content

Commit

Permalink
tools: add support for import assertions in linter
Browse files Browse the repository at this point in the history
PR-URL: #39924
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>

Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Geoffrey Booth <[email protected]>
  • Loading branch information
aduh95 authored and nodejs-github-bot committed Oct 17, 2021
1 parent cbc7b5d commit f5e9486
Show file tree
Hide file tree
Showing 27 changed files with 353 additions and 2,429 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const hacks = [
'eslint-plugin-node-core',
'eslint-plugin-markdown',
'@babel/eslint-parser',
'@babel/plugin-syntax-import-assertions',
];
Module._findPath = (request, paths, isMain) => {
const r = ModuleFindPath(request, paths, isMain);
Expand All @@ -36,6 +37,11 @@ module.exports = {
plugins: ['markdown', 'node-core'],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
plugins: [
Module._findPath('@babel/plugin-syntax-import-assertions'),
],
},
requireConfigFile: false,
sourceType: 'script',
},
Expand Down
7 changes: 7 additions & 0 deletions test/es-module/test-esm-import-assertion-1.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Flags: --experimental-json-modules --harmony-import-assertions
import '../common/index.mjs';
import { strictEqual } from 'assert';

import secret from '../fixtures/experimental.json' assert { type: 'json' };

strictEqual(secret.ofLife, 42);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f5e9486

Please sign in to comment.