Skip to content

Commit f0c1756

Browse files
committedAug 14, 2021
[meta] fix some formatting
1 parent fa3192a commit f0c1756

18 files changed

+55
-64
lines changed
 

‎CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
2020
### Fixed
2121
- [`no-duplicates`]: ensure autofix avoids excessive newlines ([#2028], thanks [@ertrzyiks])
2222
- [`extensions`]: avoid crashing on partially typed import/export statements ([#2118], thanks [@ljharb])
23-
- [`no-extraneous-dependencies`]: add ESM intermediate package.json support] ([#2121], thanks [@paztis])
23+
- [`no-extraneous-dependencies`]: add ESM intermediate package.json support ([#2121], thanks [@paztis])
2424
- Use `context.getPhysicalFilename()` when available (ESLint 7.28+) ([#2160], thanks [@pmcelhaney])
2525
- [`extensions`]/`importType`: fix isScoped treating @/abc as scoped module ([#2146], thanks [@rperello])
2626

‎docs/rules/no-unresolved.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ as defined by standard Node `require.resolve` behavior.
66
See [settings](../../README.md#settings) for customization options for the resolution (i.e.
77
additional filetypes, `NODE_PATH`, etc.)
88

9-
This rule can also optionally report on unresolved modules in CommonJS `require('./foo')` calls and AMD `require(['./foo'], function (foo){...})` and `define(['./foo'], function (foo){...})`.
9+
This rule can also optionally report on unresolved modules in CommonJS `require('./foo')` calls and AMD `require(['./foo'], function (foo) {...})` and `define(['./foo'], function (foo) {...})`.
1010

1111
To enable this, send `{ commonjs: true/false, amd: true/false }` as a rule option.
1212
Both are disabled by default.

‎resolvers/webpack/index.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ exports.resolve = function (source, file, settings) {
118118

119119
if (typeof configIndex !== 'undefined' && webpackConfig.length > configIndex) {
120120
webpackConfig = webpackConfig[configIndex];
121-
}
122-
else {
121+
} else {
123122
webpackConfig = find(webpackConfig, function findFirstWithResolve(config) {
124123
return !!config.resolve;
125124
});
@@ -311,16 +310,16 @@ function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) {
311310
/* eslint-disable */
312311
// from https://github.com/webpack/webpack/blob/v1.13.0/lib/WebpackOptionsApply.js#L365
313312
function makeRootPlugin(ModulesInRootPlugin, name, root) {
314-
if(typeof root === "string")
313+
if (typeof root === 'string') {
315314
return new ModulesInRootPlugin(name, root);
316-
else if(Array.isArray(root)) {
315+
} else if (Array.isArray(root)) {
317316
return function() {
318-
root.forEach(function(root) {
317+
root.forEach(function (root) {
319318
this.apply(new ModulesInRootPlugin(name, root));
320319
}, this);
321320
};
322321
}
323-
return function() {};
322+
return function () {};
324323
}
325324
/* eslint-enable */
326325

@@ -436,17 +435,17 @@ function findConfigPath(configPath, packageDir) {
436435
}
437436

438437
function registerCompiler(moduleDescriptor) {
439-
if(moduleDescriptor) {
440-
if(typeof moduleDescriptor === 'string') {
438+
if (moduleDescriptor) {
439+
if (typeof moduleDescriptor === 'string') {
441440
require(moduleDescriptor);
442-
} else if(!Array.isArray(moduleDescriptor)) {
441+
} else if (!Array.isArray(moduleDescriptor)) {
443442
moduleDescriptor.register(require(moduleDescriptor.module));
444443
} else {
445-
for(let i = 0; i < moduleDescriptor.length; i++) {
444+
for (let i = 0; i < moduleDescriptor.length; i++) {
446445
try {
447446
registerCompiler(moduleDescriptor[i]);
448447
break;
449-
} catch(e) {
448+
} catch (e) {
450449
log('Failed to register compiler for moduleDescriptor[]:', i, moduleDescriptor);
451450
}
452451
}

‎src/rules/dynamic-import-chunkname.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = {
6969

7070
try {
7171
// just like webpack itself does
72-
vm.runInNewContext(`(function(){return {${comment.value}}})()`);
72+
vm.runInNewContext(`(function() {return {${comment.value}}})()`);
7373
}
7474
catch (error) {
7575
context.report({

‎src/rules/first.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
const errorInfos = [];
4343
let shouldSort = true;
4444
let lastSortNodesIndex = 0;
45-
body.forEach(function (node, index){
45+
body.forEach(function (node, index) {
4646
if (!anyExpressions && isPossibleDirective(node)) {
4747
return;
4848
}

‎src/rules/no-unresolved.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,36 @@ module.exports = {
1515
url: docsUrl('no-unresolved'),
1616
},
1717

18-
schema: [ makeOptionsSchema({
19-
caseSensitive: { type: 'boolean', default: true },
20-
})],
18+
schema: [
19+
makeOptionsSchema({
20+
caseSensitive: { type: 'boolean', default: true },
21+
}),
22+
],
2123
},
2224

2325
create: function (context) {
24-
2526
function checkSourceValue(source) {
26-
const shouldCheckCase = !CASE_SENSITIVE_FS &&
27-
(!context.options[0] || context.options[0].caseSensitive !== false);
27+
const shouldCheckCase = !CASE_SENSITIVE_FS
28+
&& (!context.options[0] || context.options[0].caseSensitive !== false);
2829

2930
const resolvedPath = resolve(source.value, context);
3031

3132
if (resolvedPath === undefined) {
32-
context.report(source,
33-
`Unable to resolve path to module '${source.value}'.`);
34-
}
35-
36-
else if (shouldCheckCase) {
33+
context.report(
34+
source,
35+
`Unable to resolve path to module '${source.value}'.`
36+
);
37+
} else if (shouldCheckCase) {
3738
const cacheSettings = ModuleCache.getSettings(context.settings);
3839
if (!fileExistsWithCaseSync(resolvedPath, cacheSettings)) {
39-
context.report(source,
40-
`Casing of ${source.value} does not match the underlying filesystem.`);
40+
context.report(
41+
source,
42+
`Casing of ${source.value} does not match the underlying filesystem.`
43+
);
4144
}
42-
4345
}
4446
}
4547

4648
return moduleVisitor(checkSourceValue, context.options[0]);
47-
4849
},
4950
};

‎src/rules/no-unused-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ module.exports = {
540540

541541
const value = exportsKey === IMPORT_DEFAULT_SPECIFIER ? DEFAULT : exportsKey;
542542

543-
if (typeof exportStatement !== 'undefined'){
543+
if (typeof exportStatement !== 'undefined') {
544544
if (exportStatement.whereUsed.size < 1) {
545545
context.report(
546546
node,

‎src/rules/order.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ function takeTokensAfterWhile(sourceCode, node, condition) {
4747
for (let i = 0; i < tokens.length; i++) {
4848
if (condition(tokens[i])) {
4949
result.push(tokens[i]);
50-
}
51-
else {
50+
} else {
5251
break;
5352
}
5453
}
@@ -61,8 +60,7 @@ function takeTokensBeforeWhile(sourceCode, node, condition) {
6160
for (let i = tokens.length - 1; i >= 0; i--) {
6261
if (condition(tokens[i])) {
6362
result.push(tokens[i]);
64-
}
65-
else {
63+
} else {
6664
break;
6765
}
6866
}

‎src/rules/prefer-default-export.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ module.exports = {
6969
node.declaration.declarations.forEach(function(declaration) {
7070
captureDeclaration(declaration.id);
7171
});
72-
}
73-
else {
72+
} else {
7473
// captures 'export function foo() {}' syntax
7574
specifierExportCount++;
7675
}

‎tests/files/foo-bar-resolver-no-version.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ exports.resolveImport = function (modulePath, sourceFile, config) {
55
if (sourceFileName === 'foo.js') {
66
return path.join(__dirname, 'bar.jsx')
77
}
8-
else if (sourceFileName === 'exception.js') {
8+
if (sourceFileName === 'exception.js') {
99
throw new Error('foo-bar-resolver-v1 resolveImport test exception')
1010
}
11-
else {
12-
return undefined
13-
}
11+
return undefined;
1412
}

‎tests/files/foo-bar-resolver-v1.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ var path = require('path')
33
exports.resolveImport = function (modulePath, sourceFile, config) {
44
var sourceFileName = path.basename(sourceFile)
55
if (sourceFileName === 'foo.js') {
6-
return path.join(__dirname, 'bar.jsx')
6+
return path.join(__dirname, 'bar.jsx');
77
}
8-
else if (sourceFileName === 'exception.js') {
9-
throw new Error('foo-bar-resolver-v1 resolveImport test exception')
8+
if (sourceFileName === 'exception.js') {
9+
throw new Error('foo-bar-resolver-v1 resolveImport test exception');
1010
}
11-
else {
12-
return undefined
13-
}
14-
}
11+
return undefined;
12+
};
1513

16-
exports.interfaceVersion = 1
14+
exports.interfaceVersion = 1;

‎tests/files/foo-bar-resolver-v2.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ exports.resolve = function (modulePath, sourceFile, config) {
55
if (sourceFileName === 'foo.js') {
66
return { found: true, path: path.join(__dirname, 'bar.jsx') }
77
}
8-
else if (sourceFileName === 'exception.js') {
8+
if (sourceFileName === 'exception.js') {
99
throw new Error('foo-bar-resolver-v2 resolve test exception')
1010
}
11-
else {
12-
return { found: false }
13-
}
14-
}
11+
return { found: false };
12+
};
1513

16-
exports.interfaceVersion = 2
14+
exports.interfaceVersion = 2;

‎tests/files/typescript.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export function getFoo() : MyType {
2323
}
2424

2525
export module MyModule {
26-
export function ModuleFunction(){}
26+
export function ModuleFunction() {}
2727
}
2828

2929
export namespace MyNamespace {
30-
export function NamespaceFunction(){}
30+
export function NamespaceFunction() {}
3131

3232
export module NSModule {
33-
export function NSModuleFunction(){}
33+
export function NSModuleFunction() {}
3434
}
3535
}
3636

‎tests/src/rules/newline-after-import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
2626
code: `const x = () => require('baz') && require('bar')`,
2727
parserOptions: { ecmaVersion: 6 } ,
2828
},
29-
`function x(){ require('baz'); }`,
29+
`function x() { require('baz'); }`,
3030
`a(require('b'), require('c'), require('d'));`,
3131
`function foo() {
3232
switch (renderData.modalViewKey) {

‎tests/src/rules/no-cycle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ruleTester.run('no-cycle', rule, {
6161
options: [{ maxDepth: 1 }],
6262
}),
6363
test({
64-
code: `import("./${testDialect}/depth-two").then(function({ foo }){})`,
64+
code: `import("./${testDialect}/depth-two").then(function({ foo }) {})`,
6565
options: [{ maxDepth: 1 }],
6666
parser: require.resolve('babel-eslint'),
6767
}),

‎tests/src/rules/no-unresolved.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function runResolverTests(resolver) {
122122
type: 'Literal',
123123
}] }),
124124
rest({
125-
code: "import('in-alternate-root').then(function({DEEP}){});",
125+
code: "import('in-alternate-root').then(function({DEEP}) {});",
126126
errors: [{
127127
message: 'Unable to resolve path to module \'in-alternate-root\'.',
128128
type: 'Literal',
@@ -138,7 +138,7 @@ function runResolverTests(resolver) {
138138

139139
// check with eslint parser
140140
testVersion('>= 7', () => rest({
141-
code: "import('in-alternate-root').then(function({DEEP}){});",
141+
code: "import('in-alternate-root').then(function({DEEP}) {});",
142142
errors: [{
143143
message: 'Unable to resolve path to module \'in-alternate-root\'.',
144144
type: 'Literal',

‎tests/src/rules/no-useless-path-segments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function runResolverTests(resolver) {
3232
parser: require.resolve('babel-eslint') }),
3333
test({ code: 'import("..")',
3434
parser: require.resolve('babel-eslint') }),
35-
test({ code: 'import("fs").then(function(fs){})',
35+
test({ code: 'import("fs").then(function(fs) {})',
3636
parser: require.resolve('babel-eslint') }),
3737
],
3838

‎utils/moduleVisitor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function makeOptionsSchema(additionalProperties) {
131131
'additionalProperties': false,
132132
};
133133

134-
if (additionalProperties){
134+
if (additionalProperties) {
135135
for (const key in additionalProperties) {
136136
base.properties[key] = additionalProperties[key];
137137
}

0 commit comments

Comments
 (0)
Please sign in to comment.