Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add authored and Hypnosphi committed Aug 30, 2021
1 parent 1414d8b commit 05211e8
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { test, testFilePath, getTSParsers } from '../utils'
import jsxConfig from '../../../config/react'
import typescriptConfig from '../../../config/typescript'
import eslintPkg from 'eslint/package.json'
import semver from 'semver'
import { test, testFilePath, getTSParsers } from '../utils';
import jsxConfig from '../../../config/react';
import typescriptConfig from '../../../config/typescript';

import { RuleTester } from 'eslint';
import fs from 'fs';
Expand Down Expand Up @@ -114,35 +112,35 @@ ruleTester.run('no-unused-modules', rule, {
options: unusedExportsOptions,
code: 'import { o2 } from "./file-o";export default () => 12',
filename: testFilePath('./no-unused-modules/file-a.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'export const b = 2',
filename: testFilePath('./no-unused-modules/file-b.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'const c1 = 3; function c2() { return 3 }; export { c1, c2 }',
filename: testFilePath('./no-unused-modules/file-c.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'export function d() { return 4 }',
filename: testFilePath('./no-unused-modules/file-d.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'export class q { q0() {} }',
filename: testFilePath('./no-unused-modules/file-q.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'const e0 = 5; export { e0 as e }',
filename: testFilePath('./no-unused-modules/file-e.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'const l0 = 5; const l = 10; export { l0 as l1, l }; export default () => {}',
filename: testFilePath('./no-unused-modules/file-l.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
test({ options: unusedExportsOptions,
code: 'const o0 = 0; const o1 = 1; export { o0, o1 as o2 }; export default () => {}',
filename: testFilePath('./no-unused-modules/file-o.js') ,
parser: require.resolve('babel-eslint')}),
parser: require.resolve('babel-eslint') }),
],
invalid: [
test({
Expand Down Expand Up @@ -232,23 +230,23 @@ ruleTester.run('no-unused-modules', rule, {

describe('dynamic imports', () => {
if (semver.satisfies(eslintPkg.version, '< 6')) {
this.skip()
return
this.skip();
return;
}

// test for unused exports with `import()`
ruleTester.run('no-unused-modules', rule, {
valid: [
test({ options: unusedExportsOptions,
code: `
code: `
export const a = 10
export const b = 20
export const c = 30
const d = 40
export default d
`,
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/exports-for-dynamic-js.js')}),
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/exports-for-dynamic-js.js') }),
],
invalid: [
test({ options: unusedExportsOptions,
Expand All @@ -262,30 +260,30 @@ describe('dynamic imports', () => {
parser: require.resolve('babel-eslint'),
filename: testFilePath('./no-unused-modules/exports-for-dynamic-js-2.js'),
errors: [
error(`exported declaration 'a' not used within other modules`),
error(`exported declaration 'b' not used within other modules`),
error(`exported declaration 'c' not used within other modules`),
error(`exported declaration 'default' not used within other modules`),
]}),
error(`exported declaration 'a' not used within other modules`),
error(`exported declaration 'b' not used within other modules`),
error(`exported declaration 'c' not used within other modules`),
error(`exported declaration 'default' not used within other modules`),
] }),
],
})
});
typescriptRuleTester.run('no-unused-modules', rule, {
valid: [
test({ options: unusedExportsTypescriptOptions,
code: `
code: `
export const ts_a = 10
export const ts_b = 20
export const ts_c = 30
const ts_d = 40
export default ts_d
`,
parser: require.resolve('@typescript-eslint/parser'),
filename: testFilePath('./no-unused-modules/typescript/exports-for-dynamic-ts.ts')}),
parser: require.resolve('@typescript-eslint/parser'),
filename: testFilePath('./no-unused-modules/typescript/exports-for-dynamic-ts.ts') }),
],
invalid: [
],
})
})
});
});

// // test for export from
ruleTester.run('no-unused-modules', rule, {
Expand Down

0 comments on commit 05211e8

Please sign in to comment.