Lint '/extras/*' #7252

Closed
infinite-persistence wants to merge 3 commits from x.lint.extras into master
7 changed files with 29 additions and 50 deletions

View file

@ -1,8 +1,10 @@
{ {
"linters": { "linters": {
"ui/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], "ui/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"],
"extras/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"],
"web/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], "web/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"],
"ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"], "ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"],
"extras/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"],
"web/**/*.{js,jsx}": ["eslint", "git add"] "web/**/*.{js,jsx}": ["eslint", "git add"]
}, },
"ignore": ["node_modules", "web/dist/**/*", "dist/**/*", "package-lock.json"] "ignore": ["node_modules", "web/dist/**/*", "dist/**/*", "package-lock.json"]

View file

@ -17,9 +17,6 @@ export const FETCH_CHANNEL_LIST_STARTED = 'FETCH_CHANNEL_LIST_STARTED';
export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED'; export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED';
export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED'; export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED';
export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED'; export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED';
export const PUBLISH_STARTED = 'PUBLISH_STARTED';
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
export const PUBLISH_FAILED = 'PUBLISH_FAILED';
export const SET_PLAYING_URI = 'SET_PLAYING_URI'; export const SET_PLAYING_URI = 'SET_PLAYING_URI';
export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION'; export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED'; export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
@ -29,10 +26,8 @@ export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL';
// Subscriptions // Subscriptions
export const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE'; export const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE';
export const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE'; export const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE';
export const CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS = export const CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS = 'CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS';
'CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS'; export const CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS = 'CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS';
export const CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS =
'CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS';
export const HAS_FETCHED_SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS'; export const HAS_FETCHED_SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS';
export const SET_SUBSCRIPTION_LATEST = 'SET_SUBSCRIPTION_LATEST'; export const SET_SUBSCRIPTION_LATEST = 'SET_SUBSCRIPTION_LATEST';
export const UPDATE_SUBSCRIPTION_UNREADS = 'UPDATE_SUBSCRIPTION_UNREADS'; export const UPDATE_SUBSCRIPTION_UNREADS = 'UPDATE_SUBSCRIPTION_UNREADS';

View file

