Skip to content

Commit 4f50816

Browse files
committed
Lint fixes
1 parent 8d6c5c5 commit 4f50816

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const runEslint = (paths, options) => {
3838
return processReport(report, options);
3939
};
4040

41-
module.exports.lintText = (str, options) => {
41+
module.exports.lintText = (string, options) => {
4242
options = optionsManager.preprocess(options);
4343

4444
if (options.overrides && options.overrides.length > 0) {
@@ -79,7 +79,7 @@ module.exports.lintText = (str, options) => {
7979
}
8080

8181
const engine = new eslint.CLIEngine(options);
82-
const report = engine.executeOnText(str, options.filename);
82+
const report = engine.executeOnText(string, options.filename);
8383

8484
return processReport(report, options);
8585
};
@@ -104,8 +104,8 @@ module.exports.lintFiles = (patterns, options) => {
104104
// For silly users that don't specify an extension in the glob pattern
105105
if (!isEmptyPatterns) {
106106
paths = paths.filter(filePath => {
107-
const ext = path.extname(filePath).replace('.', '');
108-
return options.extensions.includes(ext);
107+
const extension = path.extname(filePath).replace('.', '');
108+
return options.extensions.includes(extension);
109109
});
110110
}
111111

lib/options-manager.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@ const normalizeOptions = options => {
152152
return options;
153153
};
154154

155-
const mergeWithPkgConf = options => {
155+
const mergeWithPackageConfig = options => {
156156
options = Object.assign({cwd: process.cwd()}, options);
157157
options.cwd = path.resolve(options.cwd);
158-
const conf = pkgConf.sync('xo', {cwd: options.cwd, skipOnFalse: true});
158+
const config = pkgConf.sync('xo', {cwd: options.cwd, skipOnFalse: true});
159159
const engines = pkgConf.sync('engines', {cwd: options.cwd});
160-
return Object.assign({}, conf, {nodeVersion: engines && engines.node && semver.validRange(engines.node)}, options);
160+
return Object.assign({}, config, {nodeVersion: engines && engines.node && semver.validRange(engines.node)}, options);
161161
};
162162

163163
const normalizeSpaces = options => typeof options.space === 'number' ? options.space : 2;
164164

165-
const mergeWithPrettierConf = (options, prettierOptions) => {
165+
const mergeWithPrettierConfig = (options, prettierOptions) => {
166166
if ((options.semicolon === true && prettierOptions.semi === false) ||
167167
(options.semicolon === false && prettierOptions.semi === true)) {
168168
throw new Error(`The Prettier config \`semi\` is ${prettierOptions.semi} while XO \`semicolon\` is ${options.semicolon}`);
@@ -279,13 +279,13 @@ const buildConfig = options => {
279279
name = `eslint-config-${name}`;
280280
}
281281

282-
const ret = resolveFrom(options.cwd, name);
282+
const returnValue = resolveFrom(options.cwd, name);
283283

284-
if (!ret) {
284+
if (!returnValue) {
285285
throw new Error(`Couldn't find ESLint config: ${name}`);
286286
}
287287

288-
return ret;
288+
return returnValue;
289289
});
290290

291291
config.baseConfig.extends = config.baseConfig.extends.concat(configs);
@@ -301,7 +301,7 @@ const buildConfig = options => {
301301
config.baseConfig.extends = config.baseConfig.extends.concat('prettier');
302302
// The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
303303
config.rules['prettier/prettier'] = [
304-
'error', mergeWithPrettierConf(options, prettier.resolveConfig.sync(options.cwd || process.cwd()) || {})
304+
'error', mergeWithPrettierConfig(options, prettier.resolveConfig.sync(options.cwd || process.cwd()) || {})
305305
];
306306
// If the user has the React, Flowtype, or Standard plugin, add the corresponding Prettier rule overrides
307307
// See https://github.com/prettier/eslint-config-prettier for the list of plugins overrrides
@@ -374,7 +374,7 @@ const getIgnores = options => {
374374
};
375375

376376
const preprocess = options => {
377-
options = mergeWithPkgConf(options);
377+
options = mergeWithPackageConfig(options);
378378
options = normalizeOptions(options);
379379
options = getIgnores(options);
380380
options.extensions = DEFAULT_EXTENSION.concat(options.extensions || []);
@@ -383,8 +383,8 @@ const preprocess = options => {
383383

384384
module.exports.DEFAULT_IGNORE = DEFAULT_IGNORE;
385385
module.exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
386-
module.exports.mergeWithPkgConf = mergeWithPkgConf;
387-
module.exports.mergeWithPrettierConf = mergeWithPrettierConf;
386+
module.exports.mergeWithPkgConf = mergeWithPackageConfig;
387+
module.exports.mergeWithPrettierConf = mergeWithPrettierConfig;
388388
module.exports.normalizeOptions = normalizeOptions;
389389
module.exports.buildConfig = buildConfig;
390390
module.exports.findApplicableOverrides = findApplicableOverrides;

test/cli-main.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import tempWrite from 'temp-write';
77

88
process.chdir(__dirname);
99

10-
const main = (args, options) => execa(path.join(__dirname, '../cli-main.js'), args, options);
10+
const main = (arguments_, options) => execa(path.join(__dirname, '../cli-main.js'), arguments_, options);
1111

1212
test('fix option', async t => {
1313
const filepath = await tempWrite('console.log()\n', 'x.js');
@@ -71,8 +71,8 @@ test.failing('ignores fixture', async t => {
7171

7272
test('ignore files in .gitignore', async t => {
7373
const cwd = path.join(__dirname, 'fixtures/gitignore');
74-
const err = await t.throwsAsync(main(['--reporter=json'], {cwd}));
75-
const reports = JSON.parse(err.stdout);
74+
const error = await t.throwsAsync(main(['--reporter=json'], {cwd}));
75+
const reports = JSON.parse(error.stdout);
7676
const files = reports
7777
.map(report => path.relative(cwd, report.filePath))
7878
.map(report => slash(report));
@@ -86,8 +86,8 @@ test('ignore explicit files when in .gitgnore', async t => {
8686

8787
test('negative gitignores', async t => {
8888
const cwd = path.join(__dirname, 'fixtures/negative-gitignore');
89-
const err = await t.throwsAsync(main(['--reporter=json'], {cwd}));
90-
const reports = JSON.parse(err.stdout);
89+
const error = await t.throwsAsync(main(['--reporter=json'], {cwd}));
90+
const reports = JSON.parse(error.stdout);
9191
const files = reports.map(report => path.relative(cwd, report.filePath));
9292
t.deepEqual(files, ['foo.js']);
9393
});
@@ -99,8 +99,8 @@ test('supports being extended with a shareable config', async t => {
9999

100100
test('quiet option', async t => {
101101
const filepath = await tempWrite('// TODO: quiet\nconsole.log()\n', 'x.js');
102-
const err = await t.throwsAsync(main(['--quiet', '--reporter=json', filepath]));
103-
const [report] = JSON.parse(err.stdout);
102+
const error = await t.throwsAsync(main(['--quiet', '--reporter=json', filepath]));
103+
const [report] = JSON.parse(error.stdout);
104104
t.is(report.warningCount, 0);
105105
});
106106

@@ -115,8 +115,8 @@ test('init option', async t => {
115115

116116
test('invalid node-engine option', async t => {
117117
const filepath = await tempWrite('console.log()\n', 'x.js');
118-
const err = await t.throwsAsync(main(['--node-version', 'v', filepath]));
119-
t.is(err.code, 1);
118+
const error = await t.throwsAsync(main(['--node-version', 'v', filepath]));
119+
t.is(error.code, 1);
120120
});
121121

122122
test('cli option takes precedence over config', async t => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava'
22
import fn from '../'
33

4-
test(t => {
4+
test('main', t => {
55
t.is(fn('foo'), fn('foobar'))
66
})

test/fixtures/project/file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
const obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = { a: 1 };
2+
console.log(object.a);

test/options-manager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ test('groupConfigs', t => {
423423
},
424424
paths: ['/user/bar/hello.js']
425425
}
426-
].map(obj => {
427-
obj.options = Object.assign(manager.emptyOptions(), obj.options);
428-
return obj;
426+
].map(object => {
427+
object.options = Object.assign(manager.emptyOptions(), object.options);
428+
return object;
429429
}));
430430
});
431431

0 commit comments

Comments
 (0)