Skip to content

Commit

Permalink
Merge pull request #149 from epaew/feature/preset-rules
Browse files Browse the repository at this point in the history
Refactoring: Replace src/utils/preset-cases with src/utils/preset-rules
  • Loading branch information
epaew authored Oct 11, 2020
2 parents fc414bc + 6221af1 commit a728832
Show file tree
Hide file tree
Showing 16 changed files with 393 additions and 343 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ plugins:
- '@typescript-eslint'
rules:
'@typescript-eslint/explicit-module-boundary-types': off
overrides:
- files:
- '__tests__/**'
rules:
filenames-simple/extname: off
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Use `core-js` as replacement of my own polyfill implementation.
* [#147](https://github.com/epaew/eslint-plugin-filenames-simple/pull/147)
Refactor utils/pluralize: Remove dependency on `eslint` package.
* [#149](https://github.com/epaew/eslint-plugin-filenames-simple/pull/149)
Refactoring: Replace utils/preset-cases with utils/preset-rules.

# 0.4.0
## Features
Expand Down
4 changes: 2 additions & 2 deletions __tests__/test-utils/fetch-rule-names.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import glob from 'glob';

import { presetCaseConverters } from '#/utils/preset-case-converters';
import { presetRules } from '#/utils/preset-rules';
import { asyncArrayFilter } from './async-array-filter';

export const fetchAllRuleNames = () =>
Expand All @@ -12,7 +12,7 @@ export const fetchAllRuleNames = () =>

export const fetchAvailableRuleNames = async () => {
return asyncArrayFilter<string>(fetchAllRuleNames(), async name => {
const camelizedName = presetCaseConverters['camelCase'](name);
const camelizedName = presetRules.camelCase.recommendationBuilder(name);

try {
const rule = await import(name);
Expand Down
21 changes: 21 additions & 0 deletions __tests__/utils/get-rule.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getRule, presetRules } from '#/utils/preset-rules';

describe('getRule', () => {
const subject = getRule;

describe('when the rule is camelCale', () => {
const rule = 'camelCase';

it('returns presetRules.camelCase', () => {
expect(subject(rule)).toEqual(presetRules.camelCase);
});
});

describe('when the rule is not defined in presetRules', () => {
const rule = 'index';

it('returns a new object with the field `expression` constructed based on the specified rule.', () => {
expect(subject(rule)).toEqual({ expression: new RegExp(`^${rule}$`) });
});
});
});
164 changes: 0 additions & 164 deletions __tests__/utils/preset-case-converters.test.ts

This file was deleted.

115 changes: 0 additions & 115 deletions __tests__/utils/preset-cases.test.ts

This file was deleted.

Loading

0 comments on commit a728832

Please sign in to comment.