@ -5,10 +5,6 @@ import Lbryio from './lbryio';
export { Lbryio }; export { Lbryio };
export function testTheThing() {
console.log('tested');
}
// constants // constants
export { LBRYINC_ACTIONS, YOUTUBE_STATUSES, ERRORS }; export { LBRYINC_ACTIONS, YOUTUBE_STATUSES, ERRORS };
@ -51,10 +47,7 @@ export {
selectAllCostInfoByUri, selectAllCostInfoByUri,
selectFetchingCostInfo, selectFetchingCostInfo,
} from './redux/selectors/cost_info'; } from './redux/selectors/cost_info';
export { export { selectBlackListedOutpoints, selectBlacklistedOutpointMap } from './redux/selectors/blacklist';
selectBlackListedOutpoints,
selectBlacklistedOutpointMap,
} from './redux/selectors/blacklist';
export { selectFilteredOutpoints, selectFilteredOutpointMap } from './redux/selectors/filtered'; export { selectFilteredOutpoints, selectFilteredOutpointMap } from './redux/selectors/filtered';
// export { // export {
// selectFeaturedUris, // selectFeaturedUris,
@ -62,11 +55,7 @@ export { selectFilteredOutpoints, selectFilteredOutpointMap } from './redux/sele
// selectTrendingUris, // selectTrendingUris,
// selectFetchingTrendingUris, // selectFetchingTrendingUris,
// } from './redux/selectors/homepage'; // } from './redux/selectors/homepage';
export { export { selectViewCount, makeSelectViewCountForUri, makeSelectSubCountForUri } from './redux/selectors/stats';
selectViewCount,
makeSelectViewCountForUri,
makeSelectSubCountForUri,
} from './redux/selectors/stats';
export { export {
selectHasSyncedWallet, selectHasSyncedWallet,
selectSyncData, selectSyncData,

View file

@ -14,7 +14,7 @@ const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000;
const INTERNAL_APIS_DOWN = 'internal_apis_down'; const INTERNAL_APIS_DOWN = 'internal_apis_down';
// We can't use env's because they aren't passed into node_modules // We can't use env's because they aren't passed into node_modules
Lbryio.setLocalApi = endpoint => { Lbryio.setLocalApi = (endpoint) => {
Lbryio.CONNECTION_STRING = endpoint.replace(/\/*$/, '/'); // exactly one slash at the end; Lbryio.CONNECTION_STRING = endpoint.replace(/\/*$/, '/'); // exactly one slash at the end;
}; };
@ -36,8 +36,8 @@ Lbryio.call = (resource, action, params = {}, method = 'get') => {
return Promise.reject(INTERNAL_APIS_DOWN); return Promise.reject(INTERNAL_APIS_DOWN);
} }
if (response) if (response) {
return response.json().then(json => { return response.json().then((json) => {
let error; let error;
if (json.error) { if (json.error) {
error = new Error(json.error); error = new Error(json.error);
@ -48,14 +48,15 @@ Lbryio.call = (resource, action, params = {}, method = 'get') => {
return Promise.reject(error); return Promise.reject(error);
}); });
} }
}
function makeRequest(url, options) { function makeRequest(url, options) {
return fetch(url, options).then(checkAndParse); return fetch(url, options).then(checkAndParse);
} }
return Lbryio.getAuthToken().then(token => { return Lbryio.getAuthToken().then((token) => {
const fullParams = { auth_token: token, ...params }; const fullParams = { auth_token: token, ...params };
Object.keys(fullParams).forEach(key => { Object.keys(fullParams).forEach((key) => {
const value = fullParams[key]; const value = fullParams[key];
if (typeof value === 'object') { if (typeof value === 'object') {
fullParams[key] = JSON.stringify(value); fullParams[key] = JSON.stringify(value);
@ -80,18 +81,18 @@ Lbryio.call = (resource, action, params = {}, method = 'get') => {
url = `${Lbryio.CONNECTION_STRING}${resource}/${action}`; url = `${Lbryio.CONNECTION_STRING}${resource}/${action}`;
} }
return makeRequest(url, options).then(response => response.data); return makeRequest(url, options).then((response) => response.data);
}); });
}; };
Lbryio.authToken = null; Lbryio.authToken = null;
Lbryio.getAuthToken = () => Lbryio.getAuthToken = () =>
new Promise(resolve => { new Promise((resolve) => {
if (Lbryio.authToken) { if (Lbryio.authToken) {
resolve(Lbryio.authToken); resolve(Lbryio.authToken);
} else if (Lbryio.overrides.getAuthToken) { } else if (Lbryio.overrides.getAuthToken) {
Lbryio.overrides.getAuthToken().then(token => { Lbryio.overrides.getAuthToken().then((token) => {
resolve(token); resolve(token);
}); });
} else if (typeof window !== 'undefined') { } else if (typeof window !== 'undefined') {
@ -122,7 +123,7 @@ Lbryio.authenticate = (domain, language) => {
language: language || 'en', language: language || 'en',
}; };
return new Promise(resolve => { return new Promise((resolve) => {
resolve(params); resolve(params);
}); });
} }
@ -130,15 +131,15 @@ Lbryio.authenticate = (domain, language) => {
if (Lbryio.authenticationPromise === null) { if (Lbryio.authenticationPromise === null) {
Lbryio.authenticationPromise = new Promise((resolve, reject) => { Lbryio.authenticationPromise = new Promise((resolve, reject) => {
Lbryio.getAuthToken() Lbryio.getAuthToken()
.then(token => { .then((token) => {
if (!token || token.length > 60) { if (!token || token.length > 60) {
return false; return false;
} }
// check that token works // check that token works
return Lbryio.getCurrentUser() return Lbryio.getCurrentUser()
.then(user => user) .then((user) => user)
.catch(error => { .catch((error) => {
if (error === INTERNAL_APIS_DOWN) { if (error === INTERNAL_APIS_DOWN) {
throw new Error('Internal APIS down'); throw new Error('Internal APIS down');
} }
@ -146,14 +147,14 @@ Lbryio.authenticate = (domain, language) => {
return false; return false;
}); });
}) })
.then(user => { .then((user) => {
if (user) { if (user) {
return user; return user;
} }
return Lbry.status() return Lbry.status()
.then( .then(
status => (status) =>
new Promise((res, rej) => { new Promise((res, rej) => {
const appId = const appId =
domain && domain !== 'lbry.tv' domain && domain !== 'lbry.tv'
@ -169,7 +170,7 @@ Lbryio.authenticate = (domain, language) => {
}, },
'post' 'post'
) )
.then(response => { .then((response) => {
if (!response.auth_token) { if (!response.auth_token) {
throw new Error('auth_token was not set in the response'); throw new Error('auth_token was not set in the response');
} }
@ -188,10 +189,10 @@ Lbryio.authenticate = (domain, language) => {
Lbryio.authToken = response.auth_token; Lbryio.authToken = response.auth_token;
return res(response); return res(response);
}) })
.catch(error => rej(error)); .catch((error) => rej(error));
}) })
) )
.then(newUser => { .then((newUser) => {
if (!newUser) { if (!newUser) {
return Lbryio.getCurrentUser(); return Lbryio.getCurrentUser();
} }
@ -211,10 +212,7 @@ Lbryio.getStripeToken = () =>
: 'pk_live_e8M4dRNnCCbmpZzduEUZBgJO'; : 'pk_live_e8M4dRNnCCbmpZzduEUZBgJO';
Lbryio.getExchangeRates = () => { Lbryio.getExchangeRates = () => {
if ( if (!Lbryio.exchangeLastFetched || Date.now() - Lbryio.exchangeLastFetched > EXCHANGE_RATE_TIMEOUT) {
!Lbryio.exchangeLastFetched ||
Date.now() - Lbryio.exchangeLastFetched > EXCHANGE_RATE_TIMEOUT
) {
Lbryio.exchangePromise = new Promise((resolve, reject) => { Lbryio.exchangePromise = new Promise((resolve, reject) => {
Lbryio.call('lbc', 'exchange_rate', {}, 'get', true) Lbryio.call('lbc', 'exchange_rate', {}, 'get', true)
.then(({ lbc_usd: LBC_USD, lbc_btc: LBC_BTC, btc_usd: BTC_USD }) => { .then(({ lbc_usd: LBC_USD, lbc_btc: LBC_BTC, btc_usd: BTC_USD }) => {

View file

@ -38,12 +38,12 @@
"build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null", "build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null",
"crossenv": "./node_modules/cross-env/dist/bin/cross-env", "crossenv": "./node_modules/cross-env/dist/bin/cross-env",
"flow": "flow", "flow": "flow",
"lint": "eslint 'ui/**/*.{js,jsx}' && eslint 'web/**/*.{js,jsx}' && eslint 'electron/**/*.js' && flow", "lint": "eslint 'ui/**/*.{js,jsx}' && eslint 'extras/**/*.{js,jsx}' && eslint 'web/**/*.{js,jsx}' && eslint 'electron/**/*.js' && flow",
"lint-fix": "eslint --fix --quiet 'ui/**/*.{js,jsx}' && eslint --fix --quiet 'web/**/*.{js,jsx}' && eslint --fix --quiet 'electron/**/*.js'", "lint-fix": "eslint --fix --quiet 'ui/**/*.{js,jsx}' && eslint --fix --quiet 'extras/**/*.{js,jsx}' && eslint --fix --quiet 'web/**/*.{js,jsx}' && eslint --fix --quiet 'electron/**/*.js'",
"format": "prettier 'src/**/*.{js,jsx,scss,json}' --write", "format": "prettier 'src/**/*.{js,jsx,scss,json}' --write",
"flow-defs": "flow-typed install", "flow-defs": "flow-typed install",
"precommit": "lint-staged", "precommit": "lint-staged",
"preinstall": "yarn cache clean lbry-redux && yarn cache clean lbryinc", "preinstall": "",
"postinstall": "cd web && yarn && cd .. && if-env NODE_ENV=production && yarn postinstall:warning || if-env APP_ENV=web && echo 'Done installing deps' || yarn postinstall:electron", "postinstall": "cd web && yarn && cd .. && if-env NODE_ENV=production && yarn postinstall:warning || if-env APP_ENV=web && echo 'Done installing deps' || yarn postinstall:electron",
"postinstall:electron": "electron-builder install-app-deps && node ./build/downloadDaemon.js && node ./build/downloadLBRYFirst.js", "postinstall:electron": "electron-builder install-app-deps && node ./build/downloadDaemon.js && node ./build/downloadLBRYFirst.js",
"postinstall:warning": "echo '\n\nWARNING\n\nNot all node modules were installed because NODE_ENV is set to \"production\".\nThis should only be set after installing dependencies with \"yarn\". The app will not work.\n\n'" "postinstall:warning": "echo '\n\nWARNING\n\nNot all node modules were installed because NODE_ENV is set to \"production\".\nThis should only be set after installing dependencies with \"yarn\". The app will not work.\n\n'"

View file

@ -133,9 +133,6 @@ export const FETCH_CHANNEL_LIST_STARTED = 'FETCH_CHANNEL_LIST_STARTED';
export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED'; export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED';
export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED'; export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED';
export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED'; export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED';
export const PUBLISH_STARTED = 'PUBLISH_STARTED';
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
export const PUBLISH_FAILED = 'PUBLISH_FAILED';
export const SET_PRIMARY_URI = 'SET_PRIMARY_URI'; export const SET_PRIMARY_URI = 'SET_PRIMARY_URI';
export const SET_PLAYING_URI = 'SET_PLAYING_URI'; export const SET_PLAYING_URI = 'SET_PLAYING_URI';
export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION'; export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';

View file

@ -19,7 +19,7 @@ import Lbry, { apiCall } from 'lbry';
import { isURIValid } from 'util/lbryURI'; import { isURIValid } from 'util/lbryURI';
import { setSearchApi } from 'redux/actions/search'; import { setSearchApi } from 'redux/actions/search';
import { doSetLanguage, doFetchLanguage, doUpdateIsNightAsync } from 'redux/actions/settings'; import { doSetLanguage, doFetchLanguage, doUpdateIsNightAsync } from 'redux/actions/settings';
import { Lbryio, doBlackListedOutpointsSubscribe, doFilteredOutpointsSubscribe, testTheThing } from 'lbryinc'; import { Lbryio, doBlackListedOutpointsSubscribe, doFilteredOutpointsSubscribe } from 'lbryinc';
import rewards from 'rewards'; import rewards from 'rewards';
import { store, persistor, history } from 'store'; import { store, persistor, history } from 'store';
import app from './app'; import app from './app';
@ -65,8 +65,6 @@ if (process.env.NODE_ENV === 'production') {
}); });
} }
testTheThing();
if (process.env.SDK_API_URL) { if (process.env.SDK_API_URL) {
console.warn('SDK_API_URL env var is deprecated. Use SDK_API_HOST instead'); // @eslint-disable-line console.warn('SDK_API_URL env var is deprecated. Use SDK_API_HOST instead'); // @eslint-disable-line
} }