Skip to main content

Setting Up a Modern React Project with Linting, Formatting, Styling and Spell Checking

· 3 min read

When working on a React project, maintaining clean and consistent code is essential. This guide will walk you through setting up a React project with ESLint, Prettier, Stylelint, Husky, lint-staged, and cspell to automate code formatting, linting, and spell checking.

Step 1: Create a New React App

npx create-react-app my-app --use-npm
cd my-app

This sets up a new React project.


Step 2: Initialize Git

git init

Step 3: Install Dependencies

Install necessary development dependencies:

yarn add -D eslint prettier stylelint husky lint-staged stylelint-config-standard cspell stylelint-config-standard

Step 4: Configure ESLint

Initialize ESLint:

npx eslint --init

Modify .eslintrc.json:

{
"extends": ["react-app", "eslint:recommended", "plugin:prettier/recommended"],
"rules": {
"prettier/prettier": "error"
}
}

Create .eslintignore:

# Third party
**/node_modules

# Build products
build/
static/
docs/

Add ESLint Scripts to package.json

"scripts": {
"lint:ts": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings 0",
"lint:ts:fix": "eslint --fix \"./src/**/*.{ts,tsx}\" --max-warnings 0"
}

Step 5: Configure Prettier

Create .prettierrc:

{
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none"
}

Create .prettierignore:

.git
.github
.yarn
.husky
build
node_modules
static

Add Prettier Scripts to package.json

"scripts": {
"format": "prettier --write .",
"format:diff": "prettier --list-different ."
}

Step 6: Configure Stylelint

Create .stylelintrc:

{
"extends": "stylelint-config-standard",
"rules": {
"selector-class-pattern": null,
"value-keyword-case": ["lower", { "camelCaseSvgKeywords": true }]
}
}

Add Stylelint Scripts to package.json

"scripts": {
"lint:style": "stylelint \"**/*.css\"",
"lint:style:fix": "yarn lint:style --fix"
}

Step 7: Configure cspell (Spell Checker)

Initialize cspell:

npx cspell --init

Modify .cspell.json:

{
"version": "0.2",
"language": "en",
"ignorePaths": ["node_modules", "build", "static", ".docusaurus", "i18n"],
"dictionaryDefinitions": [
{
"name": "project-words",
"path": "./project-words.txt",
"noSuggest": true
}
],
"dictionaries": [
"css",
"html",
"fonts",
"typescript",
"softwareTerms",
"companies",
"lorem-ipsum",
"project-words"
]
}

Create a project-words.txt file to store custom words.

Add cspell Script to package.json

"scripts": {
"lint:spelling": "cspell \"docs/**/*.md\" \"blog/**/*.md\" \"src/**/*.js\" \"src/**/*.tsx\" \"docusaurus.config.js\" --no-progress --show-context --show-suggestions",
"lint:spelling:fix": "yarn rimraf project-words.txt && echo \"# Project Words - DO NOT TOUCH - This is updated through CI\" >> project-words.txt && yarn -s lint:spelling --words-only --unique --no-exit-code --no-summary \"**\" | cross-env LC_ALL=en_US.UTF-8 sort --ignore-case >> project-words.txt"
}

lint:spelling:fix does


Step 8: Configure Husky for Pre-Commit Hooks

Initialize Husky:

npx husky init

Add pre-commit hook:

echo "yarn run lint-staged" > .husky/pre-commit

Add pre-push hook:

echo "yarn run lint-staged" > .husky/pre-push

Step 9: Configure Lint-Staged

Modify package.json:

"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --fix --max-warnings=0",
"prettier --write",
"cspell --no-progress --show-context --show-suggestions"
],
"src/**/*.{css,scss}": [
"stylelint --fix",
"prettier --write"
],
"{docs,blog}/**/*.{md,mdx}": [
"cspell --no-progress --show-context --show-suggestions"
]
}

Step 10: Run the Setup

yarn lint:ts
yarn format
yarn lint:style
yarn lint:spelling

Conclusion

By following these steps, your React project is now set up with:

  • ESLint for code linting
  • Prettier for code formatting
  • Stylelint for CSS linting
  • cspell for spell checking
  • Husky & lint-staged for pre-commit checks

This ensures cleaner, more readable, and error-free code throughout your development process. 🚀

Static Code Analysis in a React App

· 3 min read

Introduction

Code quality is crucial in modern web development, ensuring that projects remain maintainable, readable, and free from potential issues. In this guide, we will set up static code analysis in a React project using Yarn, integrating the following tools:

  • Husky → Manages Git hooks to enforce linting before commits.
  • Lint-staged → Runs linters only on staged files for efficiency.
  • ESLint → Lints JavaScript/TypeScript code for better quality.
  • Prettier → Formats code automatically for consistency.
  • Stylelint → Lints and fixes CSS/SCSS code.

