Skip to content

Commit

Permalink
test: Add test for relative extends in config file
Browse files Browse the repository at this point in the history
Test for xojs#685
  • Loading branch information
andrewdbond committed Aug 31, 2022
1 parent 5989128 commit 2bc1df6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/fixtures/config-files/extends-relative/.xo-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../extends.js"
}
5 changes: 5 additions & 0 deletions test/fixtures/config-files/extends-relative/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const object = {
a: 1
};

console.log(object.a);
14 changes: 14 additions & 0 deletions test/lint-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,17 @@ test(configType, {type: '.xo-config.js', dir: 'xo-config_js'});
test(configType, {type: '.xo-config.cjs', dir: 'xo-config_cjs'});
test(configType, {type: '.xo-config.json', dir: 'xo-config_json'});
test(configType, {type: '.xo-config', dir: 'xo-config'});

test('load config file with relative extends from different cwd', async t => {
const dir = 'extends-relative';
const {results, rulesMeta} = await xo.lintFiles('**/*', {cwd: path.resolve('fixtures', 'config-files', dir)});

t.true(
hasRule(
results,
path.resolve('fixtures', 'config-files', dir, 'file.js'),
'comma-dangle',
rulesMeta,
),
);
});

0 comments on commit 2bc1df6

Please sign in to comment.