Skip to content
This repository was archived by the owner on Aug 21, 2022. It is now read-only.

Commit 4e51103

Browse files
committed
➕ (lint) add prettier
1 parent 56fc6e2 commit 4e51103

File tree

12 files changed

+91
-37
lines changed

12 files changed

+91
-37
lines changed

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
package.json
4+
node_modules/**/*
5+
app/javascript/apps/graphql/**/documents.tsx

.prettierrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"printWidth": 80,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"semi": true,
6+
"jsxSingleQuote": true,
7+
"overrides": [
8+
{
9+
"files": ".prettierrc",
10+
"options": {
11+
"parser": "json"
12+
}
13+
}
14+
]
15+
}

app/javascript/apps/application/app.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
import React from "react";
2-
import { Layout, Menu } from "antd";
1+
import { IStyles } from '@/shared';
2+
import { Layout, Menu } from 'antd';
3+
import React from 'react';
34

4-
type IClass = {
5-
[className: string]: React.CSSProperties;
6-
};
7-
8-
const style: IClass = {
5+
const style: IStyles = {
6+
content: {
7+
background: '#fff',
8+
padding: '1rem',
9+
},
10+
footer: {
11+
textAlign: 'center',
12+
},
913
menu: {
10-
lineHeight: "inherit"
14+
lineHeight: 'inherit',
1115
},
1216
page: {
13-
minHeight: "calc(100vh - 64px)",
14-
padding: "1rem"
15-
},
16-
content: {
17-
background: "#fff",
18-
padding: "1rem"
17+
minHeight: 'calc(100vh - 64px)',
18+
padding: '1rem',
1919
},
20-
footer: {
21-
textAlign: "center"
22-
}
2320
};
2421

2522
export default function App(_props: any) {
2623
return (
2724
<Layout>
2825
<Layout.Header>
29-
<Menu style={style.menu} theme="dark" mode="horizontal">
30-
<Menu.Item key="home">Home</Menu.Item>
26+
<Menu style={style.menu} theme='dark' mode='horizontal'>
27+
<Menu.Item key='home'>Home</Menu.Item>
3128
</Menu>
3229
</Layout.Header>
3330
<Layout style={style.page}>

app/javascript/apps/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './interfaces';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
3+
export interface IStyles {
4+
[className: string]: React.CSSProperties;
5+
}

app/javascript/channels/consumer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Action Cable provides the framework to deal with WebSockets in Rails.
22
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
33

4-
import { createConsumer } from "@rails/actioncable"
4+
import { createConsumer } from '@rails/actioncable';
55

6-
export default createConsumer()
6+
export default createConsumer();

app/javascript/channels/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Load all the channels within this directory and all subdirectories.
22
// Channel files must be named *_channel.js.
33

4-
const channels = require.context('.', true, /_channel\.js$/)
5-
channels.keys().forEach(channels)
4+
const channels = require.context('.', true, /_channel\.js$/);
5+
channels.keys().forEach(channels);

app/javascript/packs/application.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
require("@rails/ujs").start()
1+
require('@rails/ujs').start();
22
// require("turbolinks").start()
3-
require("@rails/activestorage").start()
4-
require("channels")
3+
require('@rails/activestorage').start();
4+
require('channels');
55

6-
const componentRequireContext = require.context("apps/application", true);
7-
const ReactRailsUJS = require("react_ujs");
6+
const componentRequireContext = require.context('apps/application', true);
7+
const ReactRailsUJS = require('react_ujs');
88
ReactRailsUJS.useContext(componentRequireContext);

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "payin",
33
"private": true,
4+
"scripts": {
5+
"lint": "prettier --write app/**/*.{tsx,ts,js,gql}",
6+
"lint-check": "prettier --check app/**/*.{tsx,ts,js,gql}"
7+
},
48
"dependencies": {
59
"@babel/preset-react": "^7.8.3",
610
"@rails/actioncable": "^6.0.0",
@@ -25,6 +29,7 @@
2529
},
2630
"version": "0.1.0",
2731
"devDependencies": {
32+
"prettier": "^1.19.1",
2833
"webpack-dev-server": "^3.10.3"
2934
}
3035
}

tsconfig.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2+
"typeRoots": ["app/javascript/apps/types", "./node_modules/@types"],
23
"compilerOptions": {
4+
"rootDir": ".",
35
"allowSyntheticDefaultImports": true,
46
"declaration": false,
57
"emitDecoratorMetadata": true,
68
"experimentalDecorators": true,
7-
"lib": ["es6", "dom"],
8-
"module": "es6",
9+
"lib": ["es6", "dom", "dom.iterable", "esnext"],
10+
"module": "esnext",
911
"moduleResolution": "node",
1012
"sourceMap": true,
1113
"target": "es5",
12-
"jsx": "react"
14+
"jsx": "react",
15+
"baseUrl": ".",
16+
"paths": {
17+
"@/*": ["app/javascript/apps/*"]
18+
}
1319
},
14-
"exclude": [
15-
"**/*.spec.ts",
16-
"node_modules",
17-
"vendor",
18-
"public"
19-
],
20+
"exclude": ["**/*.spec.ts", "node_modules", "vendor", "public"],
2021
"compileOnSave": false
2122
}

0 commit comments

Comments
 (0)