From a477df1b084493c5c5d998509b1e1c46c7ac52bb Mon Sep 17 00:00:00 2001 From: jeffshaver Date: Sun, 24 Feb 2019 18:05:06 -0500 Subject: [PATCH] fix a bunch of tests that were failing --- package.json | 1 + tests/src/rules/export.js | 6 +++--- tests/src/rules/extensions.js | 8 ++++---- tests/src/rules/named.js | 2 +- tests/src/rules/no-default-export.js | 5 +++-- tests/src/rules/no-named-export.js | 5 +++-- tests/src/rules/no-unresolved.js | 2 +- tests/src/rules/prefer-default-export.js | 3 +++ tests/src/utils.js | 4 ++-- 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 79f52e5930..4a312d4929 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "watch": "cross-env NODE_PATH=./src mocha --watch --compilers js:babel-register --recursive tests/src", "pretest": "linklocal", "posttest": "eslint ./src", + "testpath": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot -t 5s", "test": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive tests/src -t 5s", "test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src", "test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done", diff --git a/tests/src/rules/export.js b/tests/src/rules/export.js index 84598677da..33f0121233 100644 --- a/tests/src/rules/export.js +++ b/tests/src/rules/export.js @@ -17,8 +17,8 @@ ruleTester.run('export', rule, { test({ code: 'export var [ foo, bar ] = array;' }), test({ code: 'export var { foo, bar } = object;' }), test({ code: 'export var [ foo, bar ] = array;' }), - test({ code: 'export { foo, foo as bar }' }), - test({ code: 'export { bar }; export * from "./export-all"' }), + test({ code: 'let foo; export { foo, foo as bar }' }), + test({ code: 'let bar; export { bar }; export * from "./export-all"' }), test({ code: 'export * from "./export-all"' }), test({ code: 'export * from "./does-not-exist"' }), @@ -62,7 +62,7 @@ ruleTester.run('export', rule, { // errors: ['Parsing error: Duplicate export \'foo\''], // }), test({ - code: 'export { foo }; export * from "./export-all"', + code: 'let foo; export { foo }; export * from "./export-all"', errors: ['Multiple exports of name \'foo\'.', 'Multiple exports of name \'foo\'.'], }), diff --git a/tests/src/rules/extensions.js b/tests/src/rules/extensions.js index 8b816daa9e..d7b97bea0b 100644 --- a/tests/src/rules/extensions.js +++ b/tests/src/rules/extensions.js @@ -105,14 +105,14 @@ ruleTester.run('extensions', rule, { test({ code: [ 'export { foo } from "./foo.js"', - 'export { bar }', + 'let bar; export { bar }', ].join('\n'), options: [ 'always' ], }), test({ code: [ 'export { foo } from "./foo"', - 'export { bar }', + 'let bar; export { bar }', ].join('\n'), options: [ 'never' ], }), @@ -334,7 +334,7 @@ ruleTester.run('extensions', rule, { test({ code: [ 'export { foo } from "./foo"', - 'export { bar }', + 'let bar; export { bar }', ].join('\n'), options: [ 'always' ], errors: [ @@ -348,7 +348,7 @@ ruleTester.run('extensions', rule, { test({ code: [ 'export { foo } from "./foo.js"', - 'export { bar }', + 'let bar; export { bar }', ].join('\n'), options: [ 'never' ], errors: [ diff --git a/tests/src/rules/named.js b/tests/src/rules/named.js index 92b3d9163e..569f3158a5 100644 --- a/tests/src/rules/named.js +++ b/tests/src/rules/named.js @@ -61,7 +61,7 @@ ruleTester.run('named', rule, { }), // regression tests - test({ code: 'export { foo as bar }'}), + test({ code: 'let foo; export { foo as bar }'}), // destructured exports test({ code: 'import { destructuredProp } from "./named-exports"' }), diff --git a/tests/src/rules/no-default-export.js b/tests/src/rules/no-default-export.js index 6440bfa895..5977ef19b2 100644 --- a/tests/src/rules/no-default-export.js +++ b/tests/src/rules/no-default-export.js @@ -29,7 +29,7 @@ ruleTester.run('no-default-export', rule, { `, }), test({ - code: `export { foo, bar }`, + code: `let foo, bar; export { foo, bar }`, }), test({ code: `export const { foo, bar } = item;`, @@ -42,6 +42,7 @@ ruleTester.run('no-default-export', rule, { }), test({ code: ` + let item; export const foo = item; export { item }; `, @@ -102,7 +103,7 @@ ruleTester.run('no-default-export', rule, { }], }), test({ - code: 'export { foo as default }', + code: 'let foo; export { foo as default }', errors: [{ ruleId: 'ExportNamedDeclaration', message: 'Do not alias `foo` as `default`. Just export `foo` itself ' + diff --git a/tests/src/rules/no-named-export.js b/tests/src/rules/no-named-export.js index d8748d3f6b..c56a135421 100644 --- a/tests/src/rules/no-named-export.js +++ b/tests/src/rules/no-named-export.js @@ -10,7 +10,7 @@ ruleTester.run('no-named-export', rule, { code: 'export default function bar() {};', }), test({ - code: 'export { foo as default }', + code: 'let foo; export { foo as default }', }), test({ code: 'export default from "foo.js"', @@ -82,7 +82,7 @@ ruleTester.run('no-named-export', rule, { }], }), test({ - code: `export { foo, bar }`, + code: `let foo, bar; export { foo, bar }`, errors: [{ ruleId: 'ExportNamedDeclaration', message: 'Named exports are not allowed.', @@ -111,6 +111,7 @@ ruleTester.run('no-named-export', rule, { }), test({ code: ` + let item; export const foo = item; export { item }; `, diff --git a/tests/src/rules/no-unresolved.js b/tests/src/rules/no-unresolved.js index 5b4f6ae53c..9db6e1a5c5 100644 --- a/tests/src/rules/no-unresolved.js +++ b/tests/src/rules/no-unresolved.js @@ -34,7 +34,7 @@ function runResolverTests(resolver) { rest({ code: 'export { foo } from "./bar"' }), rest({ code: 'export * from "./bar"' }), - rest({ code: 'export { foo }' }), + rest({ code: 'let foo; export { foo }' }), // stage 1 proposal for export symmetry, rest({ code: 'export * as bar from "./bar"' diff --git a/tests/src/rules/prefer-default-export.js b/tests/src/rules/prefer-default-export.js index 3a9145198d..3a89c6aa7f 100644 --- a/tests/src/rules/prefer-default-export.js +++ b/tests/src/rules/prefer-default-export.js @@ -28,6 +28,7 @@ ruleTester.run('prefer-default-export', rule, { }), test({ code: ` + let foo, bar; export { foo, bar }`, }), test({ @@ -44,11 +45,13 @@ ruleTester.run('prefer-default-export', rule, { }), test({ code: ` + let item; export const foo = item; export { item };`, }), test({ code: ` + let foo; export { foo as default }`, }), test({ diff --git a/tests/src/utils.js b/tests/src/utils.js index fe04d684e2..52e2d23cd5 100644 --- a/tests/src/utils.js +++ b/tests/src/utils.js @@ -43,8 +43,8 @@ export const SYNTAX_CASES = [ test({ code: 'const { x, y, ...z } = bar', parser: 'babel-eslint' }), // all the exports - test({ code: 'export { x }' }), - test({ code: 'export { x as y }' }), + test({ code: 'let x; export { x }' }), + test({ code: 'let x; export { x as y }' }), // not sure about these since they reference a file // test({ code: 'export { x } from "./y.js"'}),