Skip to content

Commit

Permalink
chore: use prettier for consistent code formatting #92 (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadayosi authored Feb 10, 2023
1 parent 1aeca8d commit 1e1be02
Show file tree
Hide file tree
Showing 92 changed files with 949 additions and 901 deletions.
26 changes: 12 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,35 @@ module.exports = {
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:testing-library/react',
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'import',
],
plugins: ['@typescript-eslint', 'import'],
rules: {
'semi': ['error', 'never'],
semi: ['error', 'never'],
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{
accessibility: 'no-public'
}
accessibility: 'no-public',
},
],
'@typescript-eslint/no-empty-function': [
'error',
{
'allow': ['constructors']
}
allow: ['constructors'],
},
],
'@typescript-eslint/no-redeclare': 'off',
'import/no-default-export': 'error',
'react/prop-types': 'off',
'testing-library/no-debugging-utils': [
'warn',
{
'utilsToCheckFor': {
'debug': false,
}
}
]
utilsToCheckFor: {
debug: false,
},
},
],
},
root: true,
}
44 changes: 22 additions & 22 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
reviewers:
- tadayosi
- phantomjinx
- mmelko
- joshiraez
- jsolovjo
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
reviewers:
- tadayosi
- phantomjinx
- mmelko
- joshiraez
- jsolovjo
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
open-pull-requests-limit: 10
reviewers:
- tadayosi
- phantomjinx
- mmelko
- joshiraez
- jsolovjo
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 10
reviewers:
- tadayosi
- phantomjinx
- mmelko
- joshiraez
- jsolovjo
10 changes: 8 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
branches:
- main
paths-ignore:
- "**.md"
- '**.md'
push:
branches:
- main
paths-ignore:
- "**.md"
- '**.md'

jobs:
lint:
Expand All @@ -37,6 +37,12 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
id: install
run: yarn install
- name: Format check
id: format-check
run: yarn format:check
- name: Lint
id: lint
if: steps.install.outcome == 'success'
run: yarn lint --max-warnings=0
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ on:
branches:
- main
paths-ignore:
- "**.md"
- '**.md'
push:
branches:
- main
paths-ignore:
- "**.md"
- '**.md'

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14', '16', '18' ]
node: ['14', '16', '18']
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
coverage
dist
.yarn
10 changes: 10 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
printWidth: 120,
semi: false,
singleQuote: true,
jsxSingleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
bracketSameLine: false,
arrowParens: 'avoid',
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ You need to have installed the following tools before developing the project.

#### Minimum Version of Yarn is 3.4.1

The default installation version of yarn on many operating systems is *1.22-19* (the classic version). This causes a problem as the development app downloads the `@hawtio/react` package rather than using
the project directory. As a result, the mandated minimum version has been set to *3.4.1*.
The default installation version of yarn on many operating systems is _1.22-19_ (the classic version). This causes a problem as the development app downloads the `@hawtio/react` package rather than using
the project directory. As a result, the mandated minimum version has been set to _3.4.1_.

If `yarn install` is attempted with a version lower than _3.4.1_ then an error message is displayed, eg.

If `yarn install` is attempted with a version lower than *3.4.1* then an error message is displayed, eg.
> $ /usr/bin/yarn install
> yarn install v1.22.19
> [1/5] Validating package.json...
> error @hawtio/next-root@0.0.0: The engine "yarn" is incompatible with this module. Expected version ">=3.4.1". Got "1.22.19"
> error Found incompatible module.
To upgrade such a version to 3.4.1, use yarn's own `set-version` command:

> yarn set version 3.4.1
This will download the 3.4.1 internals to `hawtio-next/.yarn` which are then deferred to by the installed yarn binary.
Expand Down
42 changes: 17 additions & 25 deletions app/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ module.exports = {
ignoreWarnings: [
// For suppressing sourcemap warnings coming from superstruct
function ignoreSourcemapsloaderWarnings(warning) {
return warning.module
&& warning.module.resource.includes('node_modules')
&& warning.details
&& warning.details.includes('source-map-loader')
return (
warning.module &&
warning.module.resource.includes('node_modules') &&
warning.details &&
warning.details.includes('source-map-loader')
)
},
],
},
Expand All @@ -22,17 +24,14 @@ module.exports = {
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/src/hawtio/test/',
'<rootDir>/src/hawtio/.*/ignore/.*'
'<rootDir>/src/hawtio/.*/ignore/.*',
],

