Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: Replace src/utils/preset-cases with src/utils/preset-rules #149

Merged
merged 3 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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