Skip to content

Commit 44112f2

Browse files
committed
test: Add tests after PR#681 for several issues:
- #656: "Several functions not flagged when using "last 7 years"" - #496: replaceAll no warning - #540: Are Array Prototype Methods Supported? - #539: Dont work with Array.prototype.at - #445: Some js methods not supported on IE 11 - #258: Array methods not reporting errors
1 parent 44f6be3 commit 44112f2

File tree

1 file changed

+79
-16
lines changed

1 file changed

+79
-16
lines changed

test/e2e.spec.ts

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ const eslintVersion = parseInt(
1515
const config: any =
1616
eslintVersion >= 9
1717
? {
18-
// ESLint 9+ flat config
19-
languageOptions: {
20-
parser,
21-
parserOptions: { ecmaVersion: 2020, sourceType: "module" },
22-
},
23-
settings: {
24-
lintAllEsApis: true,
25-
},
26-
}
27-
: {
28-
// ESLint 8 and below
29-
parser: require.resolve("@typescript-eslint/parser"),
18+
// ESLint 9+ flat config
19+
languageOptions: {
20+
parser,
3021
parserOptions: { ecmaVersion: 2020, sourceType: "module" },
31-
settings: {
32-
lintAllEsApis: true,
33-
},
34-
};
22+
},
23+
settings: {
24+
lintAllEsApis: true,
25+
},
26+
}
27+
: {
28+
// ESLint 8 and below
29+
parser: require.resolve("@typescript-eslint/parser"),
30+
parserOptions: { ecmaVersion: 2020, sourceType: "module" },
31+
settings: {
32+
lintAllEsApis: true,
33+
},
34+
};
3535

3636
const ruleTester = new eslint.RuleTester(config);
3737

@@ -730,5 +730,68 @@ ruleTester.run("compat", rule, {
730730
},
731731
],
732732
},
733+
{
734+
code: "['some', 'arrays'].at(-1)",
735+
settings: { browsers: ["safari 11"] },
736+
errors: [
737+
{
738+
message: "Array.at() is not supported in Safari 11",
739+
},
740+
],
741+
},
742+
{
743+
code: "[].includes()",
744+
settings: { browsers: ["ie 11"] },
745+
errors: [
746+
{
747+
message: "Array.includes() is not supported in IE 11",
748+
},
749+
],
750+
},
751+
{
752+
code: "'strsd'.includes()",
753+
settings: { browsers: ["ie 11"] },
754+
errors: [
755+
{
756+
message: "String.includes() is not supported in IE 11",
757+
},
758+
],
759+
},
760+
{
761+
code: "[1, 2, [3, 4]].flat()",
762+
settings: { browsers: ["ie 11"] },
763+
errors: [
764+
{
765+
message: "Array.flat() is not supported in IE 11",
766+
},
767+
],
768+
},
769+
{
770+
code: "[1,2,3].flatMap(x => [x, x*2])",
771+
settings: { browsers: ["chrome 68"] },
772+
errors: [
773+
{
774+
message: "Array.flatMap() is not supported in Chrome 68",
775+
},
776+
],
777+
},
778+
{
779+
code: "Object.fromEntries([])",
780+
settings: { browsers: ["chrome 72"] },
781+
errors: [
782+
{
783+
message: "Object.fromEntries() is not supported in Chrome 72",
784+
},
785+
],
786+
},
787+
{
788+
code: "'hello'.replaceAll('l', 'r')",
789+
settings: { browsers: ["chrome 84"] },
790+
errors: [
791+
{
792+
message: "String.replaceAll() is not supported in Chrome 84",
793+
},
794+
],
795+
},
733796
],
734797
});

0 commit comments

Comments
 (0)