npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-config-blueflag

v0.11.1

Published

[![eslint-config-blueflag npm](https://img.shields.io/npm/v/eslint-config-blueflag.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-blueflag)

Downloads

476

Readme

Blue Flag linting configurations

eslint-config-blueflag npm

Installation

npm install eslint-config-blueflag
// .eslintrc
{
    "extends": [
        "eslint-config-blueflag",
        "eslint-config-blueflag/flow.js" // With flow types
    ]
}

Global linters (Sublime Linter)

If your linter can't handle using the current directory to find binaries you will need to install the plugins globally. Make sure you install eslint 2.4.0 though. The babel parser is having issues with later versions.

# Defaults
# [email protected]
# eslint-plugin-react
# 
# Flow Types
# eslint-plugin-flow-vars
# eslint-plugin-flowtype

# one liner
npm install -g [email protected] eslint-plugin-flow-vars eslint-plugin-flowtype [email protected] babel-eslint

Style Guide

JSX

Return JSX elements directly

// Good
return <ul className="List">
    <li>list items</li>
    <li>list items</li>
</ul>;

// Bad
return (
    <ul className="List">
        <li>list items</li>
        <li>list items</li>
    </ul>
);

####Find and replace Find: return(\s+?)\((\s+?)<

Automatic find and replaces are hard for this. You can replace return(\s+?)\((\s+?)< with return <, find the closing ); and replace it with ; and de-indent all lines between.

Use self-closing tags for elements without children

// Good
return <span />;

// Bad
return <span></span>;

Multiple line components should have each prop on a new line, indented once

// Good
return <ExampleComponent
    title="Example"
    author="Robert"
>
    <p>Child elements</p>
</ExampleComponent>;

return <ExampleComponent
    title="Example"
    author="Robert"
/>

// Bad
return <ExampleComponent title="Example"
    description="Hello"
>
    <p>Child elements</p>
</ExampleComponent>;

return <ExampleComponent
        title="Example"
        description="Hello">
    <p>Child elements</p>
</ExampleComponent>;

Find and replace

Find: \s+?$\s+?(/?>;?)(\s*?) Replace: $1\n and then fix up indentation

JS

Chains of functions should be indented by 4 spaces

// Good
return fromJS(list)
    .map(ii => ii.get('id'))
    .sort()
    .toJS();

// Bad
return fromJS(list).map(ii => ii.get('id')).sort().toJS();

return fromJS(list)
       .map(ii => ii.get('id'))
       .sort()
       .toJS();

Named imports should not have spaces between braces and words

// Good
import React, {Component, Children} from 'react';

// Bad
import React, { Component, Children } from 'react';

Naming

  • Never pluralize.

Filenames should use TitleCase

// Good
Button.jsx
CreateRoutes.js

// Bad
button.jsx
createRoutes.js

Folders should always be camelCase

// Good
src/users/
src/learningPlan/

// Bad
src/Users/
src/learning_plan/

Route paths should be kebab-case

// Good
http://example.com/free-hugs

// Bad
http://example.com/freeHugs
http://example.com/free_hugs

Action Names should follow SEGMENT_NOUN_VERB

Underscores are reserved for the division of concept not word spaces

// Good
COURSE_ASSIGNEE_CHANGE
COURSE_DEFAULTASSIGNEE_CHANGE


// Bad
COURSECHANGE
CHANGE_COURSE_DEFAULT_ASSIGNEE
CHANGE_COURSE
courseChange

Action Creators should be lowerCamelCase of ActionName

// Good COURSE_ASSIGNEE_CHANGE
courseAssigneeChange()

// Bad COURSE_ASSIGNEE_CHANGE
changeCourseAssignee()
dispatchCourseAssignee()
COURSE_ASSIGNEE_CHANGE()

Errors

"Expected string but got object"

Often caused by a require() requiring a file that's using export default. Ensure all require()s of components with export default use import instead.

"inst.render is not a function"

In React <0.15 this can happen when functional components try to return null. They must return an empty <span/> instead. This has been fixed as of React 0.15