Giter Site home page Giter Site logo

fullstackacademy / eslint-config-fullstack Goto Github PK

View Code? Open in Web Editor NEW
16.0 19.0 26.0 2.67 MB

A complete ESLint config file to help students avoid errors and learn best practices

License: MIT License

JavaScript 100.00%
eslint fullstack-academy eslint-config eslintrc eslint-rules eslint-shareable-configs eslintconfig best-practices students

eslint-config-fullstack's Introduction

eslint-config-fullstack

Built at Fullstack Academy npm version Build Status Greenkeeper badge

Installation

Global

Global installation is recommended for Fullstack Education Group students. To install or upgrade the config along with its peer dependencies:

npm install -g eslint eslint-config-fullstack eslint-plugin-react babel-eslint

In your global ~/.eslintrc.json file:

{
    "extends": "fullstack"
}

Note that the eslint-config- portion of the module name is assumed by ESLint.

Local

A specific project can extend this definition by including eslint eslint-config-fullstack eslint-plugin-react babel-eslint as saved dev-dependencies, and defining a local .eslintrc.json. Project-level eslintrc files are recommended to be set as root, which prevents users' global configs from producing inconsistent results:

{
    "extends": "fullstack",
    "root": true
}

Note on Parsing

This config now uses babel-eslint as the parser by default. This enables linting some relatively modern code which ESLint's default parser does not handle, and was necessary for this project to lint itself. You still need to install babel-eslint manually as it is a peer dependency of this config.

Extending

Any rules added to your global or local .eslintrc.json files will override the rules defined by this package. For example:

{
    "extends": "fullstack",
    "rules": {
        "semi": [1, "always"]
    }
}

This turns on enforcing the use of semicolons, a rule which is silenced by default in the current version of the eslint-config-fullstack package.

Background

The ESLint linting system is a popular one for its support of ES6 syntax, pluggable rules, automatic rule names in warning messages, and shareable / extendable config files.

This npm package provides a thorough starting config file. It was developed at Fullstack Academy of Code / Grace Hopper Academy to use in an educational setting, helping students to avoid definite errors but also pick up best practices.

Because it defaults to supporting multiple environments (e.g. Node, browsers, Jasmine, Mocha, etc.) it is probably not suitable for general production, where one might want a finer-grained and more restrictive config. However it is easy to override and extend this base config with custom rules, as explained above and in the ESLint docs.

License

MIT

eslint-config-fullstack's People

Contributors

fterdal avatar glebec avatar greenkeeper[bot] avatar greenkeeperio-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eslint-config-fullstack's Issues

Allow shadowing of same values ignored by no-unused-vars

Sometimes when you are forced to initialize a variable (e.g. object destructuring to get the "rest" of the props) you want to ignore that variable. Using _ as the variable name is a convention taken from other languages (where it is sometimes more than just a convention). However, _ variables can trigger the no-shadow rule if you have nested uses.

We should upgrade our no-shadow to use the allow prop as explained at https://eslint.org/docs/rules/no-shadow#allow. We should allow any variables that are ignored under no-unused-vars.

Disable camelcase rule?

camelcase: 1, // enforce camelcase naming convention

This rule enforces that variables use camelCase. This can be a problem with Sequelize entities that use snake_case. We don't always run into this because often Sequelize defaults to using camelCase unless instructed otherwise, but when it is an issue it becomes pretty annoying.

OTOH it is good to teach the students idiomatic naming conventions.

babel-eslint v8.2.6 required

eslint-config-fullstack requires babel-eslint v8.2.6 but does not support a newer version.

It pops an error "UNMET PEER DEPENDENCY". In need of update or modified to accept later versions of babel-eslint.

Remove `id-length`?

@Rinaldo stated:

id-length is annoying if you want to use variable names like a and b in the callback to a sort function

I used to be more strongly against single-letter variable names for most use cases, but once in a blue moon they are fine, and I think making the linter complain about them is maybe heavy-handed. I'll look into possibly relaxing this rule.

Newest eslint breaks this plugin

Expected Behavior

Running npm install -g eslint eslint-config-fullstack eslint-plugin-react babel-eslint and creating the file ~/.eslintrc.json with the following contents:

{
  "extends": "fullstack",
  "parser": "babel-eslint",
  "rules": {
    "semi": [1, "always"]
  }
}

Will make eslint work, as per the instructions in the workshop.

Actual Behavior

Running eslint generates the following error message:

Oops! Something went wrong! :(

ESLint: 6.0.1.

ESLint couldn't find the config "fullstack" to extend from. Please check that the name of the config is correct.

The config "fullstack" was referenced from the config file in "/Users/joshua/.eslintrc.json".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.

Temporary Workaround

Downgrading eslint to version 5.0.1 works. I modified the instructions to:

npm install -g [email protected] eslint-config-fullstack eslint-plugin-react babel-eslint

And everything worked perfectly.

Disable camel case rule

People naturally learn that camelCase is idiomatic JS. But sometimes it's convenient to be able to use underscore_case, e.g. for Sequelize properties. It's annoying for the linter to yell about this.

Remove `no-nested-ternary`

@Rinaldo stated:

I’ve taken to using ternaries instead of if-else chains in some situations, so I disable no-nested-ternary

I agree somewhat. I think nested ternaries can be abused, but I no longer feel strongly that it is worth linting against.

Add a11y plugin

Fullstack would like to add a11y techniques as part of the curriculum. Adding eslint-plugin-jsx-a11y to this repo as a peer dep, with associated ruleset customized for our purposes, would be a passive win along those lines.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.