From 0292ddb8c04a33a59a5d919b7cb5a13cf151a25d Mon Sep 17 00:00:00 2001 From: Duncan Bay Date: Mon, 14 Mar 2022 16:35:46 +1100 Subject: [PATCH] build: fix prettier/quotes nonsense --- .editorconfig | 16 ------------ .eslintrc.json | 2 +- .prettierrc | 7 +++++ src/components.js | 3 +-- tests/index.test.js | 10 +++---- tests/utils.test.js | 63 +++++++++++++++++++++++++++++++++++++-------- 6 files changed, 64 insertions(+), 37 deletions(-) delete mode 100644 .editorconfig create mode 100644 .prettierrc diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dae45f6..0000000 --- a/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 2 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.js] -max_line_length = 100 -quote_type = single - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintrc.json b/.eslintrc.json index 739fffd..265ad5b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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"], diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..43574a1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "printWidth": 100, + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "tabWidth": 2 +} diff --git a/src/components.js b/src/components.js index 960e677..0f4960b 100644 --- a/src/components.js +++ b/src/components.js @@ -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 = { diff --git a/tests/index.test.js b/tests/index.test.js index aaf720a..4688958 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -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('', () => { it('no reading or furi provided: just render word', () => { @@ -14,9 +14,7 @@ describe('', () => { }); it('no furi provided: render relevant readings over kanji blocks', () => { - const { container } = render( - - ); + const { container } = render(); expect(container).toMatchSnapshot(); }); @@ -26,9 +24,7 @@ describe('', () => { }); it('showFuri false: no furigana rendered', () => { - const { container } = render( - - ); + const { container } = render(); expect(container).toMatchSnapshot(); }); diff --git a/tests/utils.test.js b/tests/utils.test.js index ea606e6..a7a0d64 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -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); @@ -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', () => { @@ -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([ ['', 'お'], @@ -145,7 +170,10 @@ 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', () => { @@ -153,7 +181,10 @@ describe('parseFuri()', () => { }); 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], 'ちゃ'], + ]); }); }); @@ -163,7 +194,12 @@ describe('generatePairs()', () => { }); it('works', () => { - expect(generatePairs('お世辞', [[[1, 2], 'せ'], [[2, 3], 'じ']])).toEqual([ + expect( + generatePairs('お世辞', [ + [[1, 2], 'せ'], + [[2, 3], 'じ'], + ]) + ).toEqual([ ['', 'お'], ['せ', '世'], ['じ', '辞'], @@ -171,7 +207,12 @@ describe('generatePairs()', () => { }); it('handles words with separated kanji and trailing okurigana', () => { - expect(generatePairs('貫き通す', [[[0, 1], 'つらぬ'], [[2, 3], 'とお']])).toEqual([ + expect( + generatePairs('貫き通す', [ + [[0, 1], 'つらぬ'], + [[2, 3], 'とお'], + ]) + ).toEqual([ ['つらぬ', '貫'], ['', 'き'], ['とお', '通'],