Let's dive into the step-by-step setup.


1️⃣ Installing Required Packages

Run the following command to install all necessary dependencies as dev dependencies:

yarn add -D husky lint-staged eslint prettier stylelint eslint-config-prettier eslint-plugin-prettier eslint-plugin-react stylelint-config-standard

Why these tools?

  • ESLint: Ensures consistent JavaScript/TypeScript code by enforcing best practices and detecting potential issues.
  • Prettier: Automatically formats code to maintain a uniform style.
  • Stylelint: Lints and fixes CSS/SCSS styles.
  • Husky: Hooks into Git workflows to run linters before committing changes.
  • Lint-staged: Runs linters only on staged files to improve efficiency.

2️⃣ Configuring ESLint

To configure ESLint, create a file named .eslintrc.json in the root directory and add the following content:

{
"extends": ["react-app", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}

Why ESLint?

✅ Catches syntax errors early.
✅ Helps maintain a consistent coding style.
✅ Enforces best practices in JavaScript and React development.


3️⃣ Configuring Prettier

To ensure consistent code formatting, create a .prettierrc.json file:

{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}

Why Prettier?

✅ Automatically formats code on save.
✅ Eliminates debates over code style.
✅ Works seamlessly with ESLint.


4️⃣ Configuring Stylelint

To enforce CSS/SCSS best practices, create a .stylelintrc.json file:

{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 2,
"string-quotes": "double"
}
}

Why Stylelint?

✅ Ensures consistent styling rules.
✅ Detects and fixes errors in CSS/SCSS.
✅ Avoids potential styling issues in projects.


5️⃣ Setting Up Husky & Lint-Staged

Installing Husky

Initialize Husky:

yarn husky install

Modify your package.json to include Husky and lint-staged:

"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"src/**/*.{css,scss}": [
"stylelint --fix",
"prettier --write"
]
}

Enable Pre-Commit Hook

Run the following command to enable Husky’s pre-commit hook:

yarn husky add .husky/pre-commit "yarn lint-staged"

Why Husky & Lint-Staged?

✅ Prevents committing bad code.
✅ Runs linters only on changed files (performance-friendly).
✅ Ensures consistent formatting and linting before every commit.


6️⃣ Running Linters Manually

To check code quality manually, run:

yarn lint       # Runs ESLint
yarn format # Runs Prettier
yarn stylelint # Runs Stylelint

Conclusion

By following these steps, we have successfully set up Husky, lint-staged, ESLint, Prettier, and Stylelint in a React project using Yarn. This setup ensures:

Better code quality
Automatic formatting
Enforced best practices
Prevention of bad code commits

With this configuration in place, your React project will maintain high coding standards, making it more maintainable and scalable! 🚀

A Divine Journey to Tirupati and Tirumala

· 3 min read

Tirupati and Tirumala, the abode of Lord Venkateswara, are among the most revered pilgrimage destinations in India. My recent visit to these sacred places was a blend of spirituality, nostalgia, and cultural exploration. Here’s a glimpse into my enriching experience.

Day 1: Beginning the Journey (21-Mar-2025)

The journey to Tirupati commenced with great enthusiasm. As we embarked on this spiritual quest, the anticipation of visiting the divine shrines and reconnecting with old memories added to the excitement.

Day 2: Exploring Chandragiri Fort (22-Mar-2025)

Our first stop was Chandragiri Fort, a historical gem that echoes the grandeur of the Vijayanagara Empire. The fort's architecture, along with the scenic beauty surrounding it, provided a captivating experience, offering a glimpse into the region’s glorious past.

Day 3: Nostalgic Reunions & Ancient Temples (23-Mar-2025)

Morning: SVGP Alumni Meet

Attending the SVGP alumni meet was a heartwarming experience. Reconnecting with old friends and faculty, sharing memories, and witnessing the progress of our institution made this gathering truly special.

Afternoon: Gudimallam Temple Visit

Later, we visited the Gudimallam Shiva Temple, a marvel from the 2nd century. Known for its ancient Lingam with unique carvings, the temple exuded an aura of mysticism and spiritual energy.

Day 4: Annual Day Celebrations & Student Interactions (24-Mar-2025)

Morning: SVGP Annual Day

The annual day celebration at SVGP was inspiring. It was remarkable to witness a 100% placement record, showcasing the institution’s dedication to academic excellence and career growth.

Afternoon: SVITSA Interaction

Later, I visited SVITSA and had an engaging session with the students. Their enthusiasm and curiosity towards learning and innovation were truly commendable.

Day 5: Tirumala Darshan & Temple Visits (25-Mar-2025)

