Skip to content

Commit

Permalink
build: fix prettier/quotes nonsense
Browse files Browse the repository at this point in the history
  • Loading branch information
DJTB committed Mar 14, 2022
1 parent 2716719 commit 0292ddb
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 37 deletions.
16 changes: 0 additions & 16 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"rules": {
"function-paren-newline": 0,
"quotes": [2, "single"],
"quotes": 0,
"arrow-parens": [2, "always"],
"camelcase": 1,
"comma-dangle": [2, "always-multiline"],
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2
}
3 changes: 1 addition & 2 deletions src/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useFuriPairs } from './hooks';
const wrapperStyle = {
display: 'inline-flex',
flexFlow: 'row wrap',
fontFamily:
'"ヒラギノ角ゴ ProN", "Hiragino Kaku Gothic ProN", "TakaoPゴシック", TakaoPGothic, "游ゴシック", "游ゴシック体", YuGothic, "Yu Gothic", "メイリオ", Meiryo, "MS ゴシック", "MS Gothic", HiraKakuProN-W3, "MotoyaLCedar", "Droid Sans Japanese", sans-serif',
fontFamily: `'ヒラギノ角ゴ ProN', 'Hiragino Kaku Gothic ProN', 'TakaoPゴシック', TakaoPGothic, '游ゴシック', '游ゴシック体', YuGothic, 'Yu Gothic', 'メイリオ', Meiryo, 'MS ゴシック', 'MS Gothic', HiraKakuProN-W3, 'MotoyaLCedar', 'Droid Sans Japanese', sans-serif`,
};

const pairStyle = {
Expand Down
10 changes: 3 additions & 7 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React from 'react';
import { render } from '@testing-library/react';

import { ReactFuri, Wrapper, Pair, Furi, Text } from '../src/index';
import { ReactFuri, Wrapper, Pair, Furi, Text } from '../src/components';

describe('<ReactFuri />', () => {
it('no reading or furi provided: just render word', () => {
Expand All @@ -14,9 +14,7 @@ describe('<ReactFuri />', () => {
});

it('no furi provided: render relevant readings over kanji blocks', () => {
const { container } = render(
<ReactFuri word="お見舞い" reading="おみまい" />
);
const { container } = render(<ReactFuri word="お見舞い" reading="おみまい" />);
expect(container).toMatchSnapshot();
});

Expand All @@ -26,9 +24,7 @@ describe('<ReactFuri />', () => {
});

it('showFuri false: no furigana rendered', () => {
const { container } = render(
<ReactFuri word="漢字" furi="0:かん;1:じ" showFuri={false} />
);
const { container } = render(<ReactFuri word="漢字" furi="0:かん;1:じ" showFuri={false} />);
expect(container).toMatchSnapshot();
});

Expand Down
63 changes: 52 additions & 11 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ describe('combineFuri()', () => {
});

describe('with furi data', () => {
const expected = [['', 'お'], ['せ', '世'], ['じ', '辞']];
const expected = [
['', 'お'],
['せ', '世'],
['じ', '辞'],
];

it('accepts furi location string', () => {
expect(combineFuri('お世辞', 'おせじ', '1:せ;2:じ')).toEqual(expected);
expect(combineFuri('お世辞', '', '1:せ;2:じ')).toEqual(expected);
Expand Down Expand Up @@ -69,11 +74,17 @@ describe('combineFuri()', () => {
});

it('trailing okurigana fallback', () => {
expect(combineFuri('大人しい', 'おとなしい')).toEqual([['おとな', '大人'], ['', 'しい']]);
expect(combineFuri('大人しい', 'おとなしい')).toEqual([
['おとな', '大人'],
['', 'しい'],
]);
});

it('leading bikago fallback', () => {
expect(combineFuri('お札', 'おふだ')).toEqual([['', 'お'], ['ふだ', '札']]);
expect(combineFuri('お札', 'おふだ')).toEqual([
['', 'お'],
['ふだ', '札'],
]);
});

it('leading bikago and trailing okurigana fallback', () => {
Expand Down Expand Up @@ -118,16 +129,30 @@ describe('basicFuri()', () => {
});

it('slices kana where present', () => {
expect(basicFuri('お札', 'おふだ')).toEqual([['', 'お'], ['ふだ', '札']]);
expect(basicFuri('使い方', 'つかいかた')).toEqual([['つか', '使'], ['', 'い'], ['かた', '方']]);
expect(basicFuri('大人しい', 'おとなしい')).toEqual([['おとな', '大人'], ['', 'しい']]);
expect(basicFuri('お札', 'おふだ')).toEqual([
['', 'お'],
['ふだ', '札'],
]);
expect(basicFuri('使い方', 'つかいかた')).toEqual([
['つか', '使'],
['', 'い'],
['かた', '方'],
]);
expect(basicFuri('大人しい', 'おとなしい')).toEqual([
['おとな', '大人'],
['', 'しい'],
]);
expect(basicFuri('申し申し', 'もしもし')).toEqual([
['も', '申'],
['', 'し'],
['も', '申'],
['', 'し'],
]);
expect(basicFuri('お見舞い', 'おみまい')).toEqual([['', 'お'], ['みま', '見舞'], ['', 'い']]);
expect(basicFuri('お見舞い', 'おみまい')).toEqual([
['', 'お'],
['みま', '見舞'],
['', 'い'],
]);
// not a real word :P
expect(basicFuri('お見い舞い', 'おみいまい')).toEqual([
['', 'お'],
Expand All @@ -145,15 +170,21 @@ describe('parseFuri()', () => {
});

it('works', () => {
expect(parseFuri('1:せ;2:じ')).toEqual([[[1, 2], 'せ'], [[2, 3], 'じ']]);
expect(parseFuri('1:せ;2:じ')).toEqual([
[[1, 2], 'せ'],
[[2, 3], 'じ'],
]);
});

it('can span multiple kanji', () => {
expect(parseFuri('0-1:おとな')).toEqual([[[0, 2], 'おとな']]);
});

it('can partially span multiple kanji', () => {
expect(parseFuri('0-1:うーろん;2:ちゃ')).toEqual([[[0, 2], 'うーろん'], [[2, 3], 'ちゃ']]);
expect(parseFuri('0-1:うーろん;2:ちゃ')).toEqual([
[[0, 2], 'うーろん'],
[[2, 3], 'ちゃ'],
]);
});
});

Expand All @@ -163,15 +194,25 @@ describe('generatePairs()', () => {
});

it('works', () => {
expect(generatePairs('お世辞', [[[1, 2], 'せ'], [[2, 3], 'じ']])).toEqual([
expect(
generatePairs('お世辞', [
[[1, 2], 'せ'],
[[2, 3], 'じ'],
])
).toEqual([
['', 'お'],
['せ', '世'],
['じ', '辞'],
]);
});

it('handles words with separated kanji and trailing okurigana', () => {
expect(generatePairs('貫き通す', [[[0, 1], 'つらぬ'], [[2, 3], 'とお']])).toEqual([
expect(
generatePairs('貫き通す', [
[[0, 1], 'つらぬ'],
[[2, 3], 'とお'],
])
).toEqual([
['つらぬ', '貫'],
['', 'き'],
['とお', '通'],
Expand Down

0 comments on commit 0292ddb

Please sign in to comment.