npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wdio-eslint-service

v0.0.3

Published

WDIO service to use ESLint

Downloads

274

Readme

wdio-eslint-service

WDIO service to use ESLint

wdio-eslint-service

This service makes a lot of sense when your tests and code are placed independently.

Installation

npm install wdio-eslint-service --save

Usage

wdio.config.js

{
	services: [
		'eslint'
	],

	eslintOptions: {
		files: ['**/*.js']
	}
}

Options

Custom options
  • cache — Only check changed files. In additional, we see your diff (for Git repositories).
  • files — This option allows you to specify which files will be used.
  • fix — True indicates that fixes should be included with the output report, and that errors and warnings should not be listed if they can be fixed. Your files on disk will be changed!
Standard options
  • extensions — Specify JavaScript / Typescript file extensions. Default: .js.
  • format — Use a specific output format. Default: node_modules/eslint-friendly-formatter
  • ...

In additional you can use all options and rules are available in ESLint.

TypeScript

Make sure you already have the following dependencies:

package.json

{
	"typescript": "^2.1.5",
	"eslint-plugin-typescript": "^0.1.0",
	"typescript-eslint-parser": "^1.0.3"
}

wdio.config.js

{
    services: [
        'eslint'
    ],

	eslintOptions: {
		extensions: ['.js', '.ts']
	}
}

eslintrc.js

{
	parser: 'typescript-eslint-parser',
	plugins: [ 'typescript' ],
	parserOptions: {
		sourceType: 'module',
		ecmaFeatures: {
			impliedStrict: true
		}
	}
}

These options can be added to wdio.config.js as well.

Rationale

Before:

package.json

{
	"scripts": {
		"test": "wdio wdio.conf.js",
		"lint": "eslint . --cache --format node_modules/eslint-friendly-formatter --ext .js"
	},

	"pre-commit": {
		"silent": true,

		"run": [
			"lint"
		]
	}
}

Or:

{
	"scripts": {
		"test": "eslint . --cache --format node_modules/eslint-friendly-formatter --ext .js && wdio wdio.conf.js"
	}
}

What if you want to run your ESLint task only locally? In this case, you should care about some environment variables on your server:

CI

SERVER_SIDE_ENV=npm test

utils/test.sh

#!/usr/bin/env bash

if [ -z $SERVER_SIDE_ENV ]
	then  eslint . --cache --format node_modules/eslint-friendly-formatter --ext .js
fi

wdio wdio.conf.js
{
	 "scripts": {
		"test": "source ./utils/test.sh"
	}
}

Do you like it? I don't think so.

After

.gitignore

wdio.conf.local.js

package.json

{
	"scripts": {
		"test": "test wdio.conf.local.js && wdio wdio.conf.local.js || wdio wdio.conf.js"
	}
}

wdio.conf.local.js

{
    services: [
        'eslint'
    ],
 
    eslintOptions: {
        files: ['**/*.js']
    }
}

So, you can have several configuration files for different environments and preferences. That's why wdio-eslint-service is so actual.

License

MIT