lint fixes
parent
fcb9cb0f69
commit
971da5f8c1
|
@ -24,9 +24,18 @@ rules:
|
|||
prefer-arrow-callback: error
|
||||
prefer-const: error
|
||||
react/no-deprecated: off
|
||||
react/prop-types: off
|
||||
strict: error
|
||||
symbol-description: error
|
||||
yoda:
|
||||
- error
|
||||
- never
|
||||
- exceptRange: true
|
||||
overrides:
|
||||
- files:
|
||||
- website/playground/**
|
||||
env:
|
||||
es6: true
|
||||
browser: true
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
|
|
|
@ -10,7 +10,6 @@ import formatMarkdown from "./markdown";
|
|||
|
||||
import { Sidebar, SidebarCategory } from "./sidebar/components";
|
||||
import SidebarOptions from "./sidebar/SidebarOptions";
|
||||
import Option from "./sidebar/options";
|
||||
import { Checkbox } from "./sidebar/inputs";
|
||||
|
||||
const CATEGORIES_ORDER = ["Global", "JavaScript", "Markdown", "Special"];
|
||||
|
@ -68,14 +67,14 @@ class Playground extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { availableOptions } = this.props;
|
||||
const { availableOptions, worker } = this.props;
|
||||
const { content, options } = this.state;
|
||||
|
||||
return (
|
||||
<EditorState>
|
||||
{editorState => (
|
||||
<PrettierFormat
|
||||
worker={this.props.worker}
|
||||
worker={worker}
|
||||
code={content}
|
||||
options={options}
|
||||
debugAst={editorState.showAst}
|
||||
|
@ -150,7 +149,7 @@ class Playground extends React.Component {
|
|||
<Button onClick={this.clearContent}>Clear</Button>
|
||||
</div>
|
||||
<div className="bottom-bar-buttons bottom-bar-buttons-right">
|
||||
<ClipboardButton copy={() => window.location.href}>
|
||||
<ClipboardButton copy={window.location.href}>
|
||||
Copy link
|
||||
</ClipboardButton>
|
||||
<ClipboardButton
|
||||
|
@ -188,7 +187,7 @@ function getCliOptions(availableOptions, options) {
|
|||
const cliOptions = [];
|
||||
for (let i = 0; i < availableOptions.length; i++) {
|
||||
const option = availableOptions[i];
|
||||
let value = options[option.name];
|
||||
const value = options[option.name];
|
||||
|
||||
if (option.type === "boolean") {
|
||||
if ((value && !option.inverted) || (!value && option.inverted)) {
|
||||
|
|
|
@ -7,7 +7,7 @@ function getFormatProps(props) {
|
|||
return { code, options, debugAst, debugDoc, secondFormat };
|
||||
}
|
||||
|
||||
export default class extends React.Component {
|
||||
export default class PrettierFormat extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = { formatted: "" };
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
export default function(source) {
|
||||
const worker = new Worker(source);
|
||||
let counter = 0;
|
||||
let handlers = {};
|
||||
const handlers = {};
|
||||
|
||||
worker.addEventListener("message", event => {
|
||||
const { uid, message, error } = event.data;
|
||||
|
||||
if (!handlers[uid]) return;
|
||||
if (!handlers[uid]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [resolve, reject] = handlers[uid];
|
||||
delete handlers[uid];
|
||||
|
|
|
@ -30,7 +30,9 @@ export class ClipboardButton extends React.Component {
|
|||
|
||||
showTooltip(text) {
|
||||
this.setState({ showTooltip: true, tooltipText: text }, () => {
|
||||
if (this.timer) clearTimeout(this.timer);
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
this.timer = setTimeout(() => {
|
||||
this.timer = null;
|
||||
this.setState({ showTooltip: false });
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export function stateToggler(key) {
|
||||
return state => ({ [key]: !Boolean(state[key]) });
|
||||
return state => ({ [key]: !state[key] });
|
||||
}
|
||||
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
@ -10,14 +10,15 @@ function is(x, y) {
|
|||
// Steps 1-5, 7-10
|
||||
// Steps 6.b-6.e: +0 != -0
|
||||
return x !== 0 || 1 / x === 1 / y;
|
||||
} else {
|
||||
// Step 6.a: NaN == NaN
|
||||
return x !== x && y !== y;
|
||||
}
|
||||
// Step 6.a: NaN == NaN
|
||||
return x !== x && y !== y;
|
||||
}
|
||||
|
||||
export function shallowEqual(objA, objB) {
|
||||
if (is(objA, objB)) return true;
|
||||
if (is(objA, objB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof objA !== "object" ||
|
||||
|
@ -31,7 +32,9 @@ export function shallowEqual(objA, objB) {
|
|||
const keysA = Object.keys(objA);
|
||||
const keysB = Object.keys(objB);
|
||||
|
||||
if (keysA.length !== keysB.length) return false;
|
||||
if (keysA.length !== keysB.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (
|
||||
|
|
|
@ -45,7 +45,9 @@ class App extends React.Component {
|
|||
render() {
|
||||
const { loaded, availableOptions, version } = this.state;
|
||||
|
||||
if (!loaded) return "Loading...";
|
||||
if (!loaded) {
|
||||
return "Loading...";
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -69,7 +71,9 @@ function parsePrettierOptions(supportInfo) {
|
|||
}, {});
|
||||
|
||||
return ENABLED_OPTIONS.reduce((optionsList, optionConfig) => {
|
||||
if (!supportedOptions[optionConfig.name]) return optionsList;
|
||||
if (!supportedOptions[optionConfig.name]) {
|
||||
return optionsList;
|
||||
}
|
||||
|
||||
const option = Object.assign(
|
||||
{},
|
||||
|
|
|
@ -55,13 +55,13 @@ function formatCLIOptions(cliOptions) {
|
|||
}
|
||||
|
||||
function codeBlock(content, syntax) {
|
||||
var backtickSequences = content.match(/`+/g) || [];
|
||||
var longestBacktickSequenceLength = Math.max.apply(
|
||||
const backtickSequences = content.match(/`+/g) || [];
|
||||
const longestBacktickSequenceLength = Math.max.apply(
|
||||
null,
|
||||
backtickSequences.map(backticks => backticks.length)
|
||||
);
|
||||
var fenceLength = Math.max(3, longestBacktickSequenceLength + 1);
|
||||
var fence = Array(fenceLength + 1).join("`");
|
||||
const fenceLength = Math.max(3, longestBacktickSequenceLength + 1);
|
||||
const fence = Array(fenceLength + 1).join("`");
|
||||
return [fence + (syntax || ""), content, fence].join("\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue