Skip to content
Permalink
Browse files

Switched eslint to use prettier (#2796)

* switched eslint to use prettier
  • Loading branch information...
Pomax committed Mar 13, 2019
1 parent 642ccb2 commit b9adc3495585cc069ec10c6ebdf8b28f2d8da86d
Showing with 1,962 additions and 1,104 deletions.
  1. +22 −0 .eslintrc.json
  2. +0 −16 .eslintrc.yaml
  3. +41 −0 package-lock.json
  4. +4 −1 package.json
  5. +17 −10 source/js/basket-signup.js
  6. +53 −26 source/js/buyers-guide/bg-main.js
  7. +122 −48 source/js/buyers-guide/components/creep-vote/creep-vote.jsx
  8. +48 −22 source/js/buyers-guide/components/creepiness-chart/creepiness-chart.jsx
  9. +32 −20 source/js/buyers-guide/components/creepometer/creepometer.jsx
  10. +112 −55 source/js/buyers-guide/components/filter/filter.jsx
  11. +11 −7 source/js/buyers-guide/components/likelyhood-chart/likelyhood-chart.jsx
  12. +3 −3 source/js/buyers-guide/components/primary-nav/primary-nav.js
  13. +22 −9 source/js/buyers-guide/components/social-share/social-share.jsx
  14. +0 −1 source/js/buyers-guide/copy-to-clipboard.js
  15. +63 −45 source/js/buyers-guide/homepage-c-slider.js
  16. +25 −23 source/js/buyers-guide/product-analytics.js
  17. +39 −16 source/js/components/fellow-list/fellow-list.jsx
  18. +27 −22 source/js/components/fellow-list/single-filter-fellow-list.jsx
  19. +16 −12 source/js/components/highlights/highlights.jsx
  20. +23 −14 source/js/components/home-news/home-news.jsx
  21. +107 −47 source/js/components/join/join.jsx
  22. +20 −11 source/js/components/leaders/leaders.jsx
  23. +8 −6 source/js/components/loading-indicator/loading-indicator.jsx
  24. +42 −9 source/js/components/member-notice/member-notice.jsx
  25. +28 −14 source/js/components/multipage-nav-mobile/multipage-nav-mobile.jsx
  26. +39 −25 source/js/components/news/news.jsx
  27. +20 −18 source/js/components/people/people.jsx
  28. +111 −54 source/js/components/people/person.jsx
  29. +20 −9 source/js/components/petition/country-select.jsx
  30. +8 −8 source/js/components/petition/donation-modal.jsx
  31. +7 −4 source/js/components/petition/floating-label-input.jsx
  32. +7 −4 source/js/components/petition/floating-label-textarea.jsx
  33. +63 −21 source/js/components/petition/locale-strings.jsx
  34. +2 −2 source/js/components/petition/locales.js
  35. +293 −124 source/js/components/petition/petition.jsx
  36. +250 −250 source/js/components/petition/salesforce-country-list.js
  37. +48 −25 source/js/components/pulse-project-list/pulse-project-list.jsx
  38. +5 −5 source/js/dnt.js
  39. +28 −18 source/js/donate-modal/donate-modal.jsx
  40. +164 −93 source/js/main.js
  41. +1 −1 source/js/polyfills.js
  42. +2 −2 source/js/primary-nav.js
  43. +2 −2 source/js/react-ga-proxy.js
  44. +7 −2 webpack.config.js
@@ -0,0 +1,22 @@
{
"extends": [
"prettier"
],
"plugins": [
"prettier",
"react"
],
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true
},
"rules": {
"prettier/prettier": "error",
"react/jsx-uses-vars": "error"
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more.

@@ -27,7 +27,7 @@
"start": "run-p build-uncompressed server watch:**",
"snyk": "snyk test --file=package.json",
"test:procfile": "node test/test-procfile.js",
"test:eslint": "eslint --config ./.eslintrc.yaml \"source/js/**/*.js\" \"source/js/**/*.jsx\" webpack.config.js",
"test:eslint": "eslint --config ./.eslintrc.json \"source/js/**/*.js\" \"source/js/**/*.jsx\" webpack.config.js",
"test:scss": "stylelint \"source/sass/**/*.scss\" \"source/js/**/*.scss\" --syntax scss",
"test": "run-s test:** build",
"watch:images": "chokidar \"source/images/**/*\" -c \"npm run build:images\"",
@@ -52,6 +52,8 @@
"classnames": "2.2.6",
"dotenv": "^6.2.0",
"eslint": "^5.15.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
"event-stream": "3.3.4",
"html-entities": "^1.2.1",
@@ -64,6 +66,7 @@
"optipng-bin": "^5.1.0",
"postcss": "^7.0.14",
"postcss-cli": "^6.1.2",
"prettier": "^1.16.4",
"prop-types": "^15.7.2",
"react": "16.8.4",
"react-dom": "16.8.4",
@@ -13,29 +13,37 @@ var basketSignup = function(transaction, onSuccessCallback, onFailCallback) {
var errorArray = [];
var newsletterErrors = [];

while (newsletterErrors.firstChild) { newsletterErrors.removeChild(newsletterErrors.firstChild); }
while (newsletterErrors.firstChild) {
newsletterErrors.removeChild(newsletterErrors.firstChild);
}

var params = `email=` + encodeURIComponent(payload.email) +
`&newsletters=` + payload.newsletter +
`&privacy=`+ payload.privacy +
`&fmt=` + payload.format +
`&source_url=` + encodeURIComponent(document.location.href);
var params =
`email=` +
encodeURIComponent(payload.email) +
`&newsletters=` +
payload.newsletter +
`&privacy=` +
payload.privacy +
`&fmt=` +
payload.format +
`&source_url=` +
encodeURIComponent(document.location.href);

var xhr = new XMLHttpRequest();

xhr.onload = function(r) {
if (r.target.status >= 200 && r.target.status < 300) {
var response = r.target.response;

if(response === null ) {
if (response === null) {
onFailCallback(new Error());
return;
}

if (response.success === true) {
onSuccessCallback();
} else {
if(response.errors) {
if (response.errors) {
for (var i = 0; i < response.errors.length; i++) {
errorArray.push(response.errors[i]);
}
@@ -53,14 +61,13 @@ var basketSignup = function(transaction, onSuccessCallback, onFailCallback) {

xhr.open(`POST`, url, true);
xhr.setRequestHeader(`Content-type`, `application/x-www-form-urlencoded`);
xhr.setRequestHeader(`X-Requested-With`,`XMLHttpRequest`);
xhr.setRequestHeader(`X-Requested-With`, `XMLHttpRequest`);
xhr.timeout = 5000;
xhr.ontimeout = onFailCallback;
xhr.responseType = `json`;
xhr.send(params);

return false;

};

module.exports = basketSignup;
@@ -1,15 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactGA from '../react-ga-proxy.js';
import React from "react";
import ReactDOM from "react-dom";
import ReactGA from "../react-ga-proxy.js";

import primaryNav from './components/primary-nav/primary-nav.js';
import CreepVote from './components/creep-vote/creep-vote.jsx';
import Creepometer from './components/creepometer/creepometer.jsx';
import Filter from './components/filter/filter.jsx';
import primaryNav from "./components/primary-nav/primary-nav.js";
import CreepVote from "./components/creep-vote/creep-vote.jsx";
import Creepometer from "./components/creepometer/creepometer.jsx";
import Filter from "./components/filter/filter.jsx";

import copyToClipboard from './copy-to-clipboard.js';
import HomepageSlider from './homepage-c-slider.js';
import ProductGA from './product-analytics.js';
import copyToClipboard from "./copy-to-clipboard.js";
import HomepageSlider from "./homepage-c-slider.js";
import ProductGA from "./product-analytics.js";

// Track all ReactDOM.render calls so we can use a Promise.all()
// all the way at the end to make sure we don't report "we are done"
@@ -32,9 +32,11 @@ let main = {
let filter = document.querySelector(`#product-filter`);

if (filter) {
apps.push(new Promise(resolve => {
ReactDOM.render(<Filter whenLoaded={() => resolve()}/>, filter);
}));
apps.push(
new Promise(resolve => {
ReactDOM.render(<Filter whenLoaded={() => resolve()} />, filter);
})
);
}
}

@@ -44,7 +46,9 @@ let main = {
// Set up help text accordions where necessary:
let productBox = document.querySelector(`.product-detail .h1-heading`);
let productName = productBox ? productBox.textContent : `unknown product`;
let criteriaWithHelp = document.querySelectorAll(`.criterion button.toggle`);
let criteriaWithHelp = document.querySelectorAll(
`.criterion button.toggle`
);

if (criteriaWithHelp.length > 0) {
Array.from(criteriaWithHelp).forEach(button => {
@@ -75,11 +79,15 @@ let main = {
enableCopyLinks() {
if (document.querySelectorAll(`.copy-link`)) {
Array.from(document.querySelectorAll(`.copy-link`)).forEach(element => {
element.addEventListener(`click`, (event) => {
element.addEventListener(`click`, event => {
event.preventDefault();

let productBox = document.querySelector(`.product-detail .h1-heading`);
let productTitle = productBox ? productBox.textContent : `unknown product`;
let productBox = document.querySelector(
`.product-detail .h1-heading`
);
let productTitle = productBox
? productBox.textContent
: `unknown product`;

ReactGA.event({
category: `product`,
@@ -105,20 +113,31 @@ let main = {
let votes = element.querySelector(`input[name=votes]`).value;

try {
votes = JSON.parse(votes.replace(/'/g,`"`));
votes = JSON.parse(votes.replace(/'/g, `"`));
} catch (e) {
votes = {
creepiness: {
average: 50,
'vote_breakdown': {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0}
vote_breakdown: { "0": 0, "1": 0, "2": 0, "3": 0, "4": 0 }
},
confidence: {'0': 0, '1': 0}
confidence: { "0": 0, "1": 0 }
};
}

apps.push(new Promise(resolve => {
ReactDOM.render(<CreepVote csrf={csrf.value} productName={productName} productID={parseInt(productID,10)} votes={votes} whenLoaded={() => resolve()}/>, element);
}));
apps.push(
new Promise(resolve => {
ReactDOM.render(
<CreepVote
csrf={csrf.value}
productName={productName}
productID={parseInt(productID, 10)}
votes={votes}
whenLoaded={() => resolve()}
/>,
element
);
})
);
});
}

@@ -128,9 +147,17 @@ let main = {
Array.from(creepometerTargets).forEach(element => {
let initialValue = element.dataset.initialValue;

apps.push(new Promise(resolve => {
ReactDOM.render(<Creepometer initialValue={initialValue} whenLoaded={() => resolve()}/>, element);
}));
apps.push(
new Promise(resolve => {
ReactDOM.render(
<Creepometer
initialValue={initialValue}
whenLoaded={() => resolve()}
/>,
element
);
})
);
});
}

0 comments on commit b9adc34

Please sign in to comment.
You can’t perform that action at this time.