<commit_before>import { test, getNonDefaultParsers } from '../utils'

import { RuleTester } from 'eslint'

const ruleTester = new RuleTester()
    , rule = require('../../../src/rules/prefer-default-export')

ruleTester.run('prefer-default-export', rule, {
  valid: [
    test({
      code: `
        export const foo = 'foo';
        export const bar = 'bar';`,
      }),
    test({
      code: `
        export default function bar() {};`,
      }),
    test({
      code: `
        export const foo = 'foo';
        export function bar() {};`,
      }),
    test({
      code: `
        export const foo = 'foo';
        export default bar;`,
      }),
    test({
      code: `
        let foo, bar;
        export { foo, bar }`,
      }),
    test({
      code: `
        export const { foo, bar } = item;`,
      }),
    test({
      code: `
        export const { foo, bar: baz } = item;`,
      }),
    test({
      code: `
        export const { foo: { bar, baz } } = item;`,
      }),
    test({
      code: `
        export const [a, b] = item;`,
      }),
    test({
      code: `
        let item;
        export const foo = item;
        export { item };`,
      }),
    test({
      code: `
        let foo;
        export { foo as default }`,
      }),
    test({
      code: `
        export * from './foo';`,
      }),
    test({
      code: `export Memory, { MemoryValue } from './Memory'`,
      parser: require.resolve('babel-eslint'),
      }),

    // no exports at all
    test({
      code: `
        import * as foo from './foo';`,
      }),

    test({
      code: `export type UserId = number;`,
      parser: require.resolve('babel-eslint'),
      }),

    // issue #653
    test({
      code: 'export default from "foo.js"',
      parser: require.resolve('babel-eslint'),
    }),
    test({
      code: 'export { a, b } from "foo.js"',
      parser: require.resolve('babel-eslint'),
    }),
    // ...SYNTAX_CASES,
    {
      code: `
        export const [CounterProvider,, withCounter] = func();;
      `,
      parser: require.resolve('babel-eslint'),
    },
  ],
  invalid: [
    test({
      code: `
        export function bar() {};`,
      errors: [{
        type: 'ExportNamedDeclaration',
        message: 'Prefer default export.',
      }],
    }),
    test({
      code: `
        export const foo = 'foo';`,<commit_msg>[Tests] `prefer-default-export`: fix test case<commit_after>import { test, getNonDefaultParsers } from '../utils'

import { RuleTester } from 'eslint'

const ruleTester = new RuleTester()
    , rule = require('../../../src/rules/prefer-default-export')

ruleTester.run('prefer-default-export', rule, {
  valid: [
    test({
      code: `
        export const foo = 'foo';
        export const bar = 'bar';`,
      }),
    test({
      code: `
        export default function bar() {};`,
      }),
    test({
      code: `
        export const foo = 'foo';
        export function bar() {};`,
      }),
    test({
      code: `
        export const foo = 'foo';
        export default bar;`,
      }),
    test({
      code: `
        let foo, bar;
        export { foo, bar }`,
      }),
    test({
      code: `
        export const { foo, bar } = item;`,
      }),
    test({
      code: `
        export const { foo, bar: baz } = item;`,
      }),
    test({
      code: `
        export const { foo: { bar, baz } } = item;`,
      }),
    test({
      code: `
        export const [a, b] = item;`,
      }),
    test({
      code: `
        let item;
        export const foo = item;
        export { item };`,
      }),
    test({
      code: `
        let foo;
        export { foo as default }`,
      }),
    test({
      code: `
        export * from './foo';`,
      }),
    test({
      code: `export Memory, { MemoryValue } from './Memory'`,
      parser: require.resolve('babel-eslint'),
      }),

    // no exports at all
    test({
      code: `
        import * as foo from './foo';`,
      }),

    test({
      code: `export type UserId = number;`,
      parser: require.resolve('babel-eslint'),
      }),

    // issue #653
    test({
      code: 'export default from "foo.js"',
      parser: require.resolve('babel-eslint'),
    }),
    test({
      code: 'export { a, b } from "foo.js"',
      parser: require.resolve('babel-eslint'),
    }),
    // ...SYNTAX_CASES,
    test({
      code: `
        export const [CounterProvider,, withCounter] = func();;
      `,
      parser: require.resolve('babel-eslint'),
    }),
  ],
  invalid: [
    test({
      code: `
        export function bar() {};`,
      errors: [{
        type: 'ExportNamedDeclaration',
        message: 'Prefer default export.',
      }],
    }),
    test({
      code: `
        export const foo = 'foo';`,
{'fraction_non_alphanumeric': 0.17251523429291868, 'fraction_numerical': 0.0012607690691321706, 'mean_word_length': 1.6225895316804408, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6189185', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1453, 'n_words': 380}