ScandiPWA (deprecated)
User ManualGitHubSlack
  • ScandiPWA (deprecated)
  • React & PWA for dummies
    • Setting Up Environment and Talking Theory
    • Learning React Hands-on
    • Styling It
    • Learning ScandiPWA Way
  • START & UPGRADE
    • Linux Docker setup
    • Mac Docker setup
    • Setting up the theme with remote M2 server
    • Theme Upgrade to the latest version
    • Automated setup (BETA)
  • A TO Z OVERVIEW
    • Motivation
    • Challenges
    • File structure and UI components
    • Rewriting and Extending A Theme
  • DESCRIPTION OF CONTAINERS
    • Ngrok
  • FAQ
    • Development
    • Installation
    • Billing and license
    • Product support
    • What is PWA?
  • HOW-TO TUTORIALS - INTRODUCTORY
    • Base template
    • Connecting to the GraphQL resolver
    • Extension mechanism
    • Creating GraphQL resolver
    • Debugging and Inspecting
    • Setting Up Frontend
    • File Structure
    • Data Flow
    • Technology Stack
    • Changing environment
    • Theme Build and Configuration
    • Implementing Caching for New Caching Identities
    • Implementing a parent theme
  • HOW-TO TUTORIALS - INTERMEDIATE
    • Debugging in Chrome
    • Configuring XDebug
    • CLI in Docker
    • Postman & GraphQL Playground
    • VSCode Extensions
    • Plugins: implementing
    • Plugins: using and publishing
    • ESlint & StyleLint
    • How To Contribute
    • Migrating to a Newer Version
    • Installation on Existing Magento 2 Sever
    • BEM and Coding Standards
    • Tools of ScandiPWA
    • React Best Practices
  • FAQ
    • Untitled
Powered by GitBook
On this page
  • ScandiPWA Recommended Linters:
  • Starting Out With Lint
  • Linting In Practice
  1. HOW-TO TUTORIALS - INTERMEDIATE

ESlint & StyleLint

PreviousPlugins: using and publishingNextHow To Contribute

Last updated 4 years ago

ScandiPWA Recommended Linters:

  • - linter for ECMAScript or JavaScript

  • - linter for your styles - CSS, SCSS and Less

Starting Out With Lint

Open the scandipwa-base/src/app/design/frontend/Scandiweb/pwa folder.

For this extension to work, you need to install the ESLint library in your project’s folder, if it’s not there it’ll look for a global install. To install eslint run:

npm install eslint      # run this in the workspace folder
npm install -g eslint   # global install

Look for the .eslintrc.sample file. Remove the .sample postfix in orded to create our own ESLint configuration.

If the configuration file is not present you can press ctrl + p in VSCode and search for >Create ESLint configuration or run eslint in terminal.

For a global installation run eslint --init, for local - ./node_modules/.bin/eslint --init for Linux and Mac.

Additionally, you can open up the terminal and run npm run eslint and this will scan the project for linter issues.

Run npm run eslint -- --fix to fix any issues, if they are found.

More of the available command presets can be seen in the base-theme/package.json file ‘script’ field. Some of these commands are:

"eslint": "eslint ./src/app --ignore-pattern *.test.*",

"eslint:fix": "npm run eslint -- --fix",

"eslint:cache": "eslint ./src/app --cache --ignore-pattern *.test.*",

"stylelint": "stylelint ./src/**/*.scss",

"stylelint:fix": "npm run stylelint -- --fix",

"stylelint:cache": "stylelint --cache ./src/**/*.scss"

Linting In Practice

Press ctrl + p and search for >ScandiPWA: Extend source component.

Select AddToCart, skip class container and select ‘Extend them!’ which will only extend the styles. This will create and open the AddToCart.override.style.scss file which, at the moment, will look like this:

.AddToCart{

}

This will create a stylelint pop-up that’ll say Unexpected empty block. If now we run in terminal npm run stylelint:fix, we can check if something can be fixed.

Note:

You can run ESLint and style lint in GitHub actions

You can copy the configuration from .github folder, main.yml file and use the output commands to comment on the pull request.

Install and enable for VSCode and it’ll start to give you suggestions.

Just as with ESLint, you need to get the extension and install stylelint locally in your project’s folder, or copy the .stylelintrc file from the source folder into your project’s folder.

First you’ll need the ScandiPWA Developer Tools VSCode extension. Find out how to get started .

Go to and you’ll see an ESlint workflow.

ESLint
stylelint
here
ScandiPWA/base-theme actions
ESLint
stylelint
Write code usign ESlint and StyleLint