ljharb on master
[eslint config] [base] [patch] … [eslint config] [patch] extend … Merge pull request #1996 from r… (compare)
ljharb on master
[editorial] [react] fix typo [eslint config] [*] [deps] upda… (compare)
For some odd reason, create-react-app
gives me the following error with eslint 7 😕
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^6.6.0"
and asks me to
const getR = async()=>(
await fetch("http://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=077fe507985744818b3f405349c79601")
).json();
(async ()=>{
const articles=(await getR()).articles;
articles.map(({title,description},index)=>{
(
value+index = title
description+index = description
)
}).join('')
})();
opentok.createSession(function (err, session) {
if (err) return console.log(err);
const token = session.generateToken({
role: 'moderator',
expireTime: (new Date().getTime() / 1000) + (1 * 24 * 60 * 60), // in one day
data: 'name=ajay',
initialLayoutClassList: ['focus']
});
return { sessionId: session.sessionId,token:token}
});
can any one tell me how to get these value in a variable ?
Can anyone please explain this part of the airbnb style guide to me?
https://github.com/airbnb/javascript#arrays--mapping
It says:
4.6 Use Array.from instead of spread ... for mapping over iterables, because it avoids creating an intermediate array.
// bad
const baz = [...foo].map(bar);
// good
const baz = Array.from(foo, bar);
But I don't understand why you wouldn't instead do:
const baz = foo.map(bar);
foo.map(bar)
is fine. If it's a non-array iterable
, then use Array.from
to prevent converting to an array just to use map
11.2 Don’t use generators for now.
Why? They don’t transpile well to ES5.
React
portion of the guide to be updated further? Given the way it refers to function components as stateless
and only recommending them if you don't have state or refs, I feel like it hasn't been updated to reflect the introduction of hooks
Hi there
I have an async function which I would like to convert to an Observable stream (using rxjs operators). The await
calls must execute in the order they appear in the function.
async authenticateUser(profile: Profile): Promise<any> {
let authCookie: any;
try {
authCookie = await getCookie();
} catch (error) {
console.error(error);
}
if (!authCookie || authCookie?.length < 1) {
cancelAuthenticationCookieGet();
throw {message: "login failed", status: -2};
}
await saveProfileAsync(profile);
await storeCurrentAuthCookieAsync(authCookie);
storeSessionStorage();
await setPartitionSessionCookie(profile.url, authCookie);
}
Is there a clean way to accomplish the above?
description is :
Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. You can also manipulate, traverse, and in some ways simulate runtime given the output.
jest
yarn create react-app ...
and by default I got setupTests.js
file with import '@testing-library/jest-dom/extend-expect';
@testing-library...
packages
setupTests.js
file according to the enzyme
test runner instead of default @testing-library...