moduleDirectories: [
'<rootDir>/node_modules/',
'<rootDir>/src/hawtio/test/'
],
moduleDirectories: ['<rootDir>/node_modules/', '<rootDir>/src/hawtio/test/'],

moduleNameMapper: {
['@hawtio/(.*)']: '<rootDir>/src/hawtio/$1',
'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js'
'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js',
},

// The path to a module that runs some code to configure or set up the testing framework before each test
Expand All @@ -41,33 +40,26 @@ module.exports = {
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/src/hawtio/test/',
'<rootDir>/src/hawtio/.*/ignore/.*'
'<rootDir>/src/hawtio/.*/ignore/.*',
],

transformIgnorePatterns: [
'node_modules/(?!@patternfly/react-icons/dist/esm/icons)/'
],
transformIgnorePatterns: ['node_modules/(?!@patternfly/react-icons/dist/esm/icons)/'],

coveragePathIgnorePatterns: [
'node_modules/',
'src/examples/',
'src/index.tsx',
'src/reportWebVitals.ts',
],
}
coveragePathIgnorePatterns: ['node_modules/', 'src/examples/', 'src/index.tsx', 'src/reportWebVitals.ts'],
},
},
devServer: {
setupMiddlewares: (middlewares) => {
setupMiddlewares: middlewares => {
middlewares.push({
name: 'hawtio-backend',
path: '/proxy',
middleware: hawtioBackend({
// Uncomment it if you want to see debug log for Hawtio backend
logLevel: 'debug',
})
}),
})

return middlewares
}
}
},
},
}
36 changes: 17 additions & 19 deletions app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<base href="%PUBLIC_URL%/" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
<head>
<meta charset="utf-8" />
<base href="%PUBLIC_URL%/" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -23,12 +22,11 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Hawtio.next dev</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
<title>Hawtio.next dev</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
7 changes: 4 additions & 3 deletions app/src/examples/example1/Example1.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core'
import React from 'react'

export const Example1: React.FunctionComponent = () =>
export const Example1: React.FunctionComponent = () => (
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Example 1</Text>
<Text component="p">This is an example plugin.</Text>
<Text component='h1'>Example 1</Text>
<Text component='p'>This is an example plugin.</Text>
</TextContent>
</PageSection>
)
3 changes: 1 addition & 2 deletions app/src/examples/example1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { hawtio } from '@hawtio/react'
import { Example1 } from './Example1'

Expand All @@ -8,6 +7,6 @@ export const registerExample1 = () => {
title: 'Example 1',
path: '/example1',
component: Example1,
isActive: async () => true
isActive: async () => true,
})
}
7 changes: 4 additions & 3 deletions app/src/examples/example2/Example2.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core'
import React from 'react'

export const Example2: React.FunctionComponent = () =>
export const Example2: React.FunctionComponent = () => (
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Example 2</Text>
<Text component="p">This is another example plugin.</Text>
<Text component='h1'>Example 2</Text>
<Text component='p'>This is another example plugin.</Text>
</TextContent>
</PageSection>
)
3 changes: 1 addition & 2 deletions app/src/examples/example2/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { hawtio } from '@hawtio/react'
import { Example2 } from './Example2'

Expand All @@ -8,6 +7,6 @@ export const registerExample2 = () => {
title: 'Example 2',
path: '/example2',
component: Example2,
isActive: async () => true
isActive: async () => true,
})
}
8 changes: 4 additions & 4 deletions app/src/examples/example3/Example3.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core'
import React from 'react'


export const Example3: React.FunctionComponent = () =>
export const Example3: React.FunctionComponent = () => (
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Example 3</Text>
<Text component="p">This is yet another example plugin.</Text>
<Text component='h1'>Example 3</Text>
<Text component='p'>This is yet another example plugin.</Text>
</TextContent>
</PageSection>
)
2 changes: 1 addition & 1 deletion app/src/examples/example3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const registerExample3 = () => {
title: 'Example 3',
path: '/example3',
component: Example3,
isActive: async () => true
isActive: async () => true,
})
}
Loading

0 comments on commit 1e1be02

Please sign in to comment.