Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2abddd

Browse files
committedNov 20, 2018
Fine tune prettier config
1 parent 4d4856c commit c2abddd

18 files changed

+388
-329
lines changed
 

‎.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
src/async-languages
2+
src/languages
3+
dist
4+
build
5+
coverage
6+
src/styles
7+

‎babel.config.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ module.exports = {
33
'@babel/plugin-proposal-class-properties',
44
'@babel/plugin-proposal-object-rest-spread',
55
'@babel/syntax-dynamic-import',
6-
'@babel/transform-runtime',
6+
'@babel/transform-runtime'
77
],
88
presets: ['@babel/react', '@babel/env'],
99
env: {
1010
cjs: {
11-
plugins: [
12-
'@babel/transform-runtime',
13-
'transform-dynamic-import',
14-
],
15-
presets: [['@babel/env']],
11+
plugins: ['@babel/transform-runtime', 'transform-dynamic-import'],
12+
presets: [['@babel/env']]
1613
},
1714
esm: {
18-
plugins: [
19-
'@babel/transform-runtime',
20-
],
21-
presets: [['@babel/env', {
22-
modules: false
23-
}]],
15+
plugins: ['@babel/transform-runtime'],
16+
presets: [
17+
[
18+
'@babel/env',
19+
{
20+
modules: false
21+
}
22+
]
23+
]
2424
},
2525
test: {
26-
presets: [['@babel/env', { targets: { node: true } } ]],
26+
presets: [['@babel/env', { targets: { node: true } }]],
2727
// There is no @babel/ scoped transform for this plugin
28-
plugins: ['transform-dynamic-import'],
29-
},
30-
},
28+
plugins: ['transform-dynamic-import']
29+
}
30+
}
3131
};

