Skip to content

Commit 5d4acdf

Browse files
committed
fix linting for directories; fix typeings issues; optimize build process (smaller bundle size)
1 parent 29e878a commit 5d4acdf

File tree

20 files changed

+88
-91
lines changed

20 files changed

+88
-91
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ root = true
33

44
[*]
55
charset = utf-8
6-
indent_style = space
76
indent_size = 2
87
end_of_line = lf
8+
indent_style = space
99
insert_final_newline = true
1010
trim_trailing_whitespace = true
1111

.eslintignore

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
src/
2-
docs/
3-
dist/
4-
__tests__/
5-
__stories__/
6-
node_modules/
7-
8-
npm-*.log
9-
*-debug.log
1+
dist
2+
node_modules

.eslintrc

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"extends": [
3-
"eslint-config-poetez/typescript-react",
4-
"react-app",
5-
"plugin:prettier/recommended"
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:react/recommended",
6+
"prettier"
7+
],
8+
"plugins": [
9+
"prettier",
10+
"react-hooks",
11+
"@typescript-eslint"
612
],
713
"env": {
814
"browser": true,
@@ -11,12 +17,24 @@
1117
"jest": true
1218
},
1319
"rules": {
20+
"react/prop-types": 0,
1421
"semi": "off",
1522
"sort-keys": "off",
1623
"global-require": "off",
1724
"spaced-comment": "off",
1825
"capitalized-comments": "off",
19-
"padding-line-between-statements": "off"
26+
"padding-line-between-statements": "off",
27+
"@typescript-eslint/no-var-requires": 0,
28+
"@typescript-eslint/no-explicit-any": 0,
29+
"@typescript-eslint/no-inferrable-types": 0,
30+
"@typescript-eslint/no-non-null-assertion": 0
31+
},
32+
"parserOptions": {
33+
"sourceType": "module",
34+
"ecmaFeatures": {
35+
"impliedStrict": true,
36+
"jsx": true
37+
}
2038
},
2139
"settings": {
2240
"react": {

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Editor directories and files
44
.idea
5-
.vs/
6-
.vscode/
5+
.vs
6+
.vscode
77
.cache
88

99
# dependencies

.prettierignore

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
.*
2-
*.ejs
3-
*.ico
4-
*.map
5-
*.png
6-
*.svg
7-
*.xml
8-
9-
.eslintignore
10-
.eslintrc
11-
.prettierignore
12-
.prettierrc
13-
.travis.yml
14-
15-
package.json
16-
17-
/docs
18-
node_modules/
19-
/dist/*/cjs/
20-
/dist/*/esm/
21-
/dist/*/umd/
1+
dist
2+
node_modules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ All properties are technically optional (with a few having default values). Very
133133
|`menuItemSize`| number | `35` | The height of each option in the menu (px)
134134
|`isClearable`| bool | `false` | Is the select value clearable
135135
|`noOptionsMsg`| string | `No options` | The text displayed in the menu when there are no options available (to hide menu when search returns no items, set to `null` or `''`)
136-
|`loadingMsg`| string | `Loading...` | The text displayed in the menu when `isLoading` === `true`
136+
|`loadingMsg`| string | `Loading..` | The text displayed in the menu when `isLoading` === `true`
137137
|`clearIcon`| ReactNode OR ((state: any) => ReactNode) | `undefined` | Custom clear icon node - `state` forwarded to a function is `{ menuOpen, isLoading, isInvalid, isDisabled }`
138138
|`caretIcon`| ReactNode OR ((state: any) => ReactNode) | `undefined` | Custom caret icon node - `state` forwarded to a function is `{ menuOpen, isLoading, isInvalid, isDisabled }`
139139
|`loadingNode`| ReactNode | `undefined` | Custom loading node

__stories__/helpers/components/CodeMarkup.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import { MEDIA_QUERY_IS_MOBILE } from '../styled';
44
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
55

66
// Register light build of react-syntax-highlighter and register only what is needed
7+
const dark = require('react-syntax-highlighter/dist/esm/styles/prism/dark').default;
78
const markup = require('react-syntax-highlighter/dist/esm/languages/prism/markup').default;
89
const javascript = require('react-syntax-highlighter/dist/esm/languages/prism/javascript').default;
9-
const dark = require('react-syntax-highlighter/dist/esm/styles/prism/dark').default;
10-
1110
SyntaxHighlighter.registerLanguage('markup', markup);
1211
SyntaxHighlighter.registerLanguage('javascript', javascript);
1312

@@ -114,4 +113,6 @@ const CodeMarkup = memo<CodeMarkupProps>(({
114113
</CodeMarkupContainer>
115114
));
116115

116+
CodeMarkup.displayName = 'CodeMarkup';
117+
117118
export default CodeMarkup;

__stories__/index.stories.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const SingleSelect = () => {
9696
<Title>Single-Select</Title>
9797
<Hr />
9898
<Paragraph>
99-
In this story's source code, notice that the callback function
99+
In this story&apos;s source code, notice that the callback function
100100
properties <code>getOptionValue</code> and <code>getOptionLabel</code> are
101101
wrapped in a <code>useCallback</code>. While not required, <em>strongly prefer </em>
102102
memoization of any callback function property whenever possible. This will boost
@@ -267,7 +267,7 @@ export const MultiSelect = () => {
267267
/>
268268
</SelectContainer>
269269
<SelectContainer>
270-
<Label>Custom "renderMultiOptions"</Label>
270+
<Label>Custom &quot;renderMultiOptions&quot;</Label>
271271
<Select
272272
isMulti
273273
isClearable
@@ -322,9 +322,9 @@ export const Styling = () => {
322322
<Content>
323323
react-functional-select uses <PackageLink {...STYLED_COMPONENTS_PACKAGE} /> to
324324
handle its styling. The root node is wrapped in
325-
styled-component's <code>ThemeProvider</code> wrapper component which gives all
326-
child styled-components access to the provided theme via React's context API.
327-
To override react-functional-select's default theme, pass an object to
325+
styled-component&apos;s <code>ThemeProvider</code> wrapper component which gives all
326+
child styled-components access to the provided theme via React&apos;s context API.
327+
To override react-functional-select&apos;s default theme, pass an object to
328328
the <code>themeConfig</code> property - any matching properties will replace
329329
those in the default theme.
330330
</Content>
@@ -455,7 +455,7 @@ export const Events = () => {
455455
</Li>
456456
<Li>
457457
<TextHeader>onInputChange(value: string) {'=>'} void</TextHeader> -
458-
executed after the input control's value changes
458+
executed after the input control&apos;s value changes
459459
</Li>
460460
<Li>
461461
<TextHeader>onInputBlur(e: FocusEvent{'<'}HTMLInputElement{'>'}) {'=>'} void</TextHeader> -
@@ -642,14 +642,14 @@ export const Filtering = () => {
642642
ignores accents when matching strings. Default value is <em>false</em>.
643643
</Li>
644644
<Li>
645-
<TextHeader>filterMatchFrom?: 'any' | 'start'</TextHeader> -
646-
Position in source string to perform match. Default value is <em>'any'</em>.
645+
<TextHeader>filterMatchFrom?: &apos; any&apos; | &apos;start&apos;</TextHeader> -
646+
Position in source string to perform match. Default value is <em>&apos;any&apos;</em>.
647647
</Li>
648648
<Li>
649649
<TextHeader>getFilterOptionString(option: MenuOption) {'=>'} string</TextHeader> -
650650
When defined will take each option and generate a string used in
651651
the filtering process. By default, the stringified version of what is
652-
generated by <code>getOptionLabel</code>, if definded, or the option's label
652+
generated by <code>getOptionLabel</code>, if definded, or the option&apos;s label
653653
as a fallback. The <code>MenuOption</code> typed parameter
654654
that <code>getFilterOptionString</code> accepts contains a <code>data</code> property
655655
that represents the objects that comprise your <code>options</code> property.
@@ -730,9 +730,9 @@ export const Virtualization = () => {
730730
of nodes), list virtualization can also assist with:
731731
<List>
732732
<Li>
733-
<strong>Efficient memory allocation</strong>. 'Windowing' naturally
733+
<strong>Efficient memory allocation</strong>.&apos; Windowing&apos; naturally
734734
lends itself to the dynamic generation of attributes/values as each
735-
object comes into your renderer's scope (as opposed to allocating
735+
object comes into your renderer&apos;s scope (as opposed to allocating
736736
this data upfront for each object in your list). This way you can
737737
perform this work just when you absolutely need to and then can
738738
immediately release it for the GC to cleanup. As an example I am
@@ -744,7 +744,7 @@ export const Virtualization = () => {
744744
<Li>
745745
<strong>Functional architecture</strong>. The flexibility provided
746746
through only having to manage subsets of your list allows for a more
747-
dynamic application. By breaking your code out into smaller, 'pure'
747+
dynamic application. By breaking your code out into smaller, &apos;pure&apos;
748748
child components, you can write code that scales well and becomes
749749
open to performance optimizations - most notably, memoization.
750750
Simple components that rely on the props passed to it (rather than
@@ -830,8 +830,8 @@ export const Advanced = () => {
830830
<Li>
831831
<TextHeader>renderOptionLabel(option: any) {'=>'} ReactNode</TextHeader> - Callback
832832
function with a return type of <code>ReactNode</code>. Use this property in cases
833-
where the standard <code>getOptionLabel</code> property won't meet your needs (for
834-
instance, you want to render each option's label using custom JSX). More complex
833+
where the standard <code>getOptionLabel</code> property will not meet your needs (for
834+
instance, you want to render each option&apos;s label using custom JSX). More complex
835835
option labels will likely equate to longer render durations - this can translate
836836
into a flash of empty space when a user first starts scrolling. In order to prevent
837837
this, the <code>menuOverscanCount</code> property can be increased to render additional
@@ -969,10 +969,10 @@ export const Async = () => {
969969
<List>
970970
<Li>
971971
<TextHeader>onInputChange(value: string) {'=>'} void</TextHeader> -
972-
callback executed directly following the input control's <code>onChange</code> event.
972+
callback executed directly following the input control&apos;s <code>onChange</code> event.
973973
This callback is not debounced, so it fires immediately. This is a good
974974
place to set a stateful loading property in your parent component that is mapped to
975-
react-functional-select's <code>isLoading</code> property.
975+
react-functional-select&apos;s <code>isLoading</code> property.
976976
</Li>
977977
<Li>
978978
<TextHeader>onSearchChange(value: string) {'=>'} void</TextHeader> -
@@ -991,7 +991,7 @@ export const Async = () => {
991991
<TextHeader>isLoading?: boolean</TextHeader> - When true, a loading animation will
992992
appear in the far-right of the control and take the place of the clear icon (if shown).
993993
Additionally, it will hide options in the menu and instead, display a loading message.
994-
The loading message text defaults to 'Loading...', but can be overriden via
994+
The loading message text defaults to &apos;Loading...&apos;, but can be overriden via
995995
the <code>loadingMsg</code> property.
996996
</Li>
997997
</List>

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"umd": "dist/index.umd.js",
88
"types": "dist/index.d.ts",
99
"files": [
10-
"dist"
10+
"dist",
11+
"LICENSE",
12+
"README.md"
1113
],
1214
"sideEffects": false,
1315
"license": "MIT",
@@ -19,10 +21,10 @@
1921
"url": "https://github.com/based-ghost/react-functional-select/issues"
2022
},
2123
"repository": {
22-
"url": "https://github.com/based-ghost/react-functional-select.git",
23-
"type": "git"
24+
"type": "git",
25+
"url": "https://github.com/based-ghost/react-functional-select.git"
2426
},
25-
"homepage": "https://based-ghost.github.io/react-functional-select/",
27+
"homepage": "https://based-ghost.github.io/react-functional-select",
2628
"keywords": [
2729
"react",
2830
"react-components",
@@ -37,8 +39,7 @@
3739
"functional"
3840
],
3941
"engines": {
40-
"node": ">=14.18.0",
41-
"npm": ">=8.0.0"
42+
"node": ">= 14"
4243
},
4344
"browserslist": [
4445
"> 0.25%",
@@ -67,7 +68,7 @@
6768
"@testing-library/react": "^13.4.0",
6869
"@testing-library/user-event": "^14.4.3",
6970
"@types/jest": "^29.1.2",
70-
"@types/node": "^18.8.4",
71+
"@types/node": "^18.8.5",
7172
"@types/react": "^18.0.21",
7273
"@types/react-dom": "^18.0.6",
7374
"@types/react-window": "^1.8.5",
@@ -81,9 +82,10 @@
8182
"cross-env": "^7.0.3",
8283
"enzyme": "^3.11.0",
8384
"eslint": "^8.25.0",
84-
"eslint-config-poetez": "^1.0.0",
8585
"eslint-config-prettier": "^8.5.0",
8686
"eslint-plugin-prettier": "^4.2.1",
87+
"eslint-plugin-react": "^7.31.10",
88+
"eslint-plugin-react-hooks": "^4.6.0",
8789
"jest": "^29.1.2",
8890
"jest-environment-jsdom": "^29.1.2",
8991
"jest-enzyme": "^7.1.2",
@@ -95,7 +97,7 @@
9597
"react-toastify": "^9.0.8",
9698
"react-window": "^1.8.7",
9799
"rimraf": "^3.0.2",
98-
"rollup": "^3.0.0",
100+
"rollup": "^3.1.0",
99101
"rollup-plugin-terser": "^7.0.2",
100102
"styled-components": "^5.3.6",
101103
"typescript": "^4.8.4",

rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import replace from '@rollup/plugin-replace';
44
import { terser } from 'rollup-plugin-terser';
55
import { DEFAULT_EXTENSIONS } from '@babel/core';
66
import typescript from '@rollup/plugin-typescript';
7-
import {createRequire} from 'node:module';
7+
import { createRequire } from 'node:module';
88

99
const require = createRequire(import.meta.url);
1010
const pkg = require('./package.json');

0 commit comments

Comments
 (0)