Coder Social home page Coder Social logo

alx-backend-javascript's Introduction

ALX BackEnd JavaScript | ES6

This repository has all ES6 JavaScript projects

Setup

Install NodeJS 12.11.x

This version of Node is very old, and in the changing world of development
you don't want to replace your current version of node with an older version.
To solve this, we need to use Node Version Manager (nvm) to be able to manage
and use multiple versions of node depending on the requirement for our project.

1. Install nvm from the nvm repository

Open your terminal and execute the following series of commands to install
and source the newly installed nvm (this is easier than restarting your terminal emurator)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
source ~/.bashrc
nvm -v

2. Install the required node version through nvm

Now, with nvm you can install the desired node version without messing
with the existing one(s).
Execute the the following series of commands to install the desired node version.

Note: This will install and set your terminal session to use the newly installed
node version for the current terminal session.

nvm install v12.11
nvm use v12.11
node -v
npm -v

Install Jest, Babel, and ESLint

In your project directory, install Jest, Babel and ESList by using the supplied
package.json and run npm install.

Configuration files

Add following files below to your project directory:

package.json

{
  "scripts": {
    "lint": "./node_modules/.bin/eslint",
    "check-lint": "lint [0-9]*.js",
    "dev": "npx babel-node",
    "test": "jest",
    "full-test": "./node_modules/.bin/eslint [0-9]*.js && jest"
  },
  "devDependencies": {
    "@babel/core": "^7.6.0",
    "@babel/node": "^7.8.0",
    "@babel/preset-env": "^7.6.0",
    "eslint": "^6.4.0",
    "eslint-config-airbnb-base": "^14.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jest": "^22.17.0",
    "jest": "^24.9.0"
  }
}

babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
}

.eslintrc.js

module.exports = {
  env: {
    browser: false,
    es6: true,
    jest: true,
  },
  extends: [
    'airbnb-base',
    'plugin:jest/all',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: ['jest'],
  rules: {
    'no-console': 'off',
    'no-shadow': 'off',
    'no-restricted-syntax': [
      'error',
      'LabeledStatement',
      'WithStatement',
    ],
  },
  overrides:[
    {
      files: ['*.js'],
      excludedFiles: 'babel.config.js',
    }
  ]
};

Finally, run npm install from the terminal of your project folder
to install all necessary project dependencies.

Note: Most of these packages if not all of them are deprecated - they are used here
For the sole purpose of learning and the project requirements. If you are using this guide
to do this project then you can safely ignore the warnings, but if you are looking for a
guide to do your project, I recommend you visit the sites (links in the references section)
to check how to use the latest versions of the packages.

References

Node Version Manager Repository (nvm)
Node Package Manager (npm)
Getting Started with ESLint
Getting Started with Jest
Learn Node.js

alx-backend-javascript's People

Contributors

namestarlit avatar

Watchers

 avatar

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.