Merge pull request #1037 from Mardak/eslint-autofix

chore(lint): Enable and autofix various eslint rules using the prevaling style.
This commit is contained in:
Ed Lee 2016-08-09 10:01:18 -07:00 коммит произвёл GitHub
Родитель b5ad7a78ed 39e6cd4245
Коммит 78c4d84240
58 изменённых файлов: 128 добавлений и 159 удалений

Просмотреть файл

@ -30,9 +30,13 @@
"mozilla/import-globals-from": 1,
"mozilla/this-top-level-scope": 1,
"react/jsx-boolean-value": [2, "always"],
"react/jsx-closing-bracket-location": [2, "after-props"],
"react/jsx-curly-spacing": [2, "never"],
"react/jsx-equals-spacing": [2, "never"],
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2,
"react/jsx-space-before-closing": [2, "always"],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-did-mount-set-state": 2,
@ -44,8 +48,10 @@
"accessor-pairs": [2, {"setWithoutGet": true, "getWithoutSet": false}],
"array-bracket-spacing": [2, "never"],
"array-callback-return": 2,
"arrow-parens": [2, "as-needed"],
"arrow-spacing": 2,
"block-scoped-var": 2,
"block-spacing": [2, "never"],
"brace-style": 0,
"camelcase": 0,
"comma-dangle": 0,
@ -106,8 +112,9 @@
"no-magic-numbers": 0,
"no-mixed-requires": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": 2,
"no-multiple-empty-lines": [2, {"max": 1, "maxBOF": 0, "maxEOF": 0}],
"no-native-reassign": 2,
"no-negated-condition": 0,
"no-new": 2,
@ -144,15 +151,18 @@
"no-whitespace-before-property": 2,
"no-with": 2,
"object-curly-spacing": [2, "never"],
"object-shorthand": [2, "always"],
"one-var": [2, "never"],
"one-var-declaration-per-line": [2, "initializations"],
"operator-assignment": [2, "always"],
"operator-linebreak": [2, "after"],
"padded-blocks": [2, "never"],
"prefer-const": 0, // TODO: Change to `1`?
"prefer-reflect": 0,
"quotes": [2, "double", "avoid-escape"],
"radix": [2, "always"],
"semi": [2, "always"],
"semi-spacing": [2, {"before": false, "after": true}],
"sort-imports": 2,
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],

Просмотреть файл

