init source

This commit is contained in:
Le Viet
2022-03-07 22:07:57 +07:00
parent e4376f3777
commit 8aba590a8d
11240 changed files with 1012977 additions and 0 deletions
@@ -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,
},
};
}
@@ -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,
};
};
}