Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@lyvly/eslint-config
Advanced tools
# install the package
yarn add -D @lyvly/eslint-config
# install peer deps
yarn add -D babel-eslint@10.1 eslint-plugin-import@2.2 eslint-plugin-jest@23.8
# if you're using react
yarn add -D eslint-plugin-jsx-a11y@6.2 eslint-plugin-react@7.18 eslint-plugin-react-hooks@2
# in your eslint config
module.exports = {
extends: ['@lyvly'],
settings: {
'import/resolver': {
'babel-module': {},
},
},
};
An approach to JavaScript that mostly follows AirBnB's guidelines with some minor tweaks
// Preferred 🚀
// ------------
export const myFunction = () => {}
// Avoid 👎
// --------
const myFunction = () => {}
export default myFunction
// Avoid 👎
// --------
export default () => {}
Why?
jest.mock
on the entire module, and then modify its implementation on a test-by-test basis: // Preferred 🚀
// ------------
import { myFunction } from './myFunction'
jest.mock('./myFunction')
describe('myModule', () => {
it('does one thing', () => {
myFunction.mockReturnValue('foo')
})
it('does another thing', () => {
myFunction.mockReturnValue('bar')
})
})
// Preferred 🚀
// ------------
import * as memberDomain from './memberDomain'
memberDomain.create()
memberDomain.update()
// Avoid 👎
// --------
import { create, update } from './memberDomain'
create()
update()
// Preferred 🚀
// ------------
memberDomain.create()
memberDomain.update()
// Avoid 👎
memberDomain.createMember()
memberDomain.updateMember()
Why?
memberDomain.create
will write to the database, while memberApi.create
will call an api.parseResponse
or authenticate
), put it in its own file. // Preferred 🚀
// ------------
import { parseResponse } from './parseResponse'
parseResponse()
// Avoid 👎
// --------
import * as parseResponse from './parseResponse'
parseResponse.parseResponse()
utils
folder except for truly global things. // Preferred 🚀
// ------------
it('finds an existing member', () => {
// Seed the database
memberDomain.create({ firstName: 'Homer', lastName: 'Simpson' })
const member = memberDomain.find({ firstName: 'Homer' })
expect(member).toEqual({ firstName: 'Homer', lastName: 'Simpson' })
})
it('updates an existing member', () => {
// Seed the database
memberDomain.create({ firstName: 'Homer', lastName: 'Simpson' })
const member = memberDomain.update({ firstName: 'Homer' }, { firstName: 'Marge' })
expect(member).toEqual({ firstName: 'Marge', lastName: 'Simpson' })
})
// Avoid 👎
// --------
beforeEach(() => {
// Seed the database
memberDomain.create({ firstName: 'Homer', lastName: 'Simpson' })
})
it('finds an existing member', () => {
const member = memberDomain.find({ firstName: 'Homer' })
expect(member).toEqual({ firstName: 'Homer', lastName: 'Simpson' })
})
it('updates an existing member', () => {
const member = memberDomain.update({ firstName: 'Homer' }, { firstName: 'Marge' })
expect(member).toEqual({ firstName: 'Marge', lastName: 'Simpson' })
})
Why?
Related to this:
Why?
Rules of Thumb
The rules are the same as for the backend, except for the following exceptions:
Why?
// If your React component looks like this:
export const Title = () => {
return (
<p>Lyvly</p>
)
}
export default compose(
inject('listingStore'),
observer
)(Title)
// Then your test can use the named export:
import { Title } from './Title'
describe('<Title />', () => {
it('matches snapshot', () => {
// No mocking of MobX required!
expect(Title).toMatchSnapshot()
})
})
Why?
// For a file structure that looks like this:
// Title/
// -- Title.js
// -- Title.props.js
// -- Title.style.js
// -- Title.storybook.js
// -- index.js
// If we have an index file like this:
import Title from './Title'
export default Title
// We can import the Title component like this:
import Title from '@components/Title'
// Rather than like this:
import Title from '@components/Title/Title'
FAQs
Lyvly standard ESLint configs
The npm package @lyvly/eslint-config receives a total of 0 weekly downloads. As such, @lyvly/eslint-config popularity was classified as not popular.
We found that @lyvly/eslint-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.