@ -31,7 +31,7 @@ function template(rawOptions) {
module.exports = template;
if (require.main === module) {
if (require.main === module) {
// called from command line
const args = require("minimist")(process.argv.slice(2), {
alias: {baseUrl: "b", title: "t"}

Просмотреть файл

@ -30,8 +30,8 @@ const ActivityFeedItem = React.createClass({
},
getDefaultProps() {
return {
onShare: function() {},
onClick: function() {},
onShare() {},
onClick() {},
showDate: false
};
},
@ -69,11 +69,11 @@ const ActivityFeedItem = React.createClass({
<div className="feed-details">
<div className="feed-description">
<h4 className="feed-title" ref="title">{title}</h4>
<span className="feed-url" ref="url" data-feed-url={prettyUrl(site.url)}/>
<span className="feed-url" ref="url" data-feed-url={prettyUrl(site.url)} />
{this.props.preview && <MediaPreview previewInfo={this.props.preview} />}
</div>
<div className="feed-stats">
<div ref="lastVisit" className="last-visit" data-last-visit={dateLabel}/>
<div ref="lastVisit" className="last-visit" data-last-visit={dateLabel} />
</div>
</div>
</a>
@ -85,8 +85,7 @@ const ActivityFeedItem = React.createClass({
site={site}
page={this.props.page}
source={this.props.source}
index={this.props.index}
/>
index={this.props.index} />
</li>);
}
});

Просмотреть файл

@ -18,8 +18,8 @@ const LinkMenu = React.createClass({
if (page && source) {
let payload = {
event,
page: page,
source: source,
page,
source,
action_position: index,
};
if (site.recommended) {

Просмотреть файл

@ -11,7 +11,7 @@ const LoadMore = React.createClass({
render() {
const link = this.props.to ?
(<Link to={this.props.to}><span className="arrow" /> {this.props.label}</Link>) :
(<a href="#" onClick={e => { e.preventDefault(); this.props.onClick(); }}>
(<a href="#" onClick={e => {e.preventDefault(); this.props.onClick();}}>
<span className="arrow" /> {this.props.label}
</a>);
return (<div className="load-more" hidden={this.props.hidden}>

Просмотреть файл

@ -10,7 +10,7 @@ const Loader = React.createClass({
},
render() {
return (<div className={classNames("loader", this.props.className, {centered: this.props.centered})} hidden={!this.props.show}>
<div className="spinner"/> {this.props.label}
<div className="spinner" /> {this.props.label}
</div>);
}
});

Просмотреть файл

@ -31,7 +31,7 @@ const MediaPreview = React.createClass({
type="text/html"
ref="previewPlayer"
frameBorder="0"
allowFullScreen />);
allowFullScreen={true} />);
}
const style = previewInfo.thumbnail ? {backgroundImage: `url(${previewInfo.thumbnail.url})`} : null;

Просмотреть файл

@ -50,15 +50,14 @@ const NewTabPage = React.createClass({
return (<main className="new-tab">
<div className="new-tab-wrapper">
<section>
<Search/>
<Search />
</section>
<Loader
className="loading-notice"
show={!this.props.isReady}
label="Hang on tight! We are analyzing your history to personalize your experience"
centered
/>
centered={true} />
<div className={classNames("show-on-init", {on: this.props.isReady})}>
<section>

Просмотреть файл

@ -4,7 +4,7 @@ const {actions} = require("common/action-manager");
const PAGE_NAME = "NEW_TAB";
const Search = React.createClass({
getInitialState: function() {
getInitialState() {
return {
focus: false,
activeIndex: -1,
@ -13,33 +13,33 @@ const Search = React.createClass({
searchString: this.props.searchString
};
},
resetState: function() {
resetState() {
this.setState(this.getInitialState());
},
manageEngines: function() {
manageEngines() {
this.props.dispatch(actions.NotifyManageEngines());
},
setValueAndSuggestions: function(value) {
setValueAndSuggestions(value) {
this.setState({activeIndex: -1, activeSuggestionIndex: -1, searchString: value});
this.props.dispatch(actions.NotifyUpdateSearchString(value));
this.props.dispatch(actions.RequestSearchSuggestions({engineName: this.props.currentEngine.name, searchString: value}));
},
getActiveSuggestion: function() {
getActiveSuggestion() {
const suggestions = this.props.formHistory.concat(this.props.suggestions);
const index = this.state.activeSuggestionIndex;
return (suggestions && suggestions.length && index >= 0) ? suggestions[index] : null;
},
getActiveEngine: function() {
getActiveEngine() {
const index = this.state.activeEngineIndex;
return (index >= 0) ? this.props.engines[index].name : this.props.currentEngine.name;
},
getSettingsButtonIsActive: function() {
getSettingsButtonIsActive() {
const index = this.state.activeIndex;
const numSuggestions = this.props.formHistory.concat(this.props.suggestions).length;
const numEngines = this.props.engines.length;
return index === numSuggestions + numEngines;
},
getActiveDescendantId: function() {
getActiveDescendantId() {
// Returns the ID of the element being currently in focus, if any.
const index = this.state.activeIndex;
const numSuggestions = this.props.formHistory.concat(this.props.suggestions).length;
@ -53,10 +53,10 @@ const Search = React.createClass({
}
return null;
},
getDropdownVisible: function() {
getDropdownVisible() {
return !!(this.props.searchString && this.state.focus);
},
performSearch: function(options) {
performSearch(options) {
let searchData = {
engineName: options.engineName,
searchString: options.searchString,
@ -68,13 +68,13 @@ const Search = React.createClass({
page: PAGE_NAME
}));
},
removeFormHistory: function(suggestion) {
removeFormHistory(suggestion) {
this.props.dispatch(actions.NotifyRemoveFormHistory(suggestion));
},
cycleCurrentEngine: function(index) {
cycleCurrentEngine(index) {
this.props.dispatch(actions.NotifyCycleEngine(this.props.engines[index].name));
},
handleKeyPress: function(e) {
handleKeyPress(e) {
// Handle the keyboard navigation of the widget.
// If the dropdown isn't visible, we don't handle the event.
@ -262,14 +262,14 @@ const Search = React.createClass({
onFocus={() => this.setState({focus: true})}
onChange={e => this.setValueAndSuggestions(e.target.value)}
onKeyDown={e => this.handleKeyPress(e)}
onBlur={() => setTimeout(() => this.resetState(), 200)}/>
onBlur={() => setTimeout(() => this.resetState(), 200)} />
<button ref="performSearchButton"
onClick={e => { e.preventDefault(); this.performSearch({engineName: currentEngine.name, searchString});}}>
onClick={e => {e.preventDefault(); this.performSearch({engineName: currentEngine.name, searchString});}}>
<span className="sr-only">Search</span>
</button>
<div className="search-container" role="presentation" hidden={!this.getDropdownVisible()}>
<section className="search-title" hidden={!formHistory.concat(suggestions).length}>
<img id="current-engine-icon" src={currentEngine.iconBuffer} alt={currentEngine.name.charAt(0)} width="16px" height="16px"/>
<img id="current-engine-icon" src={currentEngine.iconBuffer} alt={currentEngine.name.charAt(0)} width="16px" height="16px" />
{this.props.searchHeader.replace("%S", currentEngine.name)}
</section>
<section className="history-search-suggestions" hidden={!formHistory.length}>
@ -279,7 +279,7 @@ const Search = React.createClass({
const activeEngine = this.getActiveEngine();
const suggestionIndex = suggestionsIdIndex++;
return (<li key={suggestion} role="option">
<a id={"history-search-suggestions-" + suggestionIndex }
<a id={"history-search-suggestions-" + suggestionIndex}
onMouseMove={() => this.onMouseMove(suggestionIndex)}
className={active ? "active" : ""} role="option"
aria-selected={active} onClick={() => this.performSearch({engineName: activeEngine, searchString: suggestion})}>
@ -295,7 +295,7 @@ const Search = React.createClass({
const activeEngine = this.getActiveEngine();
const suggestionIndex = suggestionsIdIndex++;
return (<li key={suggestion} role="option">
<a ref={suggestion} id={"search-suggestions-" + suggestionIndex }
<a ref={suggestion} id={"search-suggestions-" + suggestionIndex}
onMouseMove={() => this.onMouseMove(suggestionIndex)}
className={active ? "active" : ""} role="option"
aria-selected={active}
@ -313,9 +313,9 @@ const Search = React.createClass({
const icon = option.icon;
const active = (this.state.activeEngineIndex === enginesIdIndex);
return (<li key={option.name} className={active ? "active" : ""}>
<a ref={option.name} id={"search-partners-" + enginesIdIndex++ } aria-selected={active}
<a ref={option.name} id={"search-partners-" + enginesIdIndex++} aria-selected={active}
onClick={() => this.performSearch({engineName: option.name, searchString: this.getActiveSuggestion() || searchString})}>
<img src={icon} alt={option.name} width="16" height="16"/></a>
<img src={icon} alt={option.name} width="16" height="16" /></a>
</li>);
})}
</ul>
@ -324,7 +324,7 @@ const Search = React.createClass({
<button id="search-settings-button" ref="searchSettingsButton"
className={this.getSettingsButtonIsActive() ? "active" : ""}
aria-selected={this.getSettingsButtonIsActive()}
onClick={(e) => {
onClick={e => {
e.preventDefault();
this.manageEngines();
}}>{this.props.searchSettings}

Просмотреть файл

@ -20,7 +20,7 @@ const SpotlightItem = React.createClass({
},
getDefaultProps() {
return {
onClick: function() {},
onClick() {},
bestImage: {}
};
},
@ -72,8 +72,7 @@ const SpotlightItem = React.createClass({
site={site}
page={this.props.page}
index={this.props.index}
source={this.props.source}
/>
source={this.props.source} />
</li>);
}
});

Просмотреть файл

@ -11,8 +11,7 @@ const TimelineBookmarks = React.createClass({
loadMoreAction={RequestMoreBookmarks}
dateKey={"bookmarkDateCreated"}
pageName={"TIMELINE_BOOKMARKS"}
Feed={props.Bookmarks}
/>);
Feed={props.Bookmarks} />);
}
});

Просмотреть файл

@ -77,7 +77,7 @@ const TimelineFeed = React.createClass({
const props = this.props;
return (<section className="content" ref="scrollElement" onScroll={!props.Feed.isLoading && props.Feed.canLoadMore && this.loadMoreDataIfNeeded}>
<div ref="wrapper" className={classNames("wrapper", "show-on-init", {on: props.Feed.init})}>
{props.Spotlight ? <Spotlight page={this.props.pageName} sites={props.Spotlight.rows} /> : null }
{props.Spotlight ? <Spotlight page={this.props.pageName} sites={props.Spotlight.rows} /> : null}
<GroupedActivityFeed
sites={props.Feed.rows}
page={props.pageName}

Просмотреть файл

@ -12,8 +12,7 @@ const TimelineHistory = React.createClass({
dateKey={"lastVisitDate"}
pageName={"TIMELINE_ALL"}
Feed={props.History}
Spotlight={props.Spotlight}
/>);
Spotlight={props.Spotlight} />);
}
});

Просмотреть файл

@ -43,10 +43,10 @@ const TopSites = React.createClass({
const isActive = this.state.showContextMenu && this.state.activeTile === i;
return (<div className={classNames("tile-outer", {active: isActive})} key={site.guid || site.cache_key || i}>
<a onClick={() => this.onClick(i)} className="tile" href={site.url}>
<SiteIcon className="tile-img-container" site={site} faviconSize={32} showTitle />
<SiteIcon className="tile-img-container" site={site} faviconSize={32} showTitle={true} />
<div className="inner-border" />
</a>
<LinkMenuButton onClick={(ev) => {
<LinkMenuButton onClick={ev => {
ev.preventDefault();
this.setState({showContextMenu: true, activeTile: i});
}} />
@ -56,8 +56,7 @@ const TopSites = React.createClass({
site={site}
page={this.props.page}
source="TOP_SITES"
index={i}
/>
index={i} />
</div>);
})}
{blankSites}

Просмотреть файл

@ -1,5 +1,5 @@
const IMG_HEIGHT = 226;
const IMG_WIDTH = 124;
const IMG_WIDTH = 124;
module.exports = function getBestImage(images) {
if (!images || !images.length) {

Просмотреть файл

@ -10,7 +10,7 @@ module.exports = function getVideoPreview(url) {
};
const getVideoURL = {
youtube: function(url) {
youtube(url) {
let videoId = getYouTubeID(url, {fuzzy: false});
if (!videoId) {
return null;
@ -19,7 +19,7 @@ const getVideoURL = {
return `https://www.youtube.com/embed/${videoId}?autoplay=1`;
},
vimeo: function(url) {
vimeo(url) {
const vimeoRegex = /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)/;
let idMatches = url.match(vimeoRegex);
if (!idMatches) {

Просмотреть файл

@ -2,7 +2,6 @@ const urlParse = require("url-parse");
const am = require("common/action-manager");
module.exports = () => next => action => {
if (!am.ACTIONS_WITH_SITES.has(action.type)) {
return next(action);
}

Просмотреть файл

@ -1,4 +1,3 @@
// This function sets the favicon of the current page
module.exports = function setFavicon(filePath) {
const iconEl = document.head.querySelector("link[rel='icon']");

Просмотреть файл

@ -27,7 +27,7 @@ module.exports = {
getRandomColor(key) {
if (key && typeof key === "number") {
return RANDOM_COLORS[key % 10];
} else if (key && typeof key === "string") {
} else if (key && typeof key === "string") {
return RANDOM_COLORS[key.charCodeAt(0) % 10];
} else {
return RANDOM_COLORS[Math.floor(Math.random() * RANDOM_COLORS.length)];

Просмотреть файл

@ -14,7 +14,6 @@ const DEFAULT_FAVICON_BG_COLOR = [150, 150, 150];
module.exports.justDispatch = (() => ({}));
function getBackgroundRGB(site) {
// This is from firefox
if (site.favicon_color) {
return site.favicon_color;
@ -45,7 +44,7 @@ const selectSpotlight = module.exports.selectSpotlight = createSelector(
[
state => state.Highlights
],
(Highlights) => {
Highlights => {
const rows = Highlights.rows
// Only concat first run data if init is true
.concat(Highlights.init ? firstRunData.Highlights : [])
@ -84,7 +83,7 @@ const selectTopSites = module.exports.selectTopSites = createSelector(
[
state => state.TopSites
],
(TopSites) => {
TopSites => {
return Object.assign({}, TopSites, {
rows: dedupe.one(TopSites.rows
// Add first run stuff to the end if init has already happened
@ -101,7 +100,6 @@ module.exports.selectNewTabSites = createSelector(
state => state.Experiments
],
(TopSites, History, Spotlight, Experiments) => {
// Remove duplicates
// Note that we have to limit the length of topsites, spotlight so we
// don't dedupe against stuff that isn't shown
@ -132,7 +130,7 @@ module.exports.selectNewTabSites = createSelector(
function selectSiteProperties(site) {
const metadataFavicon = site.favicons && site.favicons[0] && site.favicons[0].url;
const favicon = site.favicon_url || metadataFavicon || site.favicon;
const parsedUrl = site.parsedUrl || urlParse(site.url || "") ;
const parsedUrl = site.parsedUrl || urlParse(site.url || "");
const label = prettyUrl(parsedUrl.hostname);
return {favicon, parsedUrl, label};
}

Просмотреть файл

@ -71,7 +71,7 @@ describe("ContextMenu", () => {
setup({
visible: true,
options: [{label: "Test", onClick: () => {}}],
onUpdate: (value) => {
onUpdate: value => {
assert.isFalse(value);
done();
}

Просмотреть файл

@ -12,7 +12,6 @@ const fakeProps = {
};
describe("Header", () => {
let node;
let header;
let el;
@ -26,13 +25,11 @@ describe("Header", () => {
});
it("should not throw if missing props", () => {
assert.doesNotThrow(() => {
const restore = overrideConsoleError();
ReactDOM.render(<Header />, node);
restore();
});
});
it("should hide dropdown be default", () => {
@ -72,5 +69,4 @@ describe("Header", () => {
assert.include(imgEl.src, "https://foo.com/user.jpg");
});
});
});

Просмотреть файл

@ -49,5 +49,4 @@ describe("LoadMore", () => {
assert.isTrue(ReactDOM.findDOMNode(instance.refs.action).hidden, "action should be hidden");
assert.isFalse(ReactDOM.findDOMNode(instance.refs.loader).hidden, "loader should not be hidden");
});
});

Просмотреть файл

@ -48,7 +48,7 @@ describe("NewTabPage", () => {
});
it("should render connected component with correct props", () => {
const container = renderWithProvider(<ConnectedNewTabPage/>);
const container = renderWithProvider(<ConnectedNewTabPage />);
const inner = TestUtils.findRenderedComponentWithType(container, NewTabPage);
Object.keys(NewTabPage.propTypes).forEach(key => assert.property(inner.props, key));
});
@ -141,5 +141,4 @@ describe("NewTabPage", () => {
TestUtils.Simulate.click(deleteLink);
});
});
});

Просмотреть файл

@ -8,7 +8,6 @@ const NewTabPage = require("components/NewTabPage/NewTabPage");
const Provider = createMockProvider();
describe("Router", () => {
let instance;
beforeEach(() => {
instance = TestUtils.renderIntoDocument(<Provider><Routes /></Provider>);
@ -21,5 +20,4 @@ describe("Router", () => {
it("should render NewTabPage by default", () => {
TestUtils.findRenderedComponentWithType(instance, NewTabPage);
});
});

Просмотреть файл

@ -23,14 +23,14 @@ describe("Search", () => {
function setup(customProps = {}) {
const props = Object.assign({}, DEFAULT_PROPS, customProps);
instance = TestUtils.renderIntoDocument(<Search {...props}/>);
instance = TestUtils.renderIntoDocument(<Search {...props} />);
}
beforeEach(setup);
it("should send a perform search event when you click the search button", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_PERFORM_SEARCH") {
assert.equal(action.data.searchString, "hello");
done();
@ -45,7 +45,7 @@ describe("Search", () => {
it("should request suggestions when input field changes", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "SEARCH_SUGGESTIONS_REQUEST") {
assert.equal(action.data.searchString, "hello");
done();
@ -61,7 +61,7 @@ describe("Search", () => {
it("should update the search string when input field changes", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_UPDATE_SEARCH_STRING") {
assert.equal(action.data.searchString, "hello");
done();
@ -77,7 +77,7 @@ describe("Search", () => {
it("should fire a manage engines event when the search settings button is clicked", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_MANAGE_ENGINES") {
done();
}
@ -128,7 +128,7 @@ describe("Search", () => {
it("should send perform search event if suggestion is active and enter key is pressed", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_PERFORM_SEARCH") {
assert.equal(action.data.searchString, "hello");
assert.equal(action.data.engineName, "Google");
@ -149,7 +149,7 @@ describe("Search", () => {
it("should send remove form history event with proper key binding", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_REMOVE_FORM_HISTORY_ENTRY") {
assert.equal(action.data, "hello");
done();
@ -281,7 +281,7 @@ describe("Search", () => {
it("should send cycle current engine event with proper key down binding and update current engine", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "SEARCH_CYCLE_CURRENT_ENGINE_REQUEST") {
assert.equal(action.data, "Yahoo");
}
@ -304,7 +304,7 @@ describe("Search", () => {
it("should send cycle current engine event with proper key up binding and update current engine", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "SEARCH_CYCLE_CURRENT_ENGINE_REQUEST") {
assert.equal(action.data, "Google");
}
@ -327,7 +327,7 @@ describe("Search", () => {
it("should perform a search if you click on a suggestion", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_PERFORM_SEARCH") {
assert.equal(action.data.searchString, "hello");
assert.equal(action.data.engineName, "Google");
@ -348,7 +348,7 @@ describe("Search", () => {
it("should perform a search if you click on a non-default engine with a search string provided", done => {
const props = {
dispatch: (action) => {
dispatch: action => {
if (action.type === "NOTIFY_PERFORM_SEARCH") {
assert.equal(action.data.searchString, "hello");
assert.equal(action.data.engineName, "Yahoo");

Просмотреть файл

@ -64,7 +64,7 @@ describe("Spotlight", function() {
}
}
let fakeSitesWithRecommendation = fakeSpotlightItems;
let fakeRecommendation = {url: "http://example.com", recommender_type: "pocket-trending", recommended: true};
let fakeRecommendation = {url: "http://example.com", recommender_type: "pocket-trending", recommended: true};
fakeSitesWithRecommendation[0] = Object.assign({}, fakeSitesWithRecommendation[0], fakeRecommendation);
instance = renderWithProvider(<Spotlight page={"NEW_TAB"} dispatch={dispatch} sites={fakeSitesWithRecommendation} />);
TestUtils.Simulate.click(TestUtils.scryRenderedComponentsWithType(instance, SpotlightItem)[0].refs.link);
@ -115,7 +115,6 @@ describe("SpotlightItem", function() {
const props = getHighlightContextFromSite(site);
assert.equal(hc.props.type, "bookmark");
assert.deepEqual(hc.props, props);
});
});
});

Просмотреть файл

@ -17,7 +17,6 @@ const {mockData, renderWithProvider} = require("test/test-utils");
const {INFINITE_SCROLL_THRESHOLD, SCROLL_TOP_OFFSET} = require("common/constants");
describe("Timeline", () => {
describe("TimelinePage", () => {
const fakeProps = {
location: {pathname: "/timeline"}
@ -185,7 +184,6 @@ describe("Timeline", () => {
instance.maybeLoadMoreData({scrollTop: 1000, scrollHeight: 200});
});
});
});
describe("TimelineHistory", () => {
@ -231,5 +229,4 @@ describe("Timeline", () => {
Object.keys(TimelineBookmarks.propTypes).forEach(key => assert.property(inner.props, key));
});
});
});

Просмотреть файл

@ -38,5 +38,4 @@ describe("Tooltip", () => {
setup({label: "foo", visible: false});
assert.equal(el.style.display, "none");
});
});

Просмотреть файл

@ -22,7 +22,6 @@ const fakeProps = {
};
describe("TopSites", () => {
let topSites;
let el;
@ -72,5 +71,4 @@ describe("TopSites", () => {
assert.include(tileOuter.className, "active");
});
});
});

Просмотреть файл

@ -67,7 +67,6 @@ describe("randomWeighter", () => {
]);
assert.include([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], result);
});
});
describe("createRows", () => {

Просмотреть файл

@ -4,7 +4,6 @@ const ActionManager = require("common/ActionManager");
const {assert} = require("chai");
describe("ActionManager", () => {
describe("instance", () => {
it("should throw if types is not an array", () => {
assert.throws(() => new ActionManager(), "You must instantiate ActionManager with an array of action types.");
@ -111,5 +110,4 @@ describe("ActionManager", () => {
}, "BAZ is not defined in your ActionManager");
});
});
});

Просмотреть файл

@ -148,7 +148,7 @@ describe("setRowsOrError", () => {
assert.isUndefined(newRow.bookmarkTitle, "should remove bookmarkTitle");
});
((event) => {
(event => {
it(`should remove a row removed via ${event}`, () => {
const action = {type: event, data: "http://foo.com"};
const prevRows = [{url: "http://foo.com"}, {url: "http://bar.com"}];

Просмотреть файл

@ -287,7 +287,6 @@ ActivityStreams.prototype = {
* Handles changes to places
*/
_handlePlacesChanges(eventName, data) {
/* note: this will execute for each of the 3 notifications that occur
* when adding a visit: frecency:-1, frecency: real frecency, title */
if (this._populatingCache && !this._populatingCache.places) {
@ -457,7 +456,6 @@ ActivityStreams.prototype = {
contentScriptWhen: "start",
attachTo: ["existing", "top"],
onAttach: worker => {
// Don't attach when in private browsing. Send user to about:privatebrowsing
if (privateBrowsing.isPrivate(worker)) {
worker.tab.url = "about:privatebrowsing";

Просмотреть файл

@ -14,7 +14,7 @@ function AppURLHider(appURLs) {
}
AppURLHider.prototype = {
uninit: function() {
uninit() {
tabs.removeListener("activate", this.maybeHideURL);
Services.ww.unregisterNotification(this._windowObserver);
@ -24,26 +24,25 @@ AppURLHider.prototype = {
/**
* Returns true if the passed URL is an app URL.
*/
isAppURL: function(url) {
isAppURL(url) {
return this._appURLs.includes(url);
},
/**
* Hide the URL of the most recent window.
*/
_hideURL: function(url) {
_hideURL(url) {
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
// Only hide the url if it matches the expected app url.
if (browserWindow.gURLBar.value === url) {
browserWindow.gURLBar.value = "";
}
},
/**
* Hide the URL of the most recent window if the passed in tab is on an app URL.
*/
maybeHideURL: function(tab) {
maybeHideURL(tab) {
if (this.isAppURL(tab.url)) {
this._hideURL(tab.url);
}

Просмотреть файл

@ -35,7 +35,6 @@ Memoizer.prototype = {
*/
memoize(key, func) {
return (...args) => {
// figure out if we need to replace the cache for this query
let replace = false;
args = args.filter(arg => {

Просмотреть файл

@ -293,7 +293,6 @@ MetadataStore.prototype = {
yield this._conn.executeCached(SQL_INSERT_METADATA_IMAGES, [metadata_id, image_id]);
}
}
}.bind(this));
}
}),

Просмотреть файл

@ -76,10 +76,10 @@ PerfMeter.prototype = {
let variance = (this._stats.squareSum / total) - mean * mean;
return {
total: total,
total,
mean: this._twoDigitsRound(mean),
std: this._twoDigitsRound(Math.sqrt(variance)),
median: median
median
};
},
@ -124,7 +124,7 @@ PerfMeter.prototype = {
onOpen(tab) {
let item = {tag: "TAB_OPEN", start: 0};
this._tabs[tab.id] = {
tab: tab,
tab,
openAt: Date.now(),
events: [item],
requests: new Map(),
@ -162,9 +162,9 @@ PerfMeter.prototype = {
}
let item = {
tag: tag,
tag,
start: Date.now() - tabData.openAt,
data: data,
data,
};
// handle requests/response pairs

Просмотреть файл

@ -335,7 +335,6 @@ Links.prototype = {
* @returns {Promise} Returns a promise with the array of links as payload.
*/
_getHistoryLinks: Task.async(function*(options = {}) {
let {limit, afterDate, beforeDate, order, ignoreBlocked} = options;
if (!limit || limit.options > LINKS_QUERY_LIMIT) {
limit = LINKS_QUERY_LIMIT;
@ -344,7 +343,7 @@ Links.prototype = {
let blockedURLs = ignoreBlocked ? [] : this.blockedURLs.items().map(item => `"${item}"`);
// setup binding parameters
let params = {limit: limit};
let params = {limit};
// setup afterDate binding and sql clause
let afterDateClause = "";
@ -363,10 +362,10 @@ Links.prototype = {
// setup order by clause
let orderbyClause = (order === "bookmarksFrecency") ?
"ORDER BY bookmarkDateCreated DESC, frecency DESC, lastVisitDate DESC, url" :
"ORDER BY lastVisitDate DESC, frecency DESC, url" ;
"ORDER BY lastVisitDate DESC, frecency DESC, url";
// construct sql query
let sqlQuery = `SELECT moz_places.url as url,
let sqlQuery = `SELECT moz_places.url as url,
moz_places.guid as guid,
moz_favicons.data as favicon,
moz_favicons.mime_type as mimeType,
@ -391,7 +390,7 @@ Links.prototype = {
let links = yield this.executePlacesQuery(sqlQuery, {
columns: ["url", "guid", "favicon", "mimeType", "title", "lastVisitDate",
"frecency", "type", "bookmarkGuid", "bookmarkDateCreated"],
params: params
params
});
links = this._faviconBytesToDataURI(links);
@ -433,7 +432,6 @@ Links.prototype = {
* @returns {Promise} Returns a promise with the array of links as payload.
*/
getTopFrecentSites: Task.async(function*(options = {}) {
let {limit, ignoreBlocked} = options;
if (!limit || limit.options > LINKS_QUERY_LIMIT) {
limit = LINKS_QUERY_LIMIT;
@ -490,7 +488,7 @@ Links.prototype = {
let blockedURLs = ignoreBlocked ? [] : this.blockedURLs.items().map(item => `"${item}"`);
// setup binding parameters
let params = {limit: limit, type: Bookmarks.TYPE_BOOKMARK};
let params = {limit, type: Bookmarks.TYPE_BOOKMARK};
// setup afterDate binding and sql clause
let afterDateClause = "";
@ -531,7 +529,7 @@ Links.prototype = {
let links = yield this.executePlacesQuery(sqlQuery, {
columns: ["bookmarkId", "bookmarkTitle", "bookmarkGuid", "bookmarkDateCreated", "url", "guid",
"title", "lastVisitDate", "frecency", "type", "lastModified", "favicon", "mimeType"],
params: params,
params,
});
links = this._faviconBytesToDataURI(links);
@ -587,7 +585,6 @@ Links.prototype = {
* @returns {Promise} Returns a promise with the array of links as payload.
*/
getHighlightsLinks: Task.async(function*(options = {}) {
let {limit, ignoreBlocked} = options;
if (!limit || limit.options > LINKS_QUERY_LIMIT) {
limit = LINKS_QUERY_LIMIT;
@ -659,7 +656,7 @@ Links.prototype = {
let links = yield this.executePlacesQuery(sqlQuery, {
columns: ["bookmarkId", "bookmarkTitle", "bookmarkGuid", "bookmarkDateCreated", "url", "guid",
"title", "lastVisitDate", "frecency", "type", "lastModified", "favicon", "mimeType"],
params: params,
params,
});
links = this._faviconBytesToDataURI(links);

Просмотреть файл

@ -16,10 +16,10 @@ const ALLOWED_QUERY_PARAMS = new Set(["id", "p", "q", "query", "s", "search", "s
const ALLOWED_PROTOCOLS = new Set(["http:", "https:"]);
const DISALLOWED_HOSTS = new Set(["localhost", "127.0.0.1", "0.0.0.0"]);
const URL_FILTERS = [
(item) => !!item.url,
(item) => !!(new URL(item.url)),
(item) => ALLOWED_PROTOCOLS.has(new URL(item.url).protocol),
(item) => !DISALLOWED_HOSTS.has(new URL(item.url).hostname)
item => !!item.url,
item => !!(new URL(item.url)),
item => ALLOWED_PROTOCOLS.has(new URL(item.url).protocol),
item => !DISALLOWED_HOSTS.has(new URL(item.url).hostname)
];
Cu.importGlobalProperties(["fetch"]);

Просмотреть файл

@ -88,7 +88,7 @@ RecommendationProvider.prototype = {
let responseJson = yield response.json();
if (responseJson.urls.length > 0) {
// wait for the recommendation's metadata to come back (we don't want to show ugly recommendations)
this._recommendedContent = yield this._previewProvider.getLinkMetadata(responseJson.urls);
this._recommendedContent = yield this._previewProvider.getLinkMetadata(responseJson.urls);
}
} else {
Cu.reportError(`Response failed with status ${response.status} ${response.statusText}`);

Просмотреть файл

@ -139,7 +139,7 @@ NewTabSearchProvider.prototype = {
};
const pref = Services.prefs.getCharPref(HIDDEN_ENGINES);
const hiddenEngines = pref ? pref.split(",") : [];
let result = Services.search.getVisibleEngines().filter(engine => !hiddenEngines.includes(engine.name));
let result = Services.search.getVisibleEngines().filter(engine => !hiddenEngines.includes(engine.name));
for (let engine of result) {
let favicon = engine.getIconURLBySize(ENGINE_ICON_SIZE, ENGINE_ICON_SIZE);
state.engines.push({

Просмотреть файл

@ -261,7 +261,7 @@ TabTracker.prototype = {
},
onOpen(tab) {
this._openTabs[tab.id] = {tab: tab, url: tab.url, active: true};
this._openTabs[tab.id] = {tab, url: tab.url, active: true};
this.logReady = this.logReady.bind(this);
this.logPageShow = this.logPageShow.bind(this);
@ -294,7 +294,7 @@ TabTracker.prototype = {
this.enabled = newValue;
},
observe: function(subject, topic, data) {
observe(subject, topic, data) {
let eventData = JSON.parse(data);
if (eventData.tabId === this._tabData.tab_id) {
this._tabData.load_latency = eventData.events[eventData.events.length - 1].start;

Просмотреть файл

@ -42,11 +42,8 @@ TelemetrySender.prototype = {
_onPrefChange(prefName) {
if (prefName === ENDPOINT_PREF) {
this._pingEndpoint = simplePrefs.prefs[ENDPOINT_PREF];
} else if (prefName === TELEMETRY_PREF) {
let newValue = simplePrefs.prefs[TELEMETRY_PREF];
if (this.enabled && !newValue) {

Просмотреть файл

@ -22,7 +22,6 @@ let connectRetried = 0;
Object.assign(exports, {
main(options) {
// options.loadReason can be install/enable/startup/upgrade/downgrade
PlacesProvider.links.init();
SearchProvider.search.init();

Просмотреть файл

@ -86,7 +86,7 @@ const PlacesTestUtils = Object.freeze({
resultCode);
reject(ex);
},
handleResult: function() {},
handleResult() {},
handleCompletion: function UP_handleCompletion() {
resolve();
}
@ -179,7 +179,7 @@ const PlacesTestUtils = Object.freeze({
*/
insertAndBookmarkVisit: Task.async(function*(url) {
yield this.addVisits({uri: NetUtil.newURI(url), visitDate: Date.now(), transition: PlacesUtils.history.TRANSITION_LINK});
yield Bookmarks.insert({url: url, parentGuid: "root________", type: Bookmarks.TYPE_BOOKMARK});
yield Bookmarks.insert({url, parentGuid: "root________", type: Bookmarks.TYPE_BOOKMARK});
}),
});

Просмотреть файл

@ -4,7 +4,7 @@
const {Cu} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
let makeCachePromise = (name) => {
let makeCachePromise = name => {
return new Promise(resolve => {
let precacheNotif = `activity-streams-${name}-cache-complete`;
let waitForCache = (subject, topic, data) => {

Просмотреть файл

@ -55,11 +55,11 @@ function doDump(object, trailer) {
function getTestActivityStream(options = {}) {
const mockMetadataStore = {
asyncConnect() { return Promise.resolve();},
asyncReset() { return Promise.resolve();},
asyncClose() { return Promise.resolve();},
asyncInsert() { return Promise.resolve();},
asyncGetMetadataByCacheKey() { return Promise.resolve([]);},
asyncConnect() {return Promise.resolve();},
asyncReset() {return Promise.resolve();},
asyncClose() {return Promise.resolve();},
asyncInsert() {return Promise.resolve();},
asyncGetMetadataByCacheKey() {return Promise.resolve([]);},
};
let mockApp = new ActivityStreams(mockMetadataStore, options);
return mockApp;

Просмотреть файл

@ -26,7 +26,7 @@ exports["test awesomebar is empty for all app urls"] = function*(assert) {
for (let appURL of app.appURLs) {
yield new Promise(resolve => tabs.open({
url: appURL,
onReady: (tab) => {
onReady: tab => {
let browserWindow = windowMediator.getMostRecentWindow("navigator:browser");
assert.equal(browserWindow.gURLBar.value, "");
tab.close(resolve);
@ -49,7 +49,7 @@ exports["test awesomebar is empty for all app urls in new windows too"] = functi
for (let appURL of app.appURLs) {
yield new Promise(resolve => windows.open({
url: appURL,
onOpen: (window) => {
onOpen: window => {
let chromeWindow = viewFor(window);
assert.equal(chromeWindow.gURLBar.value, "");
window.close(resolve);
@ -71,7 +71,7 @@ exports["test awesomebar remains empty on route changes"] = function*(assert) {
yield new Promise(resolve => tabs.open({
url: app.appURLs[0],
onReady: (tab) => {
onReady: tab => {
let browserWindow = windowMediator.getMostRecentWindow("navigator:browser");
// The url bar should be empty.
@ -101,7 +101,7 @@ exports["test awesomebar doesn't clear out what user typed"] = function*(assert)
yield new Promise(resolve => tabs.open({
url: app.appURLs[0],
onReady: (tab) => {
onReady: tab => {
let browserWindow = windowMediator.getMostRecentWindow("navigator:browser");
// The url bar should be empty.

Просмотреть файл

@ -36,7 +36,6 @@ exports["test activity stream loads on home page when appropriate"] = function(a
assert.ok(!prefService.isSet("browser.startup.homepage"));
app.unload();
assert.ok(!prefService.isSet("browser.startup.homepage"));
};
test.run(exports);

Просмотреть файл

@ -29,7 +29,7 @@ let gApp;
let gAppURL;
let gInitialCachePref = simplePrefs.prefs["query.cache"];
let makeNotifsPromise = (cacheStatus) => {
let makeNotifsPromise = cacheStatus => {
return new Promise(resolve => {
let notifSet = new Set([
"getTopFrecentSites-cache",

Просмотреть файл

@ -17,7 +17,7 @@ exports["test activity stream doesn't load in private windows"] = function*(asse
let window = yield new Promise(resolve => windows.open({
url: "about:privatebrowsing",
isPrivate: true,
onOpen: (window) => {
onOpen: window => {
resolve(window);
}
}));
@ -27,7 +27,7 @@ exports["test activity stream doesn't load in private windows"] = function*(asse
yield new Promise(resolve => {
window.tabs.open({
url: appURL,
onReady: (tab) => {
onReady: tab => {
assert.equal(tab.url, "about:privatebrowsing");
tab.close(resolve);
}

Просмотреть файл

@ -126,7 +126,7 @@ before(exports, function*() {
simplePrefs.prefs["embedly.endpoint"] = `http://localhost:${gPort}/previewProviderMetadataStore`;
simplePrefs.prefs["previews.enabled"] = true;
yield gMetadataStore.asyncConnect();
let mockTabTracker = {handlePerformanceEvent: function() {}, generateEvent: function() {}};
let mockTabTracker = {handlePerformanceEvent() {}, generateEvent() {}};
gPreviewProvider = new PreviewProvider(mockTabTracker, gMetadataStore, {initFresh: true});
});

Просмотреть файл

@ -13,10 +13,10 @@ const {PreviewProvider} = require("lib/PreviewProvider");
const ALLOWED_PROTOCOLS = new Set(["http:", "https:"]);
const DISALLOWED_HOSTS = new Set(["localhost", "127.0.0.1", "0.0.0.0"]);
const URL_FILTERS = [
(item) => !!item.url,
(item) => !!(new URL(item.url)),
(item) => ALLOWED_PROTOCOLS.has(new URL(item.url).protocol),
(item) => !DISALLOWED_HOSTS.has(new URL(item.url).hostname)
item => !!item.url,
item => !!(new URL(item.url)),
item => ALLOWED_PROTOCOLS.has(new URL(item.url).protocol),
item => !DISALLOWED_HOSTS.has(new URL(item.url).hostname)
];
Cu.importGlobalProperties(["URL"]);
@ -306,11 +306,11 @@ before(exports, function() {
simplePrefs.prefs["embedly.endpoint"] = `http://localhost:${gPort}/embedlyLinkData`;
simplePrefs.prefs["previews.enabled"] = true;
let mockMetadataStore = {
asyncInsert: function(data) {
asyncInsert(data) {
gMetadataStore.push(data);
return gMetadataStore;
},
asyncGetMetadataByCacheKey: function(cacheKeys) {
asyncGetMetadataByCacheKey(cacheKeys) {
let items = [];
gMetadataStore.forEach(item => {
if (cacheKeys.includes(item.cache_key)) {
@ -320,7 +320,7 @@ before(exports, function() {
return items;
}
};
let mockTabTracker = {handlePerformanceEvent: function() {}, generateEvent: function() {}};
let mockTabTracker = {handlePerformanceEvent() {}, generateEvent() {}};
gPreviewProvider = new PreviewProvider(mockTabTracker, mockMetadataStore, {initFresh: true});
});

Просмотреть файл

@ -151,13 +151,13 @@ before(exports, function() {
simplePrefs.prefs["pocket.endpoint"] = `http://localhost:${gPort}/pocketRecommendations`;
// PreviewProvider needs to attach some metadata to these recommendations
const mockPreviewProvider = {
getLinkMetadata: function(links) {
getLinkMetadata(links) {
let a = [];
links.forEach(item => a.push(Object.assign({}, item, {metadata: "some metadata"})));
return a;
}
};
const mockTabTracker = {handleUserEvent: function() {}, generateEvent: function() {}, handlePerformanceEvent: function() {}};
const mockTabTracker = {handleUserEvent() {}, generateEvent() {}, handlePerformanceEvent() {}};
gRecommendationProvider = new RecommendationProvider(mockPreviewProvider, mockTabTracker);
});

Просмотреть файл

@ -452,7 +452,7 @@ exports.test_TabTracker_unload_reason_with_user_action = function*(assert) {
data: {
source: "topsites",
action_position: 3,
event: event
event
}
}
};

Просмотреть файл

@ -1,6 +1,6 @@
"use strict";
const webpack = require("webpack");
const absolute = (relPath) => require("path").join(__dirname, relPath);
const absolute = relPath => require("path").join(__dirname, relPath);
module.exports = {
entry: {

Просмотреть файл

@ -2,7 +2,7 @@
const WebpackNotifierPlugin = require("webpack-notifier");
const webpack = require("webpack");
const path = require("path");
const absolute = (relPath) => path.join(__dirname, relPath);
const absolute = relPath => path.join(__dirname, relPath);
const EnvLoaderPlugin = require("webpack-env-loader-plugin");
const srcPath = absolute("./content-src/main.js");
@ -11,7 +11,7 @@ const outputFilename = "bundle.js";
let env = process.env.NODE_ENV || "development";
let plugins = [
let plugins = [
new WebpackNotifierPlugin(),
new EnvLoaderPlugin({
env,