Skip to content

Commit

Permalink
Eslint 8 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
rizowski authored Nov 8, 2021
1 parent 55d06ff commit 59d4809
Show file tree
Hide file tree
Showing 40 changed files with 957 additions and 2,918 deletions.
17 changes: 0 additions & 17 deletions .babelrc

This file was deleted.

19 changes: 3 additions & 16 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
{
"parser": "babel-eslint",
"extends": "rizowski",
"env": {
"es6": true
},
"parserOptions": {
"sourceType": "module"
},
"rules": {
"brace-style": "error",
"comma-dangle": ["error", "always-multiline"],
"keyword-spacing": "error",
"quotes": ["error", "single", { "avoidEscape": true }],
"space-before-blocks": "error",
"space-infix-ops": "error"
}
"extends": ["xo-space", "prettier"],
"plugins": ["prettier"],
"rules": {}
}
6 changes: 6 additions & 0 deletions .husky/_/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

[ -n "$CI" ] && exit 0

yarn lint-staged --allow-empty
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
12
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "10"
- "12"
- "14"
- "16"
os:
- linux
# - osx
Expand Down
98 changes: 50 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![](https://img.shields.io/badge/release-notes-blue.svg)](https://github.com/rizowski/eslint-watch/releases/latest)
[![Build Status](https://travis-ci.org/rizowski/eslint-watch.svg?branch=master)](https://travis-ci.org/rizowski/eslint-watch)
[![Coverage Status](https://coveralls.io/repos/github/rizowski/eslint-watch/badge.svg?branch=dep-coverage)](https://coveralls.io/github/rizowski/eslint-watch?branch=dep-coverage)
[![Code Climate](https://codeclimate.com/github/rizowski/eslint-watch/badges/gpa.svg)](https://codeclimate.com/github/rizowski/eslint-watch)
[![Dependencies](https://www.versioneye.com/nodejs/eslint-watch/reference_badge.svg?style=flat-square)](https://github.com/rizowski/eslint-watch/network/dependencies)

Expand All @@ -13,19 +12,16 @@ Eslint Watch is a simple command line tool that wraps [Eslint](https://www.npmjs

To use this tool we require eslint to be installed on your project. The versions supported are:

- `"eslint": ">=7 <8.0.0"`
- `node >= 10.0.0 <= LTS` Non LTS versions will have limited support.
- `"eslint": ">=8 <9.0.0"`
- `node >= 12.0.0 <= LTS` Non LTS versions will have limited support.

## Getting started

To run eslint-watch without the global install, make an npm script.

### NPM
### Installing

- `npm i -g eslint eslint-watch` or `npm i -D eslint eslint-watch`

### Yarn

- `yarn global add eslint eslint-watch` or `yarn add -D eslint eslint-watch`

## Features added
Expand All @@ -43,69 +39,75 @@ To run eslint-watch without the global install, make an npm script.
Eslint-Watch replaces only a few commands that it needs to take control over. All other commands are forwarded to Eslint unmodified. Please refer to their help text for full command support as the one provided below might not be up to date with the latest Eslint changes.

```md
esw [options][file.js ...] [dir ...]
esw [options] [file.js ...] [dir ...]

ESW Options:
-h, --help Show help
-w, --watch Enable file watch
--changed Enables single file linting while watch is enabled
--clear Clear terminal when running lint
-v, --version Prints Eslint-Watch Version
--versions Prints Eslint-Watch and Eslint Versions
--watch-ignore RegExp Regex string of folders to ignore when watching - default: /.git|node_modules|bower_components/
--watch-delay Int Delay(ms) for watcher to wait to trigger re-lint - default: 300
-h, --help Show help
-w, --watch Enable file watch
--changed Enables single file linting while watch is enabled
--clear Clear terminal when running lint
-v, --version Prints Eslint-Watch Version
--versions Prints Eslint-Watch and Eslint Versions
--watch-ignore RegExp Regex string of folders to ignore when watching - default:
/.git|node_modules|bower_components|.eslintcache/
--watch-delay Int Delay(ms) for watcher to wait to trigger re-lint - default: 300

Basic configuration:
--ext [String] Specify JavaScript file extensions - default: .js
--no-eslintrc Disable use of configuration from .eslintrc._
-c, --config path::String Use this configuration, overriding .eslintrc._ config options if present
--env [String] Specify environments
--global [String] Define global variables
--parser String Specify the parser to be used
--parser-options Object Specify parser options
--resolve-plugins-relative-to path::String A folder where plugins should be resolved from CWD by default
--ext [String] Specify JavaScript file extensions - default: .js
--no-eslintrc Disable use of configuration from .eslintrc.*
-c, --config path::String Use this configuration, overriding .eslintrc.* config options if present
--env [String] Specify environments
--global [String] Define global variables
--parser String Specify the parser to be used
--parser-options Object Specify parser options
--resolve-plugins-relative-to path::String A folder where plugins should be resolved from CWD by default

Specifying rules and plugins:
--rulesdir [path::String] Use additional rules from this directory
--plugin [String] Specify plugins
--rule Object Specify rules
--rulesdir [path::String] Use additional rules from this directory
--plugin [String] Specify plugins
--rule Object Specify rules

Fixing problems:
--fix Automatically fix problems
--fix-dry-run Automatically fix problems without saving the changes to the file system
--fix-type Array Specify the types of fixes to apply (problem suggestion, layout)
--fix Automatically fix problems
--fix-dry-run Automatically fix problems without saving the changes to the file system
--fix-type Array Specify the types of fixes to apply (directive problem, suggestion, layout)

Ignoring files:
--ignore-path path::String Specify path of ignore file
--no-ignore Disable use of ignore files and patterns
--ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)
--ignore-path path::String Specify path of ignore file
--no-ignore Disable use of ignore files and patterns
--ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)

Using stdin:
--stdin Lint code provided on <STDIN> - default: false
--stdin-filename String Specify filename to process STDIN as
--stdin Lint code provided on <STDIN> - default: false
--stdin-filename String Specify filename to process STDIN as

Handling warnings:
--quiet Report errors only - default: false
--max-warnings Int Number of warnings to trigger nonzero exit code - default: -1
--quiet Report errors only - default: false
--max-warnings Int Number of warnings to trigger nonzero exit code - default: -1

Output:
-o, --output-file path::String Specify file to write report to
-f, --format String Use a specific output format - default: stylish
--color, --no-color Force enabling/disabling of color
-o, --output-file path::String Specify file to write report to
-f, --format String Use a specific output format - default: stylish
--color, --no-color Force enabling/disabling of color

Inline configuration comments:
--no-inline-config Prevent comments from changing config or rules
--report-unused-disable-directives Adds reported errors for unused eslint-disable directives
--no-inline-config Prevent comments from changing config or rules
--report-unused-disable-directives Adds reported errors for unused eslint-disable directives

Caching:
--cache Only check changed files - default: false
--cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
--cache-location path::String Path to the cache file or directory
--cache Only check changed files - default: false
--cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
--cache-location path::String Path to the cache file or directory
--cache-strategy String Strategy to use for detecting changed files in the cache - either: metadata or content - default:
metadata

Miscellaneous:
--init Run config initialization wizard - default: false
--debug Output debugging information
--print-config path::String Print the configuration for the given file
--init Run config initialization wizard - default: false
--env-info Output execution environment information - default: false
--no-error-on-unmatched-pattern Prevent errors when pattern is unmatched
--exit-on-fatal-error Exit with exit code 2 in case of fatal error - default: false
--debug Output debugging information
--print-config path::String Print the configuration for the given file
```

### Other Options
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
version: "{build}"
environment:
matrix:
- nodejs_version: 10
- nodejs_version: 12
- nodejs_version: 14
- nodejs_version: 16
install:
- ps: Install-Product node $env:nodejs_version
- npm install
Expand Down
4 changes: 1 addition & 3 deletions bin/esw
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env node
require('core-js/stable');
require('source-map-support/register');
const path = require('path');

const esw = require(path.join(__dirname, '..', 'build'));
const esw = require(path.join(__dirname, '..', 'src'));

esw
.run(process.argv)
Expand Down
75 changes: 30 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
{
"name": "eslint-watch",
"version": "7.0.0",
"version": "8.0.0",
"description": "Run eslint with watch mode",
"main": "./build",
"main": "./src",
"scripts": {
"build": "babel src -d build -s inline",
"ci:win": "npm run lint && npm test",
"ci:test": "npm run lint && npm run coverage",
"ci:test": "npm run lint && npm run test",
"clean": "rm -rf build node_modules",
"coverage": "nyc npm test",
"deploy": "./scripts/deploy.sh",
"prepare": "husky install",
"lint:watch": "node ./bin/esw -w",
"lint": "node ./bin/esw",
"mocha": "mocha",
"mocha": "mocha --recursive --timeout 10000 -r tests/globals.js",
"postcoverage": "nyc report --reporter=text-lcov | coveralls",
"prepare": "npm run build",
"test:integration": "npm run mocha -- --opts ./tests/mocha-integration.opts",
"test:unit": "npm run mocha -- --opts ./tests/mocha-unit.opts",
"test:integration": "yarn mocha ./tests/integration/**/*spec.js",
"test:unit": "yarn mocha ./tests/unit/**/*spec.js",
"test:watch": "npm run test -- -R min -b -w",
"test": "npm run mocha -- --opts ./tests/mocha.opts"
"test": "yarn mocha ./tests/**/**/**/*spec.js"
},
"engines": {
"node": ">=10"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"repository": {
"type": "git",
Expand All @@ -32,7 +31,7 @@
},
"files": [
"bin",
"build",
"src",
"package.json",
"README.md"
],
Expand All @@ -50,19 +49,12 @@
"email": "[email protected]"
},
"license": "MIT",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"npm run lint -- --fix"
],
"*.{js,css,json}": [
"npm run lint -- --fix",
"prettier --write --print-width=160"
],
"*.md": [
"*.{md,json,yaml,yml}": [
"prettier --write --print-width=80"
]
},
Expand All @@ -71,42 +63,35 @@
},
"homepage": "https://github.com/rizowski/eslint-watch",
"peerDependencies": {
"eslint": ">=7 <8.0.0"
"eslint": ">=8 <9.0.0"
},
"dependencies": {
"chokidar": "^3.1.1",
"core-js": "^3.2.1",
"debug": "^4.1.0",
"execa": "^4.0.1",
"chokidar": "^3.5.2",
"debug": "^4.3.2",
"execa": "^5.1.1",
"keypress": "^0.2.1",
"lodash.debounce": "^4.0.8",
"lodash.isempty": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.kebabcase": "^4.1.1",
"lodash.unionwith": "^4.6.0",
"optionator": "^0.9.1",
"source-map-support": "^0.5.13"
"optionator": "^0.9.1"
},
"devDependencies": {
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/register": "^7.6.0",
"babel-eslint": "^10.0.3",
"babel-plugin-add-module-exports": "^1.0.0",
"chai": "^4.2.0",
"coveralls": "^3.0.6",
"eslint": "^7.0.0",
"eslint-config-rizowski": "^1.1.4",
"eslint-plugin-fp": "^2.3.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.2",
"mocha": "^7.1.2",
"chai": "^4.3.4",
"coveralls": "^3.1.1",
"eslint": "^8",
"eslint-config-prettier": "^8.3.0",
"eslint-config-xo-space": "^0.30.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"mocha": "^9.1.3",
"mocha-lcov-reporter": "^1.3.0",
"mocha-sinon": "^2.0.0",
"nyc": "^15.0.1",
"prettier": "^2.0.5",
"sinon": "^9.0.2",
"sinon-chai": "^3.3.0"
"nyc": "^15.1.0",
"prettier": "^2.4.1",
"sinon": "^12.0.1",
"sinon-chai": "^3.7.0"
}
}
13 changes: 7 additions & 6 deletions src/cli/options.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import unionwith from 'lodash.unionwith';
import optionator from 'optionator';
import kebab from 'lodash.kebabcase';
import { createLogger } from '../logger';
const path = require('path');
const unionwith = require('lodash.unionwith');
const optionator = require('optionator');
const kebab = require('lodash.kebabcase');
const { createLogger } = require('../logger');

const logger = createLogger('options');

Expand Down Expand Up @@ -75,10 +75,11 @@ function areEqual(opt1, opt2) {
if (opt1.heading && opt2.heading) {
return opt1.heading === opt2.heading;
}

return opt1.alias === opt2.alias && opt1.option === opt2.option && opt1.type === opt2.type;
}

export default {
module.exports = {
get eswOptions() {
return [...defaultOptions];
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/clear.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
module.exports = {
name: 'clear',
trigger(options) {
return options.clear;
Expand Down
Loading

0 comments on commit 59d4809

Please sign in to comment.