The final day was the most spiritually fulfilling.

Darshan of Lord VenkateswaraThe divine darshan of Lord Venkateswara at Tirumala filled my heart with immense peace and devotion. The energy of the temple, combined with the collective prayers of thousands of devotees, made this experience unforgettable.

Sacred Places Visited:

  • Pushkarani – A holy water tank where devotees take a purifying dip before entering the temple.

  • Varaha Temple – Dedicated to Lord Varaha, an incarnation of Lord Vishnu.

  • Sri Krishna Temple – A serene temple radiating spiritual bliss.

  • Hayagriva Temple Abhishekam – Witnessing the Abhishekam ceremony at Hayagriva Temple was a soul-stirring experience.

Shopping & Book Collection

Before concluding the journey, I indulged in some spiritual shopping and collected books from TTD (Tirumala Tirupati Devasthanams), enriching my spiritual knowledge.

Conclusion

This journey to Tirupati and Tirumala was more than just a trip—it was a profound spiritual awakening. From reconnecting with old friends to seeking divine blessings, every moment was deeply fulfilling. If you seek a blend of history, culture, and spirituality, Tirupati is a must-visit destination! 🙏✨

7 Days Spiritual Awakening Journey: A Divine Experience

· 3 min read

Embark on a transformative 7-day spiritual journey exploring some of India’s most sacred places. This pilgrimage, starting from Gudivada, takes you through the heart of spiritual India, immersing you in devotion, history, and divine energy.

Day 1: The Journey Begins (20-Feb-2025)

Our sacred expedition commenced with a bus journey from Gudivada. To ensure a fulfilling and comfortable experience, chefs on the bus prepared nourishing meals, setting the tone for a spiritually enriching trip.

Day 2: Prayagraj – The Holy Kumbh Mela (23-Feb-2025)

Our first stop was Prayagraj (Allahabad), home to the Kumbh Mela, the largest religious gathering in the world. Pilgrims took a holy dip at the Triveni Sangam, where the Ganga, Yamuna, and the mystical Saraswati rivers converge, believed to cleanse sins and purify the soul.

Day 3: Ayodhya – The Land of Lord Rama (24-Feb-2025)

Ayodhya, the birthplace of Lord Rama, welcomed us with its spiritual grandeur. Key places visited included:

  • Ram Mandir – The majestic temple dedicated to Lord Rama.

  • Shiva Mandir – A serene temple devoted to Lord Shiva.

  • Birla Mandir – A beautifully crafted temple known for its spiritual ambiance.

  • Ayodhya Palace – A historic glimpse into the city’s royal past.

  • Shopping – Exploring local souvenirs and religious artifacts.

Day 4: Varanasi – The Eternal City (25-Feb-2025)

We arrived in the spiritual capital of India, Varanasi, and visited:

  • Manikarnika Ghat – Witnessing the sacred cremation rituals along the banks of the Ganges.

  • Shri Kashi Vishwanath Temple – A revered Shiva temple symbolizing divine energy.

  • Vishalakshi Temple – Dedicated to Goddess Vishalakshi, an incarnation of Goddess Parvati.

Day 4: Gaya – Moksha’s Gateway (25-Feb-2025)

Later that day, we proceeded to Gaya, an important pilgrimage site:

  • Vishnupadam Temple – A sacred shrine believed to have Lord Vishnu’s footprint.

  • Mangla Gowri Shakti Peetham – A powerful temple dedicated to Goddess Shakti.

  • Shopping – Exploring the spiritual markets for unique souvenirs.

Day 5: Puri – The Land of Lord Jagannath (26-Feb-2025)

Our journey led us to Puri, home to the Jagannath Temple, one of the Char Dham pilgrimage sites. The divine aura of Lord Jagannath’s idol and the temple’s spiritual essence left every devotee in awe.

Day 6: Annavaram – The Grace of Lord Satyanarayana Swamy (27-Feb-2025)

The final stop was Annavaram, where we visited the Satyanarayana Swamy Temple. The temple, situated atop a hill, offered a breathtaking view and a serene atmosphere for prayer and reflection.

Conclusion

This 7-day spiritual awakening journey was not just a pilgrimage but a profound experience of devotion, faith, and self-discovery. The sacred sites visited, the holy rituals performed, and the divine energy felt at each stop left a lasting spiritual imprint on all participants.

If you’re seeking inner peace and a closer connection to the divine, this journey is truly a once-in-a-lifetime experience! 🙏✨

Basics of Angular: Understanding Components

· 2 min read

Angular is a powerful front-end framework that allows developers to build dynamic, modern web applications. One of the fundamental building blocks of an Angular application is the Component. In this blog post, we will explore what an Angular component is, how it works, and different ways to define and style it.

