How to create a custom ESLint plugin for function prefix | Rahul Sharma (DevsMitra)
How to create a custom ESLint plugin for function prefix | Rahul Sharma (DevsMitra)

Recently our development team decided to enforce the role for function naming. Meaning, all function name should start with the prefix defined in the eslint rule.
Instead of giving some random names to the function, strict developers follow some pre-defined conventions.

Example:

<button onclick=”someFunction()”>Login</button>
function someFunction() {}
<button onclick=”onLogin()”>Login</button>
function onLogin() {}

In the HTML button click, we can give any name we want. but when we read the code, the second function makes more sense. Let’s write a plugin that will warn us about wrong function naming.

JavaScript Naming Convention Best Practices

Boolean: is, are, has

Events: init, pre…


State Management with React Hooks and Context API
State Management with React Hooks and Context API
State Management with React Hooks and Context API

There are many ways how to handle global application state like Redux, MobX, etc. Do you remember all the stuff like the store, actions, and reducers in Redux? And then all those connect, mapStateToProps and other functions to be able to access the state?

Many React developers default to Redux for state management without considering other alternatives.

In this article, I will introduce the React Context API for state management and create a similar solution as Redux without using a third-party library.

React Context API

It’s actually not a new idea. Context API as part of React for a long time, but only…


Decorators Introduction:

A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter.

REST API’s using Node.js, Express.js & Typescript Decorators | 6Questions
REST API’s using Node.js, Express.js & Typescript Decorators | 6Questions

We’ll be using Method Decorators to develop routesDecorator.

Method Decorators:

A Method Decorator is declared just before a method declaration. The decorator is applied to the Property Descriptor for the method and can be used to observe, modify, or replace a method definition. A method decorator cannot be used in a declaration file, on overload, or in any other ambient context (such as in a declare class).

Definition referred from typescript official site, Check more details about…


Before ES6 there was only one way to declare the variables in Javascript using var. but there are issues associated with variables declared with var.

javascript var, let or const | 6Questions https://www.youtube.com/channel/UCQkvNcHN5vg3jEoeOb9Tdrw/
javascript var, let or const | 6Questions https://www.youtube.com/channel/UCQkvNcHN5vg3jEoeOb9Tdrw/

1. Scope: Scope essentially means where it can be used. or the lifetime of a variable.

a. var has a function-level scope. If we declare a variable inside the function using var it can applicable anywhere inside that function.

To understand further, look at the example below.

Rahul Sharma (DevsMitra)

I’m a software engineer who specializes in JavaScript, Node.js, React.js, Angular, Angular.js, Express.js, Typescript, and MongoDB.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store