Skip to content

Commit 7626a14

Browse files
committedAug 5, 2021
[Refactor] named: clean up formatting
1 parent 7163824 commit 7626a14

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed
 

‎src/rules/named.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,38 @@ module.exports = {
1414
create: function (context) {
1515
function checkSpecifiers(key, type, node) {
1616
// ignore local exports and type imports/exports
17-
if (node.source == null || node.importKind === 'type' ||
18-
node.importKind === 'typeof' || node.exportKind === 'type') {
17+
if (
18+
node.source == null
19+
|| node.importKind === 'type'
20+
|| node.importKind === 'typeof'
21+
|| node.exportKind === 'type'
22+
) {
1923
return;
2024
}
2125

22-
if (!node.specifiers
23-
.some(function (im) { return im.type === type; })) {
26+
if (!node.specifiers.some((im) => im.type === type)) {
2427
return; // no named imports/exports
2528
}
2629

2730
const imports = Exports.get(node.source.value, context);
28-
if (imports == null) return;
31+
if (imports == null) {
32+
return;
33+
}
2934

3035
if (imports.errors.length) {
3136
imports.reportErrors(context, node);
3237
return;
3338
}
3439

3540
node.specifiers.forEach(function (im) {
36-
if (im.type !== type) return;
41+
if (im.type !== type) {
42+
return;
43+
}
3744

3845
// ignore type imports
39-
if (im.importKind === 'type' || im.importKind === 'typeof') return;
46+
if (im.importKind === 'type' || im.importKind === 'typeof') {
47+
return;
48+
}
4049

4150
const deepLookup = imports.hasDeep(im[key].name);
4251

@@ -46,27 +55,18 @@ module.exports = {
4655
.map(i => path.relative(path.dirname(context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename()), i.path))
4756
.join(' -> ');
4857

49-
context.report(im[key],
50-
`${im[key].name} not found via ${deepPath}`);
58+
context.report(im[key], `${im[key].name} not found via ${deepPath}`);
5159
} else {
52-
context.report(im[key],
53-
im[key].name + ' not found in \'' + node.source.value + '\'');
60+
context.report(im[key], im[key].name + ' not found in \'' + node.source.value + '\'');
5461
}
5562
}
5663
});
5764
}
5865

5966
return {
60-
'ImportDeclaration': checkSpecifiers.bind( null
61-
, 'imported'
62-
, 'ImportSpecifier'
63-
),
67+
ImportDeclaration: checkSpecifiers.bind(null, 'imported', 'ImportSpecifier'),
6468

65-
'ExportNamedDeclaration': checkSpecifiers.bind( null
66-
, 'local'
67-
, 'ExportSpecifier'
68-
),
69+
ExportNamedDeclaration: checkSpecifiers.bind(null, 'local', 'ExportSpecifier'),
6970
};
70-
7171
},
7272
};

0 commit comments

Comments
 (0)
Please sign in to comment.