‎demo/diff.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ function itIs() {
1515
return 'no seriously really it is';
1616
}`;
1717

18-
1918
const ADDED = [1, 2];
2019
const REMOVED = [6];
2120

@@ -29,8 +28,8 @@ function DiffHighlight() {
2928
<div>
3029
<h1 style={h1Style}>React SyntaxHighlighter</h1>
3130
<ExamplesLinks />
32-
<div style={{paddingTop: 20, display: 'flex'}}>
33-
<div style={{flex: 1, width: '100%', flexDirection: 'column'}}>
31+
<div style={{ paddingTop: 20, display: 'flex' }}>
32+
<div style={{ flex: 1, width: '100%', flexDirection: 'column' }}>
3433
<SyntaxHighlighter
3534
style={docco}
3635
wrapLines={true}
@@ -39,8 +38,7 @@ function DiffHighlight() {
3938
let style = { display: 'block' };
4039
if (ADDED.includes(lineNumber)) {
4140
style.backgroundColor = '#dbffdb';
42-
}
43-
else if (REMOVED.includes(lineNumber)) {
41+
} else if (REMOVED.includes(lineNumber)) {
4442
style.backgroundColor = '#ffecec';
4543
}
4644
return style;
@@ -49,12 +47,8 @@ function DiffHighlight() {
4947
{CODE}
5048
</SyntaxHighlighter>
5149
<h1 style={h1Style}>The code to make this happen</h1>
52-
<SyntaxHighlighter
53-
style={docco}
54-
wrapLines={true}
55-
>
56-
{
57-
`import React from 'react';
50+
<SyntaxHighlighter style={docco} wrapLines={true}>
51+
{`import React from 'react';
5852
import { render } from 'react-dom';
5953
import SyntaxHighlighter from '../';
6054
import docco from '../styles/docco';
@@ -108,10 +102,8 @@ function DiffHighlight() {
108102
}
109103
110104
render(<DiffHighlight />, document.getElementById('app'));
111-
`
112-
}
105+
`}
113106
</SyntaxHighlighter>
114-
115107
</div>
116108
</div>
117109
</div>

‎demo/examples-links.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ export default () => (
99
<div>
1010
<h1 style={h1Style}>Other examples: </h1>
1111
<ul>
12-
<li><a href="http://localhost:9001/demo">Default</a></li>
13-
<li><a href="http://localhost:9001/demo/diff.html">Diff</a></li>
14-
<li><a href="http://localhost:9001/demo/virtualized.html">Virtualized</a></li>
15-
<li><a href="http://localhost:9001/demo/prism-async-light.html">Prism async light</a></li>
12+
<li>
13+
<a href="http://localhost:9001/demo">Default</a>
14+
</li>
15+
<li>
16+
<a href="http://localhost:9001/demo/diff.html">Diff</a>
17+
</li>
18+
<li>
19+
<a href="http://localhost:9001/demo/virtualized.html">Virtualized</a>
20+
</li>
21+
<li>
22+
<a href="http://localhost:9001/demo/prism-async-light.html">
23+
Prism async light
24+
</a>
25+
</li>
1626
</ul>
1727
</div>
1828
);

‎demo/index.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function createElement({ node, style, useInlineStyles, key }) {
122122
style: require('../styles/hljs/tomorrow-night-eighties').default,
123123
code: initialCodeString,
124124
showLineNumbers: false
125-
}
125+
};
126126
}
127127
render() {
128128
const h1Style = {
@@ -132,7 +132,7 @@ function createElement({ node, style, useInlineStyles, key }) {
132132
const h2 = {
133133
fontSize: 24,
134134
color: 'aliceblue'
135-
}
135+
};
136136

137137
return (
138138
<div>
@@ -141,34 +141,45 @@ function createElement({ node, style, useInlineStyles, key }) {
141141
<h2 style={h2}>Change Style</h2>
142142
<select
143143
value={this.state.selected}
144-
onChange={(e) => this.setState({style: require(`../styles/hljs/${e.target.value}`).default, selected: e.target.value})}
144+
onChange={e =>
145+
this.setState({
146+
style: require(`../styles/hljs/${e.target.value}`).default,
147+
selected: e.target.value
148+
})
149+
}
145150
>
146-
{availableStyles.map(s => <option key={s} value={s}>{s}</option>)}
151+
{availableStyles.map(s => (
152+
<option key={s} value={s}>
153+
{s}
154+
</option>
155+
))}
147156
</select>
148-
<div style={{paddingTop: '10px', fontSize: 16, color: 'aliceblue'}}>
157+
<div style={{ paddingTop: '10px', fontSize: 16, color: 'aliceblue' }}>
149158
<label htmlFor="showLineNumbers">Show Line Numbers:</label>
150159
<input
151160
type="checkbox"
152161
checked={this.state.showLineNumbers}
153-
onChange={() => this.setState({ showLineNumbers: !this.state.showLineNumbers })}
162+
onChange={() =>
163+
this.setState({ showLineNumbers: !this.state.showLineNumbers })
164+
}
154165
id="showLineNumbers"
155166
/>
156167
</div>
157-
<div style={{paddingTop: 20, display: 'flex'}}>
168+
<div style={{ paddingTop: 20, display: 'flex' }}>
158169
<textarea
159-
style={{flex: 1, marginTop: 11}}
170+
style={{ flex: 1, marginTop: 11 }}
160171
rows={40}
161172
cols={100}
162173
value={this.state.code}
163-
onChange={(e) => this.setState({code: e.target.value})}
174+
onChange={e => this.setState({ code: e.target.value })}
164175
/>
165-
<div style={{flex: 1, width: '50%'}}>
176+
<div style={{ flex: 1, width: '50%' }}>
166177
<SyntaxHighlighter
167178
style={this.state.style}
168179
showLineNumbers={this.state.showLineNumbers}
169180
wrapLines={true}
170-
lineProps={(lineNumber) => ({
171-
style: { display: "block", cursor: "pointer" },
181+
lineProps={lineNumber => ({
182+
style: { display: 'block', cursor: 'pointer' },
172183
onClick() {
173184
alert(`Line Number Clicked: ${lineNumber}`);
174185
}
@@ -183,5 +194,4 @@ function createElement({ node, style, useInlineStyles, key }) {
183194
}
184195
}
185196

186-
187197
render(<Component />, document.getElementById('app'));

‎demo/prism-async-light.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ const availableStyles = [
1414
// TODO: Generate list
1515
];
1616

17-
const availableLanguages = [
18-
'text',
19-
'javascript',
20-
'java',
21-
'yaml'
22-
]
17+
const availableLanguages = ['text', 'javascript', 'java', 'yaml'];
2318

2419
class Component extends React.Component {
2520
constructor() {
@@ -72,7 +67,7 @@ function createElement({ node, style, useInlineStyles, key }) {
7267
code: initialCodeString,
7368
showLineNumbers: false,
7469
language: 'javascript'
75-
}
70+
};
7671
}
7772

7873
render() {
@@ -83,7 +78,7 @@ function createElement({ node, style, useInlineStyles, key }) {
8378
const h2 = {
8479
fontSize: 24,
8580
color: 'aliceblue'
86-
}
81+
};
8782

8883
return (
8984
<div>
@@ -103,30 +98,32 @@ function createElement({ node, style, useInlineStyles, key }) {
10398
>
10499
{availableLanguages.map(s => <option key={s} value={s}>{s}</option>)}
105100
</select>*/}
106-
<div style={{paddingTop: '10px', fontSize: 16, color: 'aliceblue'}}>
101+
<div style={{ paddingTop: '10px', fontSize: 16, color: 'aliceblue' }}>
107102
<label htmlFor="showLineNumbers">Show Line Numbers:</label>
108103
<input
109104
type="checkbox"
110105
checked={this.state.showLineNumbers}
111-
onChange={() => this.setState({ showLineNumbers: !this.state.showLineNumbers })}
106+
onChange={() =>
107+
this.setState({ showLineNumbers: !this.state.showLineNumbers })
108+
}
112109
id="showLineNumbers"
113110
/>
114111
</div>
115-
<div style={{paddingTop: 20, display: 'flex'}}>
112+
<div style={{ paddingTop: 20, display: 'flex' }}>
116113
<textarea
117-
style={{flex: 1, marginTop: 11}}
114+
style={{ flex: 1, marginTop: 11 }}
118115
rows={40}
119116
cols={100}
120117
value={this.state.code}
121-
onChange={(e) => this.setState({code: e.target.value})}
118+
onChange={e => this.setState({ code: e.target.value })}
122119
/>
123-
<div style={{flex: 1, width: '50%'}}>
120+
<div style={{ flex: 1, width: '50%' }}>
124121
<SyntaxHighlighter
125122
style={this.state.style}
126123
showLineNumbers={this.state.showLineNumbers}
127124
wrapLines={true}
128-
lineProps={(lineNumber) => ({
129-
style: { display: "block", cursor: "pointer" },
125+
lineProps={lineNumber => ({
126+
style: { display: 'block', cursor: 'pointer' },
130127
onClick() {
131128
alert(`Line Number Clicked: ${lineNumber}`);
132129
}
@@ -142,5 +139,4 @@ function createElement({ node, style, useInlineStyles, key }) {
142139
}
143140
}
144141

145-
146142
render(<Component />, document.getElementById('app'));

‎demo/virtualized.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function createElement({ node, style, useInlineStyles, key }) {
292292
showLineNumbers: false,
293293
width: window.innerWidth,
294294
height: window.innerHeight
295-
}
295+
};
296296
}
297297
render() {
298298
const h1Style = {
@@ -302,25 +302,27 @@ function createElement({ node, style, useInlineStyles, key }) {
302302
const h2 = {
303303
fontSize: 24,
304304
color: 'aliceblue'
305-
}
305+
};
306306

307307
return (
308-
<div style={{ height: "100vh" }}>
308+
<div style={{ height: '100vh' }}>
309309
<h1 style={h1Style}>React Syntax Highlighter Virtualized</h1>
310-
<ExamplesLinks />
311-
<SyntaxHighlighter
312-
customStyle={{ height: "100vh" }}
313-
style={this.state.style}
314-
showLineNumbers={this.state.showLineNumbers}
315-
renderer={renderer({ height: this.state.height, width: this.state.width })}
316-
codeTagProps={{ style: { height: "100vh" }}}
317-
>
318-
{this.state.code}
319-
</SyntaxHighlighter>
310+
<ExamplesLinks />
311+
<SyntaxHighlighter
312+
customStyle={{ height: '100vh' }}
313+
style={this.state.style}
314+
showLineNumbers={this.state.showLineNumbers}
315+
renderer={renderer({
316+
height: this.state.height,
317+
width: this.state.width
318+
})}
319+
codeTagProps={{ style: { height: '100vh' } }}
320+
>
321+
{this.state.code}
322+
</SyntaxHighlighter>
320323
</div>
321324
);
322325
}
323326
}
324327

325-
326328
render(<Component />, document.getElementById('app'));

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"test": "jest",
6666
"test-ci": "jest && codecov",
6767
"publish-coverage": "codecov",
68-
"format": "prettier --write --no-editorconfig src/**/*.js lib/**/*.js __tests__/**/*.js"
68+
"format": "prettier --write --no-editorconfig \"**/*.js\""
6969
},
7070
"repository": {
7171
"type": "git",

0 commit comments

Comments
 (0)
Please sign in to comment.