Skip to content

Commit b8d0b28

Browse files
authored
Merge pull request #69 from jonmbake/workflow-updates
Setup linting; update workflow for main branch rename
2 parents 164477f + 2d0a23d commit b8d0b28

File tree

11 files changed

+2515
-246
lines changed

11 files changed

+2515
-246
lines changed
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- 'master'
7+
- 'main'
88

99
jobs:
1010
build:
@@ -15,13 +15,16 @@ jobs:
1515
uses: actions/checkout@v2
1616

1717
- name: Set up Node.js
18-
uses: actions/setup-node@master
18+
uses: actions/setup-node@v6
1919
with:
2020
node-version: 18.4.0
2121

2222
- name: Install dependencies
2323
run: npm install && npm run install-peers
2424

25+
- name: Lint
26+
run: npm run lint
27+
2528
- name: Run tests
2629
run: npm test
2730

@@ -34,15 +37,15 @@ jobs:
3437
run: npm run build
3538

3639
- name: Copy type definition to docs
37-
if: github.ref_name == 'master'
40+
if: github.ref_name == 'main'
3841
run: cp ./build/index.d.ts ./docs/
3942

4043
- name: Perform CodeQL analysis
4144
uses: github/codeql-action/analyze@v2
4245

4346
- name: Publish github pages docs
4447
uses: peaceiris/actions-gh-pages@v3
45-
if: github.ref_name == 'master'
48+
if: github.ref_name == 'main'
4649
with:
4750
github_token: ${{ secrets.GITHUB_TOKEN }}
4851
publish_dir: ./docs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ A terminal [React](https://github.com/facebook/react) component with support for
88

99
Check out the **[Demo](https://jonmbake.github.io/react-terminal-ui/demo/)** :heart_eyes:
1010

11-
![React Terminal UI Demo Dark](https://github.com/jonmbake/screenshots/raw/master/react-terminal-ui/react-terminal-ui-demo-dark.png)
11+
![React Terminal UI Demo Dark](https://github.com/jonmbake/screenshots/raw/main/react-terminal-ui/react-terminal-ui-demo-dark.png)
1212

13-
![React Terminal UI Demo Light](https://github.com/jonmbake/screenshots/raw/master/react-terminal-ui/react-terminal-ui-demo-light.png)
13+
![React Terminal UI Demo Light](https://github.com/jonmbake/screenshots/raw/main/react-terminal-ui/react-terminal-ui-demo-light.png)
1414

1515
## Installation
1616

demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</head>
1111
<body>
1212
<div id="terminal"></div>
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js" integrity="sha512-SUJujhtUWZUlwsABaZNnTFRlvCu7XGBZBL1VF33qRvvgNk3pBS9E353kcag4JAv05/nsB9sanSXFbdHAUW9+lg==" crossorigin="anonymous"></script>
14-
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js" integrity="sha512-SYsXmAblZhruCNUVmTp5/v2a1Fnoia06iJh3+L9B9wUaqpRVjcNBQsqAglQG9b5+IaVCfLDH5+vW923JL5epZA==" crossorigin="anonymous"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js" integrity="sha512-8Q6Y9XnTbOE+JNvjBQwJ2H8S+UV4uA6hiRykhdtIyDYZ2TprdNmWOUaKdGzOhyr4dCyk287OejbPvwl7lrfqrQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
14+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" integrity="sha512-MOCpqoRoisCTwJ8vQQiciZv0qcpROCidek3GTFS6KTk2+y7munJIlKCVkFCYY+p3ErYFXCjmFjnfTTRSC1OHWQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
1515
<script src="index.js"></script>
1616
</body>
1717
</html>

demo/index.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import React, { useState, MouseEvent } from 'react'
2-
import ReactDOM from 'react-dom';
2+
import { createRoot } from 'react-dom/client';
33
import Terminal, { ColorMode, TerminalInput, TerminalOutput } from '../src/index';
44

55
import './style.css';
66

7-
const TerminalController = (props = {}) => {
7+
const TerminalController = () => {
88
const [isPasswordMode, setIsPasswordMode] = useState<boolean>(false);
99
const [colorMode, setColorMode] = useState(ColorMode.Dark);
1010
const [lineData, setLineData] = useState([
11-
<TerminalOutput>Welcome to the React Terminal UI Demo!&#128075;</TerminalOutput>,
12-
<TerminalOutput></TerminalOutput>,
13-
<TerminalOutput>The following example commands are provided:</TerminalOutput>,
14-
<TerminalOutput>'view-source' will navigate to the React Terminal UI github source.</TerminalOutput>,
15-
<TerminalOutput>'view-react-docs' will navigate to the react docs.</TerminalOutput>,
16-
<TerminalOutput>'login' will show input password with "*" instead of real string</TerminalOutput>,
17-
<TerminalOutput>'clear' will clear the terminal.</TerminalOutput>,
11+
<TerminalOutput key="welcome">Welcome to the React Terminal UI Demo!&#128075;</TerminalOutput>,
12+
<TerminalOutput key="empty"></TerminalOutput>,
13+
<TerminalOutput key="commands">The following example commands are provided:</TerminalOutput>,
14+
<TerminalOutput key="view-source">&apos;view-source&apos; will navigate to the React Terminal UI github source.</TerminalOutput>,
15+
<TerminalOutput key="view-react">&apos;view-react-docs&apos; will navigate to the react docs.</TerminalOutput>,
16+
<TerminalOutput key="login">&apos;login&apos; will show input password with &quot;*&quot; instead of real string</TerminalOutput>,
17+
<TerminalOutput key="clear">&apos;clear&apos; will clear the terminal.</TerminalOutput>,
1818
]);
1919

2020
function toggleColorMode(e: MouseEvent) {
@@ -85,9 +85,10 @@ const TerminalController = (props = {}) => {
8585
)
8686
};
8787

88-
ReactDOM.render(
88+
const container = document.getElementById('terminal')!;
89+
const root = createRoot(container);
90+
root.render(
8991
<React.StrictMode>
9092
<TerminalController />
91-
</React.StrictMode>,
92-
document.getElementById('terminal')
93+
</React.StrictMode>
9394
);

eslint.config.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import js from '@eslint/js';
2+
import tseslint from '@typescript-eslint/eslint-plugin';
3+
import tsparser from '@typescript-eslint/parser';
4+
import react from 'eslint-plugin-react';
5+
import reactHooks from 'eslint-plugin-react-hooks';
6+
7+
export default [
8+
js.configs.recommended,
9+
{
10+
files: ['**/*.{ts,tsx}'],
11+
languageOptions: {
12+
parser: tsparser,
13+
parserOptions: {
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
ecmaVersion: 'latest',
18+
sourceType: 'module',
19+
},
20+
globals: {
21+
window: 'readonly',
22+
document: 'readonly',
23+
console: 'readonly',
24+
setTimeout: 'readonly',
25+
clearTimeout: 'readonly',
26+
localStorage: 'readonly',
27+
HTMLDivElement: 'readonly',
28+
HTMLInputElement: 'readonly',
29+
HTMLElement: 'readonly',
30+
Element: 'readonly',
31+
EventListenerOrEventListenerObject: 'readonly',
32+
},
33+
},
34+
plugins: {
35+
'@typescript-eslint': tseslint,
36+
react,
37+
'react-hooks': reactHooks,
38+
},
39+
rules: {
40+
...tseslint.configs.recommended.rules,
41+
...react.configs.recommended.rules,
42+
...reactHooks.configs.recommended.rules,
43+
'react/react-in-jsx-scope': 'off',
44+
'no-undef': 'off', // TypeScript handles this
45+
'@typescript-eslint/no-unused-vars': 'warn',
46+
'react/jsx-key': 'warn',
47+
'react/no-unescaped-entities': 'warn',
48+
'react/no-deprecated': 'warn',
49+
'react-hooks/exhaustive-deps': 'warn',
50+
},
51+
settings: {
52+
react: {
53+
version: 'detect',
54+
},
55+
},
56+
},
57+
{
58+
files: ['tests/**/*.{ts,tsx}'],
59+
languageOptions: {
60+
globals: {
61+
jest: 'readonly',
62+
describe: 'readonly',
63+
test: 'readonly',
64+
expect: 'readonly',
65+
beforeEach: 'readonly',
66+
beforeAll: 'readonly',
67+
afterEach: 'readonly',
68+
afterAll: 'readonly',
69+
it: 'readonly',
70+
},
71+
},
72+
},
73+
];

0 commit comments

Comments
 (0)