Skip to content

Commit 5f5a77f

Browse files
MrCube42Josh Goldberg
authored andcommitted
Feature/converter no default export 166 (#215)
* feat (converter): Add no-default-export converter, impl pending * feat (converter): Use eslint import plugin for no-default-export * test (converter): no-default-export test (has no arguments) * test (converter): define e2e test for no-default-export * test (converter): move expected property to proper position * Accepted new end-to-end tests * Accepted new end-to-end tests
1 parent 3acdba1 commit 5f5a77f

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { convertNoConstantCondition } from "./converters/no-constant-condition";
4040
import { convertNoConstruct } from "./converters/no-construct";
4141
import { convertNoControlRegex } from "./converters/no-control-regex";
4242
import { convertNoDebugger } from "./converters/no-debugger";
43+
import { convertNoDefaultExport } from "./converters/no-default-export";
4344
import { convertNoDuplicateImports } from "./converters/no-duplicate-imports";
4445
import { convertNoDuplicateSuper } from "./converters/no-duplicate-super";
4546
import { convertNoDuplicateSwitchCase } from "./converters/no-duplicate-switch-case";
@@ -159,6 +160,7 @@ export const converters = new Map([
159160
["no-construct", convertNoConstruct],
160161
["no-control-regex", convertNoControlRegex],
161162
["no-debugger", convertNoDebugger],
163+
["no-default-export", convertNoDefaultExport],
162164
["no-duplicate-imports", convertNoDuplicateImports],
163165
["no-duplicate-super", convertNoDuplicateSuper],
164166
["no-duplicate-switch-case", convertNoDuplicateSwitchCase],
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNoDefaultExport: RuleConverter = () => {
4+
return {
5+
rules: [
6+
{
7+
ruleName: "import/no-default-export",
8+
},
9+
],
10+
plugins: ["import"],
11+
};
12+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { convertNoDefaultExport } from "../no-default-export";
2+
3+
describe(convertNoDefaultExport, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoDefaultExport({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "import/no-default-export",
13+
},
14+
],
15+
plugins: ["import"],
16+
});
17+
});
18+
});

test/tests/standalone tslint.json/eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
"@typescript-eslint/unbound-method": "off",
2727
"arrow-body-style": "off",
2828
"default-case": "off",
29+
"import/no-default-export": "error",
2930
"linebreak-style": "off",
3031
"no-bitwise": "off",
3132
"no-empty": "off",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
19 rules replaced with their ESLint equivalents. ✨
1+
20 rules replaced with their ESLint equivalents. ✨
22
️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀
3-
1 package is required for new ESLint rules. ⚡
3+
2 packages are required for new ESLint rules. ⚡
44
unicorn
5+
import
56
✅ All is well! ✅

test/tests/standalone tslint.json/tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"no-any": false,
1313
"no-bitwise": false,
1414
"no-empty": false,
15+
"no-default-export": true,
1516
"no-magic-numbers": false,
1617
"no-import-side-effect": false,
1718
"no-implicit-dependencies": [true, "dev"],

0 commit comments

Comments
 (0)