Skip to content

Commit

Permalink
refactor: refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdra committed Feb 11, 2022
1 parent bba4d58 commit 886c2c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Linter, Rule, SourceCode } from 'eslint';
import { preferAdditionShorthandRule } from './prefer-addition-shorthand-rule.js';
import { transformRule, type TransformRuleOption } from './transform-rule.js';
import {
type FixableMaker,
Expand All @@ -13,7 +14,9 @@ export { TransformRuleOption, type FixableMaker, type SuggestionFilter };

export const eslintInteractivePlugin = {
rules: {
transform: transformRule,
'transform': transformRule,
// for test
'prefer-addition-shorthand': preferAdditionShorthandRule,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Rule } from 'eslint';

/**
* @file This is a rule for testing purposes.
*/

export type ApplyFixesRuleOption = Rule.Fix[];

const rule: Rule.RuleModule = {
export const preferAdditionShorthandRule: Rule.RuleModule = {
meta: {
type: 'suggestion',
// @ts-ignore
Expand Down Expand Up @@ -50,6 +54,3 @@ const rule: Rule.RuleModule = {
};
},
};

// eslint-disable-next-line import/no-default-export
export default rule;
11 changes: 2 additions & 9 deletions src/test-util/transform-tester.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { resolve } from 'path';
import { Linter, ESLint } from 'eslint';
import { TransformArg, TransformName, TransformRuleOption } from '../plugin/index.js';
import { transformRule } from '../plugin/transform-rule.js';
import preferAdditionShorthand from './rules/prefer-addition-shorthand.js';
import { eslintInteractivePlugin, TransformArg, TransformName, TransformRuleOption } from '../plugin/index.js';

const DEFAULT_FILENAME = 'test.js';

Expand Down Expand Up @@ -84,12 +82,7 @@ export class TransformTester<T extends TransformName> {
return new ESLint({
useEslintrc: false,
plugins: {
'eslint-interactive': {
rules: {
'prefer-addition-shorthand': preferAdditionShorthand,
'transform': transformRule,
},
},
'eslint-interactive': eslintInteractivePlugin,
},
overrideConfig: {
plugins: ['eslint-interactive', ...(this.defaultLinterConfig.plugins ?? [])],
Expand Down

0 comments on commit 886c2c4

Please sign in to comment.