Skip to content

Commit

Permalink
ci: update (#5)
Browse files Browse the repository at this point in the history
* ci: update stuff

* ci: generate coverage, fix token

* ci: more updates and fixes

* Create calm-islands-fetch.md

* docs: update readme

* docs: update readme again
  • Loading branch information
roikoren755 authored Nov 10, 2021
1 parent 7e0e8c6 commit 020f56d
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 234 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-islands-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-es-roikoren": patch
---

ci: update
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ module.exports = {
'no-case-declarations': OFF,
'no-console': WARN,
'no-constructor-return': ERROR,
'no-continue': WARN,
'no-else-return': ERROR,
'no-eval': ERROR,
'no-extend-native': ERROR,
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: 0 0 * * 0

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install Packages
run: yarn install --frozen-lockfile
- name: Deduplicate yarn.lock
run: yarn deduplicate --list --fail
- name: Lint
run: yarn lint
- name: Type
run: yarn type

test:
name: Test

strategy:
matrix:
eslint: [5, 6, 7, 8]
node: [12, 14, 16]
os: [ubuntu-latest]
include:
# On other platforms
- eslint: 8
node: 16
os: windows-latest
- eslint: 8
node: 16
os: macos-latest

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install Packages
run: yarn install --frozen-lockfile
- name: Install ESLint ${{ matrix.eslint }}
run: yarn add eslint@${{ matrix.eslint }} -D
- name: Test
run: yarn test
- name: Coverage
run: yarn coverage
- name: Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/test.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

yarn lint-staged
yarn deduplicate --list --fail

yarn update
git add docs/ src/configs/ src/index.ts
142 changes: 135 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# eslint-plugin-es-roikoren

[![Test Status](https://github.com/roikoren755/eslint-plugin-es/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/roikoren755/eslint-plugin-es/actions/workflows/test.yml?query=branch%3Amain)
[![codecov](https://codecov.io/gh/roikoren755/eslint-plugin-es/branch/main/graph/badge.svg?token=RF5L5KQQN6)](https://codecov.io/gh/roikoren755/eslint-plugin-es)

[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=roikoren755_eslint-plugin-es&metric=bugs)](https://sonarcloud.io/dashboard?id=roikoren755_eslint-plugin-es)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=roikoren755_eslint-plugin-es&metric=code_smells)](https://sonarcloud.io/dashboard?id=roikoren755_eslint-plugin-es)
Expand All @@ -23,15 +24,142 @@
[![Lines of code](https://img.shields.io/tokei/lines/github/roikoren755/eslint-plugin-es)](https://www.github.com/roikoren755/eslint-plugin-es)
[![GitHub top language](https://img.shields.io/github/languages/top/roikoren755/eslint-plugin-es)](https://www.github.com/roikoren755/eslint-plugin-es)

A re-implementation of `eslint-plugin-es`, compatible with `eslint@8`.
A re-implementation of `eslint-plugin-es` in TypeScript.

### Installation
## Disclaimer
First off, I would like to deeply thank [@mistycatea](https://github.com/mysticatea) and everyone else involved in the original `eslin-plugin-es`. None of this would have been possible without them, and all credit should go to them.

Run `npm i -D eslint-plugin-es-roikoren` (or `yarn add -D eslint-plugin-es-roikoren`) to add this package to your project's `devDependencies`.
This package is an attempt to migrate `eslint-config-es` to be written in TypeScript, and to use the great [`@typescript-eslint`](https://github.com/typescript-eslint) repository for plugin development.

### Usage
Below is taken verbatim from [`eslint-plugin-es`](https://github.com/mysticatea/eslint-plugin-es), and will be updated as needed.

In your `.eslintrc.js` (or any other file you use to configure eslint),
add the config you want from this package to the `extends` field.
## 🏁 Goal

TODO
[Espree](https://github.com/eslint/espree#readme), the default parser of [ESLint](https://eslint.org/), has supported `ecmaVersion` option.
However, the error messages of new syntax are not readable (e.g., "unexpected token" or something like).

When we use this plugin along with the latest `ecmaVersion` option value, it tells us the readable error message for the new syntax, such as "ES2020 BigInt is forbidden."
Plus, this plugin lets us disable each syntactic feature individually.

## 💿 Installation

Use [npm](https://www.npmjs.com/) or a compatible tool.

```console
npm install --save-dev eslint eslint-plugin-es-roikoren

yarn add -D eslint eslint-plugin-es-roikoren
```

**IMPORTANT**

If you installed `eslint` globally, you should install this plugin in the same way.

::: tip Requirements
- Node.js `12.22.0` or newer.
- ESLint `5.16.0` or newer.
:::

## 📖 Usage

Configure your `.eslintrc.*` file.

For example, to enable only Rest/Spread Properties in ES2018, as similar to legacy `experimentalObjectRestSpread` option:

```json
{
"plugins": ["es-roikoren"],
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"es-roikoren/no-async-iteration": "error",
"es-roikoren/no-malformed-template-literals": "error",
"es-roikoren/no-regexp-lookbehind-assertions": "error",
"es-roikoren/no-regexp-named-capture-groups": "error",
"es-roikoren/no-regexp-s-flag": "error",
"es-roikoren/no-regexp-unicode-property-escapes": "error"
}
}
```

### Presets

This plugin provides the following configs.

| Config ID | Description |
|:----------|:------------|
| `plugin:es-roikoren/restrict-to-es2019` | disallow new stuff that ES2019 doesn't include.
| `plugin:es-roikoren/restrict-to-es2018` | disallow new stuff that ES2018 doesn't include.
| `plugin:es-roikoren/restrict-to-es2017` | disallow new stuff that ES2017 doesn't include.
| `plugin:es-roikoren/restrict-to-es2016` | disallow new stuff that ES2016 doesn't include.
| `plugin:es-roikoren/restrict-to-es2015` | disallow new stuff that ES2015 doesn't include.
| `plugin:es-roikoren/restrict-to-es5` | disallow new stuff that ES5 doesn't include.
| `plugin:es-roikoren/restrict-to-es3` | disallow new stuff that ES3 doesn't include.
| `plugin:es-roikoren/no-new-in-es2020` | disallow the new stuff in ES2020.
| `plugin:es-roikoren/no-new-in-es2019` | disallow the new stuff in ES2019.
| `plugin:es-roikoren/no-new-in-es2018` | disallow the new stuff in ES2018.
| `plugin:es-roikoren/no-new-in-es2017` | disallow the new stuff in ES2017.
| `plugin:es-roikoren/no-new-in-es2016` | disallow the new stuff in ES2016.
| `plugin:es-roikoren/no-new-in-es2015` | disallow the new stuff in ES2015.
| `plugin:es-roikoren/no-new-in-es5` | disallow the new stuff in ES5.
| `plugin:es-roikoren/no-new-in-esnext` | disallow the new stuff to be planned for the next yearly ECMAScript snapshot.<br>⚠️ This config will be changed in the minor versions of this plugin.

For example:

```json
{
"parserOptions": {
"ecmaVersion": 2021
},
"extends": [
"eslint:recommended",
"plugin:es-roikoren/restrict-to-es2018"
],
"rules": {
"es-roikoren/no-rest-spread-properties": "off"
}
}
```

### The `aggressive` mode

This plugin never reports prototype methods by default. Because it's hard to know the type of objects, it will cause false positives.

If you configured the `aggressive` mode, this plugin reports prototype methods even if the rules couldn't know the type of objects.
For example:

```json
{
"plugins": ["es-roikoren"],
"rules": {
"es-roikoren/no-string-prototype-codepointat": "error"
},

// `settings.es.aggressive = true` means the aggressive mode.
"settings": {
"es": { "aggressive": true }
}
}
```

If using this plugin and TypeScript, this plugin reports prototype methods by default because we can easily know types.
For example:

```json
{
"plugins": ["es-roikoren"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"rules": {
"es-roikoren/no-string-prototype-codepointat": "error"
}

// If you configured the `aggressive` mode, this plugin reports prototype methods on `any` types as well.
// "settings": {
// "es": { "aggressive": true }
// }
}
```
Loading

0 comments on commit 020f56d

Please sign in to comment.