init source
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
const defaultParserOptions = {
|
||||
ecmaVersion: 2018,
|
||||
ecmaFeatures: {
|
||||
experimentalObjectRestSpread: true,
|
||||
jsx: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default function parserOptionsMapper({
|
||||
code,
|
||||
errors,
|
||||
options = [],
|
||||
parserOptions = {},
|
||||
}) {
|
||||
return {
|
||||
code,
|
||||
errors,
|
||||
options,
|
||||
parserOptions: {
|
||||
...defaultParserOptions,
|
||||
...parserOptions,
|
||||
},
|
||||
};
|
||||
}
|
||||
Generated
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
type ESLintTestRunnerTestCase = {
|
||||
code: string,
|
||||
errors: ?Array<{ message: string, type: string }>,
|
||||
options: ?Array<mixed>,
|
||||
parserOptions: ?Array<mixed>
|
||||
};
|
||||
|
||||
export default function ruleOptionsMapperFactory(ruleOptions: Array<mixed> = []) {
|
||||
// eslint-disable-next-line
|
||||
return ({ code, errors, options, parserOptions }: ESLintTestRunnerTestCase): ESLintTestRunnerTestCase => {
|
||||
return {
|
||||
code,
|
||||
errors,
|
||||
// Flatten the array of objects in an array of one object.
|
||||
options: (options || []).concat(ruleOptions).reduce((acc, item) => [{
|
||||
...acc[0],
|
||||
...item,
|
||||
}], [{}]),
|
||||
parserOptions,
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user