Skip to content

Commit d1fd3e1

Browse files
coreyfarrellsindresorhus
authored andcommitted
Move default ESLint cache to node_modules/.cache/xo. (#351)
Fixes #335
1 parent f435698 commit d1fd3e1

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/options-manager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const mergeWith = require('lodash.mergewith');
66
const multimatch = require('multimatch');
77
const pathExists = require('path-exists');
88
const pkgConf = require('pkg-conf');
9+
const findCacheDir = require('find-cache-dir');
910
const resolveFrom = require('resolve-from');
1011
const prettier = require('prettier');
1112
const semver = require('semver');
@@ -29,7 +30,7 @@ const DEFAULT_EXTENSION = [
2930
const DEFAULT_CONFIG = {
3031
useEslintrc: false,
3132
cache: true,
32-
cacheLocation: path.join(os.homedir() || os.tmpdir(), '.xo-cache/'),
33+
cacheLocation: findCacheDir({name: 'xo'}) || path.join(os.homedir() || os.tmpdir(), '.xo-cache/'),
3334
globInputPaths: false,
3435
baseConfig: {
3536
extends: [

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"eslint-plugin-prettier": "^2.6.0",
6464
"eslint-plugin-promise": "^4.0.0",
6565
"eslint-plugin-unicorn": "^6.0.1",
66+
"find-cache-dir": "^2.0.0",
6667
"get-stdin": "^6.0.0",
6768
"globby": "^8.0.0",
6869
"has-flag": "^3.0.0",

test/options-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('normalizeOpts: falsie values stay falsie', t => {
4242

4343
test('buildConfig: defaults', t => {
4444
const config = manager.buildConfig({});
45-
t.true(/[\\/]\.xo-cache[\\/]?$/u.test(config.cacheLocation));
45+
t.true(/[\\/]\.cache\/xo[\\/]?$/u.test(config.cacheLocation));
4646
t.is(config.useEslintrc, false);
4747
t.is(config.cache, true);
4848
t.is(config.baseConfig.extends[0], 'xo/esnext');

0 commit comments

Comments
 (0)