Skip to content

Commit 4267c5c

Browse files
committed
feat: initial rules
1 parent 0a02bf7 commit 4267c5c

32 files changed

+19127
-0
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!.eslintrc.js
2+
coverage
3+
lib

.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
const config = {
3+
root: true,
4+
parser: '@typescript-eslint/parser',
5+
parserOptions: {
6+
project: 'tsconfig.json',
7+
ecmaVersion: 2019,
8+
sourceType: 'module'
9+
},
10+
env: { node: true },
11+
plugins: ['eslint-plugin'],
12+
extends: ['ackama', 'ackama/@typescript-eslint'],
13+
ignorePatterns: ['!.eslintrc.js', 'coverage', 'lib'],
14+
overrides: [
15+
{
16+
files: ['test/**'],
17+
extends: ['ackama/jest'],
18+
rules: {
19+
'jest/prefer-expect-assertions': 'off'
20+
}
21+
}
22+
],
23+
rules: {
24+
'import/no-deprecated': 'error',
25+
'@typescript-eslint/no-unsafe-assignment': 'error',
26+
'@typescript-eslint/prefer-reduce-type-parameter': 'error'
27+
}
28+
};
29+
30+
module.exports = config;

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/eslint-compact.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "eslint-compact",
5+
"pattern": [
6+
{
7+
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5,
13+
"code": 6
14+
}
15+
]
16+
}
17+
]
18+
}

.github/eslint-stylish.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "eslint-stylish",
5+
"pattern": [
6+
{
7+
"regexp": "^([^\\s].*)$",
8+
"file": 1
9+
},
10+
{
11+
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
12+
"line": 1,
13+
"column": 2,
14+
"severity": 3,
15+
"message": 4,
16+
"code": 5,
17+
"loop": true
18+
}
19+
]
20+
}
21+
]
22+
}

.github/workflows/checks.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Checks
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- next
7+
pull_request:
8+
branches:
9+
- master
10+
- next
11+
12+
env:
13+
# reduces noise from npm post-install scripts
14+
DISABLE_OPENCOLLECTIVE: true
15+
OPEN_SOURCE_CONTRIBUTOR: true
16+
17+
jobs:
18+
commitlint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
- name: Commit Linter
25+
uses: wagoid/[email protected]
26+
with:
27+
configFile: './package.json'
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
test-node:
32+
name:
33+
# prettier-ignore
34+
Test on Node.js v${{ matrix.node-version }} and eslint v${{matrix.eslint-version }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
node-version: [8.x, 10.x, 12.x, 13.x, 14.x]
39+
eslint-version: [6, 7]
40+
exclude:
41+
# eslint@7 doesn't support node@8
42+
- node-version: 8.x
43+
eslint-version: 7
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: Use Node.js ${{ matrix.node-version }}
49+
uses: actions/setup-node@v1
50+
with:
51+
node-version: ${{ matrix.node-version }}
52+
- name: install with eslint v${{matrix.eslint-version }}
53+
run: |
54+
npm ci
55+
npm install -D eslint@${{matrix.eslint-version }}
56+
- name: prettylint
57+
run: npm run prettylint
58+
- name: typecheck
59+
run: npm run typecheck
60+
- name: test
61+
run: npm run test --coverage
62+
env:
63+
CI: true
64+
65+
test-os:
66+
name: Test on ${{ matrix.os }} using Node.js LTS
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
os: [ubuntu-latest, windows-latest, macOS-latest]
71+
runs-on: ${{ matrix.os }}
72+
73+
steps:
74+
- uses: actions/checkout@v2
75+
- uses: actions/setup-node@v1
76+
with:
77+
node-version: 12.x
78+
- name: install
79+
run: npm ci
80+
- name: prettylint
81+
run: npm run prettylint
82+
- name: typecheck
83+
run: npm run typecheck
84+
- name: test
85+
run: npm run test --coverage
86+
env:
87+
CI: true

.github/workflows/release.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
env:
8+
# reduces noise from npm post-install scripts
9+
DISABLE_OPENCOLLECTIVE: true
10+
OPEN_SOURCE_CONTRIBUTOR: true
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: '12.x'
20+
21+
- uses: actions/cache@v1
22+
with:
23+
path: ~/.npm
24+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
25+
restore-keys: |
26+
${{ runner.os }}-node-
27+
28+
- name: install
29+
run: npm ci
30+
- name: prettylint
31+
run: npm run prettylint
32+
- name: typecheck
33+
run: npm run typecheck
34+
- name: test
35+
run: npm run test --coverage
36+
env:
37+
CI: true
38+
39+
- name: release
40+
run: npm run release
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.huskyrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "http://json.schemastore.org/huskyrc",
3+
"hooks": {
4+
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
5+
"pre-commit": "lint-staged"
6+
}
7+
}

.lintstagedrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"**/*.{t,j}s": "eslint --fix",
3+
"**/.eslint{rc,ignore}": "npm run lint",
4+
"**/*.{md,json}": "prettier --write"
5+
}

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<div align="center">
2+
<a href="https://eslint.org/">
3+
<img
4+
width="150"
5+
height="150"
6+
src="https://eslint.org/assets/img/logo.svg"
7+
alt="ESLint Logo"
8+
/>
9+
</a>
10+
<h1>eslint-plugin-eslint-config</h1>
11+
<p>ESLint plugin for ESLint configs</p>
12+
</div>
13+
14+
This plugin provides rules for linting files that export configs meant for use
15+
with ESLint, to ensure that they're valid.
16+
17+
## Installation
18+
19+
npm install --dev eslint eslint-plugin-eslint-config
20+
21+
**Note:** If you installed ESLint globally then you must also install
22+
`eslint-plugin-eslint-config` globally.
23+
24+
## Usage
25+
26+
Add `config` to the plugins section of your `.eslintrc.js` configuration file.
27+
You can omit the `eslint-plugin-` prefix:
28+
29+
```json
30+
{
31+
"plugins": ["eslint-config"]
32+
}
33+
```
34+
35+
Then configure the rules you want to use _for your config(s)_ using `overrides`:
36+
37+
```json
38+
{
39+
"overrides": [
40+
{
41+
"files": [".eslintrc.js", "react.js", "@typescript-eslint.js"],
42+
"rules": {
43+
"eslint-config/no-deprecated-rules": "warn"
44+
}
45+
}
46+
]
47+
}
48+
```
49+
50+
The rules assume that the files they're linting are configs meant for ESLint.
51+
52+
## Shareable configurations
53+
54+
This plugin provides three presets:
55+
56+
- `recommended-rules`
57+
- `rc`
58+
- `all`
59+
60+
The `rc` preset generally should be used by all projects, as it applies
61+
recommended rules to supported eslintrc files.
62+
63+
If a project contains other files that export eslint configs (such as an eslint
64+
config package), the `recommended-rules` preset can be used to apply the
65+
recommended rules to those files using `overrides`.
66+
67+
<!-- The reason behind having two presets instead of the standard `recommended`
68+
preset is because the rules provided by this plugin work by executing the source
69+
code that they're linting to capture the configuration they export that gets
70+
used by eslint.
71+
72+
This means that they can trigger side effects in the same way importing a file
73+
might, and so should not be applied to every file in a code base.
74+
75+
To facilitate this ESLint allows configs to provide an `overrides` property that
76+
applies rules to files based on globs (which is what `eslint-config/rc` does),
77+
but while shared configs can use `overrides` there isn't a way to nicely to add
78+
to the glob patterns to reuse the rules. -->
79+
80+
While the `recommended` and `rc` configurations only change in major versions,
81+
the `all` configuration may change in any release and is thus unsuited for
82+
installations requiring long-term consistency.
83+
84+
## Rules
85+
86+
<!-- begin rules list -->
87+
88+
| Rule | Description | Configurations | Fixable |
89+
| -------------------------------------------------------- | --------------------------------------------------- | ---------------- | ------------ |
90+
| [no-deprecated-rules](docs/rules/no-deprecated-rules.md) | Checks for usage of deprecated eslint rules | ![recommended][] | |
91+
| [no-invalid-config](docs/rules/no-invalid-config.md) | Checks that the config exported by a file is valid | ![recommended][] | |
92+
| [no-unknown-rules](docs/rules/no-unknown-rules.md) | Ensures that all rules are known | ![recommended][] | |
93+
| [sort-rules](docs/rules/sort-rules.md) | Ensures that rules are sorted in a consistent order | | ![fixable][] |
94+
95+
<!-- end rules list -->
96+
97+
[recommended]: https://img.shields.io/badge/-recommended-lightgrey.svg
98+
[fixable]: https://img.shields.io/badge/-fixable-green.svg

0 commit comments

Comments
 (0)