What is a Component?

A Component in Angular is a reusable UI element that consists of three main parts:

  1. TypeScript class – Contains the logic and properties of the component.
  2. HTML template – Defines the structure and content to be displayed.
  3. CSS styles – Applies styles to the component.

Defining a Basic Angular Component

In Angular, a component is defined using the @Component decorator. Below is a simple example:

import { Component } from '@angular/core';

@Component({
selector: 'app-root',
template: `Hello, {{ title }} {{ 1 + 2 }}`,
styles: [`:host {color: red;}`],
})
export class AppComponent {
title: string = 'NBT'; // A class property holding a title
}

Explanation:

  • selector: Defines the custom HTML tag to use this component. For example, <app-root />.
  • template: Contains the HTML structure, where {{ title }} binds data dynamically.
  • styles: Contains inline styles specific to this component.

Output:

Hello, NBT 3

Using External Template and CSS Files

Instead of defining the template and styles directly within the component file, we can separate them into external files.

app.component.ts (Component Definition)

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'NBT';
}

app.component.html (Template File)

<main id="main">
<div class="content">
<h1>Hello, {{ title }}</h1>
</div>
</main>

<router-outlet />

app.component.css (Stylesheet)

.content {
color: blue;
font-size: 20px;
}

Output:

Hello, NBT

Conclusion

In this blog post, we learned:

  • What an Angular component is.
  • How to create a basic component.
  • How to use external HTML and CSS files to organize code better.

Components are a crucial part of Angular applications. By using them effectively, we can create modular, reusable, and maintainable applications. Stay tuned for more Angular tips and best practices!

Creating an Angular Application from Scratch

· 2 min read

Setting up an Angular application from scratch may seem daunting at first, but with Angular CLI, the process is streamlined and efficient. This guide walks you through the essential steps, from installing dependencies to running your project.

1. Install the Latest Node.js

Before setting up Angular, ensure that you have the latest version of Node.js installed. Angular relies on npm (Node Package Manager) for dependency management.

Steps to Install Node.js:

  • Download and install Node.js from the official Node.js website.

  • Verify the installation by running the following commands in your terminal:

    node -v
    npm -v

    These commands should return the installed versions of Node.js and npm.

  • Ensure compatibility with Angular by checking Angular's version compatibility guide.

2. Install Angular CLI

Angular CLI (Command Line Interface) is a tool that simplifies Angular development by providing useful commands for creating, building, and serving applications.

Install Angular CLI:

  • Using npm:

    npm install -g @angular/cli
  • Using yarn:

    yarn global add @angular/cli

Verify the Installation:

Run the following command to check if Angular CLI is installed correctly:

ng version

This will display the installed Angular CLI version and its dependencies.

3. Create a New Angular Project

Once Angular CLI is installed, you can create a new Angular workspace and project using the CLI:

ng new my-app

Configuration Options:

  • Replace my-app with your desired project name.
  • The CLI will prompt you to choose configurations, such as:
    • Whether to include Angular routing
    • Preferred CSS preprocessor (CSS, SCSS, LESS, etc.)

After the project is created, navigate into the project folder:

cd my-app

4. Run the Angular Application

To launch the Angular application locally, start the development server using:

ng serve --open

What Happens?

  • The --open flag automatically opens the application in your default web browser.
  • By default, the app runs on http://localhost:4200/.
  • The server continuously watches for file changes and reloads the app as you modify the code.

Conclusion

Congratulations! You have successfully set up and run your first Angular application. From here, you can start modifying components, services, and styles to build your project. Angular's powerful framework will help you create dynamic and scalable web applications effortlessly. Happy coding! 🚀

Trip to Sri Maddi Anjaneya Temple by Walk

· 2 min read
Dwaraka TirumalaMaddi Anjeneya - Gurvaigudem
 Dwaraka Tirumala Maddi Anjeneya Temple

Taken 3 Days for reaching temple and have darshan i.e from 10-11-2023 to 12-11-2023 by walk. It was a nice experience my iPhone Fitness app shows I had walked for entrie trip with 1st day as 50.55 km, 2nd Day 38.85 km and 3rd Day as 23.34 km Total 113 KM with pradakshanams and darshan etc.

My Books

· 2 min read

I am bibliophile or bookworm and loves reading and/or collects books through purchase in online and offline books stores from various places. So I got any thought to know how many books I had and how many books I had completed reading, So I had used the google sheets (online Excel) to list books with following columns

SNoTitleAuthorEditionPagesPages ReadShelvesDate ReadPriceCurrent PriceGenreSub-GenreType
1Think and Grow RichNapolian Hill1254254ReadDec-200050249Non FictionSelf ImprovementPaperback

Most of the columns are self explanatory other are explained below: