Skip to content

Commit

Permalink
Merge pull request firefox-devtools#402 from julienw/prettier
Browse files Browse the repository at this point in the history
Add prettier to our codebase
  • Loading branch information
julienw authored Jun 30, 2017
2 parents 578f02d + 02eea79 commit 5a6887d
Show file tree
Hide file tree
Showing 142 changed files with 6,334 additions and 3,352 deletions.
182 changes: 77 additions & 105 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,111 +1,83 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended",
"prettier",
"prettier/flowtype",
"prettier/react"
],
"parserOptions": {
"ecmaVersion": "2017",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"parser": "babel-eslint",
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react",
"flowtype",
"import"
],
"rules": {
// Flow type rules:
"flowtype/define-flow-type": 1,
"flowtype/use-flow-type": 1,
"flowtype/generic-spacing": [2, "never"],
"flowtype/space-before-type-colon": [ 2, "never" ],
"flowtype/space-after-type-colon": [ 2, "always" ],
"flowtype/delimiter-dangle": [ 2, "always-multiline" ],
"sourceType": "module"
},
"plugins": [
"react",
"flowtype",
"import",
"prettier"
],
"rules": {
// ES6 Import rules:
"import/no-duplicates": "error",
"import/no-unresolved": "error",
"import/named": "error",
"prettier/prettier": ["error", { singleQuote: true, trailingComma: "es5" }],

// ES6 Import rules:
"import/no-duplicates": "error",
"import/no-unresolved": "error",
"import/named": "error",
// overriding recommended rules
"no-constant-condition": ["error", { checkLoops: false }],
"no-console": [ "error", { allow: ["log", "warn", "error"] } ],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],

// JS Rules:
"indent": [
"error",
2,
{ "SwitchCase": 1 }
],
"linebreak-style": [ "error", "unix" ],
"quotes": [ "error", "single", { "avoidEscape": true } ],
"semi": [ "error", "always" ],
"no-extra-semi": "error",
"comma-dangle": [ "error", "always-multiline" ],
"no-console": [ "error", { allow: ["log", "warn", "error"] } ],
"eqeqeq": "error",
"consistent-return": "error",
"curly": ["error", "all" ],
"dot-location": ["error", "property"],
"dot-notation": "error",
"no-alert": "error",
"no-caller": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-else-return": "error",
"no-eval": "error",
"no-implied-eval": "error",
"no-extend-native": "error",
"no-native-reassign": "error",
"no-extra-bind": "error",
"no-labels": "error",
"no-implicit-globals": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-spaces": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-void": "error",
"no-with": "error",
"radix": "error",
"yoda": ["error", "never", { "exceptRange": true }],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"camelcase": "error",
"comma-spacing": "error",
"comma-style": "error",
"jsx-quotes": ["error", "prefer-single"],
"key-spacing": "error",
"keyword-spacing": "error",
"no-new-object": "error",
"no-spaced-func": "error",
"semi-spacing": "error",
"space-in-parens": ["error", "never"],
"spaced-comment": "error",
"generator-star-spacing": "error",
"no-var": "error",
"prefer-const": "error",
"array-bracket-spacing": "error",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always",
}],
"arrow-parens": ["error", "as-needed"],
},
"settings": {
"react": {
"pragma": "React",
"version": "15.0"
}
// possible errors
"array-callback-return": "error",
"consistent-return": "error",
// "default-case": "error", // to be enabled after fixing issues in our code
"dot-notation": "error",
"eqeqeq": "error",
// "for-direction": "error", // to be enabled after we upgrade eslint
"no-alert": "error",
"no-caller": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
// "no-unused-expression": "error", // to be enabled after we upgrade eslint
// "no-use-before-define": "error", // to be enabled after fixing issues in our code
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-with": "error",
"prefer-const": "error",
// "prefer-promise-reject-errors": "error", // to be enabled after fixing issues in our code
// "prefer-rest-params": "error", // to be enabled after fixing issues in our code
"prefer-spread": "error",
},
"settings": {
"react": {
"pragma": "React",
"version": "15.0"
}
}
};
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test:
pre:
- yarn license-check
override:
- yarn eslint
- yarn lint
- yarn flow -- --quiet
- yarn test -- --coverage --runInBand
- yarn build:quiet
Expand Down
55 changes: 29 additions & 26 deletions flow-typed/overrides/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,57 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type {
// eslint-disable-next-line import/named
IDBFactory,
} from '../../src/types/indexeddb';
import type { IDBFactory } from '../../src/types/indexeddb';

type Lib = { debugName: string };

declare class SymbolTable {
constructor(): SymbolTable;
getFuncAddressTableForLib(lib: Lib): Promise<Uint32Array>;
constructor(): SymbolTable,
getFuncAddressTableForLib(lib: Lib): Promise<Uint32Array>,
getSymbolsForAddressesInLib(
requestedAddressesIndices: number[],
lib: Lib
): Promise<string[]>;
): Promise<string[]>,
}

declare class GeckoProfiler {
getProfile: () => Object;
getSymbolTable: (debugName: string, breakpadId: string) => Promise<SymbolTable>;
getProfile: () => Object,
getSymbolTable: (
debugName: string,
breakpadId: string
) => Promise<SymbolTable>,
}

declare class Window extends EventTarget {
// perf.html and Gecko Profiler Addon
geckoProfilerPromise: Promise<GeckoProfiler>;
geckoProfilerAddonInstalled?: () => void;
isGeckoProfilerAddonInstalled?: boolean;
geckoProfilerPromise: Promise<GeckoProfiler>,
geckoProfilerAddonInstalled?: () => void,
isGeckoProfilerAddonInstalled?: boolean,
legacyRangeFilters: Array<{
start: number,
end: number,
}>;
}>,
InstallTrigger?: {
install: Object => {},
};
},

// Built-ins.
getComputedStyle: (element: HTMLElement, pseudoEl: ?string) => CSSStyleDeclaration,
getComputedStyle: (
element: HTMLElement,
pseudoEl: ?string
) => CSSStyleDeclaration,
DOMRect: typeof DOMRect,
requestIdleCallback: typeof requestIdleCallback;
requestAnimationFrame: typeof requestAnimationFrame;
devicePixelRatio: number;
indexedDB: IDBFactory;
IDBKeyRange: IDBKeyRange;
innerWidth: number;
innerHeight: number;
location: Location;
history: History;
Worker: typeof Worker;
WheelEvent: WheelEvent;
requestIdleCallback: typeof requestIdleCallback,
requestAnimationFrame: typeof requestAnimationFrame,
devicePixelRatio: number,
indexedDB: IDBFactory,
IDBKeyRange: IDBKeyRange,
innerWidth: number,
innerHeight: number,
location: Location,
history: History,
Worker: typeof Worker,
WheelEvent: WheelEvent,
}

declare var window: Window;
24 changes: 19 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
"build-prod": "yarn run build:clean && NODE_ENV=production webpack -p --progress",
"build-prod-readable": "yarn run build:clean && NODE_ENV=production webpack --progress",
"build-docs": "documentation build src/types/profile.js -f md > docs/processed-profile-format.md; cat docs/processed-profile-format.md",
"eslint": "eslint index.js src",
"eslint-fix": "eslint --fix index.js src",
"lint": "eslint *.js src",
"lint-fix": "yarn lint -- --fix",
"flow": "flow",
"flow-coverage": "flow-coverage-report -i 'src/**/*.js' -t html -t text",
"flow-generate-libdefs": "flow-typed install",
"license-check": "devtools-license-check",
"precommit": "lint-staged",
"prepush": "run-p flow license-check lint test",
"publish": "rimraf public_html && cp -r dist public_html",
"serve-static": "ws -d dist/ -s index.html -p 4242",
"start": "mkdir -p dist && cp res/zee-worker.js dist/ && NODE_ENV=development node server.js",
Expand Down Expand Up @@ -46,11 +48,11 @@
"prop-types": "^15.5.10",
"query-string": "^4.2.3",
"react": "^15.6.1",
"react-transition-group": "^1.2.0",
"react-addons-perf": "^15.4.2",
"react-contextmenu": "^2.6.3",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"react-transition-group": "^1.2.0",
"redux": "^3.7.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
Expand Down Expand Up @@ -98,8 +100,10 @@
"devtools-license-check": "^0.2.0",
"eslint": "^3.10.2",
"eslint-config-google": "^0.6.0",
"eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-import": "^2.2.0",
"eslint-config-prettier": "^2.2.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-react": "^6.4.0",
"express": "^4.15.3",
"fake-indexeddb": "^1.0.12",
Expand All @@ -109,11 +113,15 @@
"flow-typed": "^2.0.0",
"html-webpack-plugin": "^2.24.1",
"http-server": "^0.9.0",
"husky": "^0.14.1",
"jest": "^20.0.3",
"json-loader": "^0.5.4",
"lint-staged": "^4.0.0",
"local-web-server": "^1.2.6",
"lodash.clonedeep": "^4.5.0",
"mkdirp": "^0.5.1",
"npm-run-all": "^4.0.2",
"prettier": "^1.5.1",
"raw-loader": "^0.5.1",
"react-test-renderer": "^15.6.1",
"rimraf": "^2.5.4",
Expand Down Expand Up @@ -142,5 +150,11 @@
},
"setupTestFrameworkScriptFile": "./src/test/setup.js",
"verbose": true
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
}
}
6 changes: 4 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ new WebpackDevServer(webpack(config), {
stats: {
colors: true,
},
}).listen(port, 'localhost', function (err) {
}).listen(port, 'localhost', function(err) {
if (err) {
console.log(err);
}

console.log(`Listening at localhost:${port}`);
if (port === 4242) {
console.log('You can change this default port with the environment variable PERFHTML_PORT.');
console.log(
'You can change this default port with the environment variable PERFHTML_PORT.'
);
}
});
2 changes: 1 addition & 1 deletion src/actions/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function iconStartLoading(icon: string): ThunkAction<Promise<void>> {
dispatch(iconIsInError(icon));
break;
case 'cached':
// nothing to do
// nothing to do
}
});
};
Expand Down
10 changes: 9 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ import * as profileView from './profile-view';
import * as receiveProfile from './receive-profile';
import * as timeline from './timeline';

export default Object.assign({}, app, icons, profileSummary, profileView, receiveProfile, timeline);
export default Object.assign(
{},
app,
icons,
profileSummary,
profileView,
receiveProfile,
timeline
);
Loading

0 comments on commit 5a6887d

Please sign in to comment.