Skip to content

Commit 2d88c0c

Browse files
committed
Standardizing base flat config in tests
1 parent cfa1bed commit 2d88c0c

File tree

2 files changed

+12
-40
lines changed

2 files changed

+12
-40
lines changed

test/lib/rules/artifacts-combined-files/helper.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
const { readFileSync } = require('fs');
99
const { basename, dirname, join, parse, extname } = require('path');
1010
const { Linter } = require('eslint');
11-
const babelParser = require('@babel/eslint-parser');
1211
const lwcGraphAnalyzer = require('../../../../lib/index');
13-
const bundleAnalyzer = require('../../../../lib/processor');
1412
const LwcBundle = require('../../../../lib/lwc-bundle');
13+
const baseConfig = require('../../../../lib/configs/base');
1514

1615
/**
1716
* Creates ESLint configuration for a given rule
@@ -20,26 +19,13 @@ const LwcBundle = require('../../../../lib/lwc-bundle');
2019
*/
2120
function createLinterConfig(rulename) {
2221
const pluginPrefix = '@salesforce/lwc-graph-analyzer';
23-
return {
24-
files: ['*.js', '**/*.js', '*.html', '**/*.html'],
25-
languageOptions: {
26-
parser: babelParser,
27-
parserOptions: {
28-
requireConfigFile: false,
29-
sourceType: 'module',
30-
babelOptions: {
31-
parserOpts: {
32-
plugins: [['decorators', { decoratorsBeforeExport: false }]]
33-
}
34-
}
35-
}
36-
},
37-
plugins: { [pluginPrefix]: lwcGraphAnalyzer },
38-
processor: bundleAnalyzer,
39-
rules: {
40-
[`${pluginPrefix}/${rulename}`]: 'error'
41-
}
22+
const ruleConfig = {
23+
[`${pluginPrefix}/${rulename}`]: 'error'
4224
};
25+
const config = baseConfig;
26+
config.plugins = { [pluginPrefix]: lwcGraphAnalyzer };
27+
config.rules = ruleConfig;
28+
return config;
4329
}
4430

4531
/**

test/lib/rules/shared.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,10 @@
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
66
*/
77

8-
const RULE_TESTER_CONFIG = {
9-
languageOptions: {
10-
parser: require('@babel/eslint-parser'),
11-
parserOptions: {
12-
requireConfigFile: false,
13-
sourceType: 'module',
14-
babelOptions: {
15-
parserOpts: {
16-
plugins: [['decorators', { decoratorsBeforeExport: false }]]
17-
}
18-
}
19-
}
20-
},
21-
plugins: {
22-
'@salesforce/lwc-graph-analyzer': require('../../../lib/index')
23-
},
24-
processor: require('../../../lib/processor')
25-
};
8+
// Unless circumstances dictate otherwise, we'll endeavor to use the project's base configuration for our
9+
// test config.
10+
const baseConfig = require('../../../lib/configs/base');
11+
2612
module.exports = {
27-
RULE_TESTER_CONFIG
13+
RULE_TESTER_CONFIG: baseConfig
2814
};

0 commit comments

Comments
 (0)