@neolution-ch/eslint-config-neolution 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +58 -0
- package/.eslintrc.js +17 -0
- package/.github/workflows/ci.yml +46 -0
- package/.github/workflows/create-release.yml +51 -0
- package/.github/workflows/prepare-release.yml +66 -0
- package/CHANGELOG.md +18 -0
- package/README.md +44 -0
- package/index.js +10 -0
- package/package.json +42 -0
- package/rules/eslint.js +67 -0
- package/rules/import.js +33 -0
- package/rules/jsdoc.js +25 -0
- package/rules/next.js +17 -0
- package/rules/react.js +28 -0
- package/rules/typescript.js +197 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Neolution ❤ http://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# This file is the top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# All Files
|
|
7
|
+
[*]
|
|
8
|
+
charset = utf-8
|
|
9
|
+
end_of_line = crlf
|
|
10
|
+
indent_style = space
|
|
11
|
+
#indent_size = 4
|
|
12
|
+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
|
|
13
|
+
insert_final_newline = true
|
|
14
|
+
trim_trailing_whitespace = true
|
|
15
|
+
|
|
16
|
+
# Solution Files
|
|
17
|
+
[*.sln]
|
|
18
|
+
indent_size = 4
|
|
19
|
+
indent_style = tab
|
|
20
|
+
|
|
21
|
+
# XML Project Files
|
|
22
|
+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,njsproj}]
|
|
23
|
+
indent_size = 2
|
|
24
|
+
|
|
25
|
+
# Configuration Files
|
|
26
|
+
[*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset}]
|
|
27
|
+
indent_size = 2
|
|
28
|
+
|
|
29
|
+
# .NET Config Files
|
|
30
|
+
[*.{config}]
|
|
31
|
+
indent_size = 2
|
|
32
|
+
charset = utf-8-bom
|
|
33
|
+
|
|
34
|
+
# Markdown Files
|
|
35
|
+
[*.md]
|
|
36
|
+
end_of_line = lf
|
|
37
|
+
trim_trailing_whitespace = false
|
|
38
|
+
|
|
39
|
+
# Web Files
|
|
40
|
+
[*.{htm,html,js,ts,css,scss,less}]
|
|
41
|
+
indent_size = 2
|
|
42
|
+
insert_final_newline = true
|
|
43
|
+
|
|
44
|
+
# Razor Files
|
|
45
|
+
[*.cshtml]
|
|
46
|
+
indent_size = 2
|
|
47
|
+
charset = utf-8-bom
|
|
48
|
+
|
|
49
|
+
# Bash Files
|
|
50
|
+
[*.sh]
|
|
51
|
+
indent_size = 4
|
|
52
|
+
end_of_line = lf
|
|
53
|
+
|
|
54
|
+
# Dotnet Code Files
|
|
55
|
+
[*.{cs,csx,cake,vb}]
|
|
56
|
+
indent_size = 4
|
|
57
|
+
insert_final_newline = true
|
|
58
|
+
charset = utf-8-bom
|
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Disable typescript rules
|
|
2
|
+
const typescriptOff = Object.keys(require('@typescript-eslint/eslint-plugin').rules)
|
|
3
|
+
.reduce((acc, rule) => { acc[`@typescript-eslint/${rule}`] = 'off'; return acc }, {})
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
root: true,
|
|
7
|
+
env: {
|
|
8
|
+
es6: true,
|
|
9
|
+
node: true,
|
|
10
|
+
browser: true,
|
|
11
|
+
},
|
|
12
|
+
extends: ["@neolution-ch/eslint-config-neolution"],
|
|
13
|
+
parser: "espree", // restore original parser
|
|
14
|
+
rules: {
|
|
15
|
+
...typescriptOff
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [main]
|
|
7
|
+
types: [opened, reopened, synchronize, ready_for_review]
|
|
8
|
+
|
|
9
|
+
# cancel running actions for current PR if new commits were pushed
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
if: github.event.pull_request.draft == false
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: 18
|
|
23
|
+
cache: "yarn"
|
|
24
|
+
- run: yarn install --frozen-lockfile
|
|
25
|
+
- run: yarn lint
|
|
26
|
+
- run: yarn pack
|
|
27
|
+
|
|
28
|
+
check-changelog:
|
|
29
|
+
if: github.event.pull_request.draft == false
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v3
|
|
33
|
+
with:
|
|
34
|
+
fetch-depth: 0
|
|
35
|
+
|
|
36
|
+
- name: Get changed files
|
|
37
|
+
id: changed-files
|
|
38
|
+
uses: tj-actions/changed-files@v31
|
|
39
|
+
|
|
40
|
+
- name: Check if changelog was touched
|
|
41
|
+
run: |
|
|
42
|
+
changelogFound=$(echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -ow "CHANGELOG.md" | wc -w)
|
|
43
|
+
if [ $changelogFound -eq 0 ]; then
|
|
44
|
+
echo '### :boom: Please update the changelog accordingly (https://keepachangelog.com)' >> $GITHUB_STEP_SUMMARY
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Create Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
create-github-release:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Check out code
|
|
11
|
+
uses: actions/checkout@v3
|
|
12
|
+
|
|
13
|
+
- name: Initialize mandatory git config
|
|
14
|
+
run: |
|
|
15
|
+
git config user.name "GitHub Actions"
|
|
16
|
+
git config user.email noreply@github.com
|
|
17
|
+
|
|
18
|
+
- name: Setup release information
|
|
19
|
+
run: |
|
|
20
|
+
echo "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')" >> $GITHUB_ENV
|
|
21
|
+
|
|
22
|
+
- name: Extract release notes
|
|
23
|
+
id: extract_release_notes
|
|
24
|
+
uses: ffurrer2/extract-release-notes@v1
|
|
25
|
+
|
|
26
|
+
- name: Create Release
|
|
27
|
+
id: create_release
|
|
28
|
+
uses: actions/create-release@v1
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
with:
|
|
32
|
+
tag_name: ${{ env.PACKAGE_VERSION }}
|
|
33
|
+
release_name: v${{ env.PACKAGE_VERSION }}
|
|
34
|
+
body: ${{ steps.extract_release_notes.outputs.release_notes }}
|
|
35
|
+
draft: false
|
|
36
|
+
prerelease: false
|
|
37
|
+
|
|
38
|
+
publish-npm:
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
steps:
|
|
41
|
+
- name: Check out code
|
|
42
|
+
uses: actions/checkout@v3
|
|
43
|
+
- uses: actions/setup-node@v3
|
|
44
|
+
with:
|
|
45
|
+
node-version: 18
|
|
46
|
+
cache: "yarn"
|
|
47
|
+
registry-url: "https://registry.npmjs.org"
|
|
48
|
+
- run: yarn install --frozen-lockfile
|
|
49
|
+
- run: yarn publish --access public
|
|
50
|
+
env:
|
|
51
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NEOLUTION }}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Prepare Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
versionName:
|
|
7
|
+
description: "Name of version (ie 5.5.0)"
|
|
8
|
+
required: true
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
prepare-release:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: Check out code
|
|
15
|
+
uses: actions/checkout@v2
|
|
16
|
+
|
|
17
|
+
- name: Check the input version
|
|
18
|
+
run: |
|
|
19
|
+
versionNumber=${{ github.event.inputs.versionName }}
|
|
20
|
+
|
|
21
|
+
if [[ $versionNumber =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
|
|
22
|
+
echo '### :rocket: Preparing the release!' >> $GITHUB_STEP_SUMMARY
|
|
23
|
+
else
|
|
24
|
+
echo '### :boom: Please supply valid version according to the [Semantic Versioning](https://semver.org/) scheme.' >> $GITHUB_STEP_SUMMARY
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
- name: Create release branch
|
|
29
|
+
run: git checkout -b release/v${{ github.event.inputs.versionName }}
|
|
30
|
+
|
|
31
|
+
- name: Initialize mandatory git config
|
|
32
|
+
run: |
|
|
33
|
+
git config user.name "GitHub Actions"
|
|
34
|
+
git config user.email noreply@github.com
|
|
35
|
+
|
|
36
|
+
- name: Change version number and name
|
|
37
|
+
run: yarn version --no-git-tag-version --no-commit-hook --new-version ${{ github.event.inputs.versionName }}
|
|
38
|
+
|
|
39
|
+
- name: Update Changelog
|
|
40
|
+
uses: thomaseizinger/keep-a-changelog-new-release@v1
|
|
41
|
+
with:
|
|
42
|
+
version: ${{ github.event.inputs.versionName }}
|
|
43
|
+
|
|
44
|
+
- name: Commit changelog and manifest files
|
|
45
|
+
id: make-commit
|
|
46
|
+
run: |
|
|
47
|
+
git add package.json
|
|
48
|
+
git add CHANGELOG.md
|
|
49
|
+
git commit --message "Prepare release ${{ github.event.inputs.versionName }}"
|
|
50
|
+
echo "::set-output name=commit::$(git rev-parse HEAD)"
|
|
51
|
+
|
|
52
|
+
- name: Push new branch
|
|
53
|
+
run: git push origin release/v${{ github.event.inputs.versionName }}
|
|
54
|
+
|
|
55
|
+
- name: Create pull request into main
|
|
56
|
+
uses: thomaseizinger/create-pull-request@1.0.0
|
|
57
|
+
with:
|
|
58
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
59
|
+
head: release/v${{ github.event.inputs.versionName }}
|
|
60
|
+
base: main
|
|
61
|
+
title: v${{ github.event.inputs.versionName }} into main
|
|
62
|
+
reviewers: ${{ github.event.issue.user.login }}
|
|
63
|
+
body: |
|
|
64
|
+
Hi!
|
|
65
|
+
This PR was created in response workflow running.
|
|
66
|
+
I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2022-10-06
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Initial release
|
|
15
|
+
|
|
16
|
+
[Unreleased]: https://github.com/neolution-ch/eslint-config-neolution/compare/1.0.0...HEAD
|
|
17
|
+
|
|
18
|
+
[1.0.0]: https://github.com/neolution-ch/eslint-config-neolution/compare/5f308ef87fa2a779e56cb6af4510baf6e2deeb23...1.0.0
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# eslint-config-neolution
|
|
2
|
+
|
|
3
|
+
This package provides Neolution's .eslintrc as an extensible shared config.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# inside your project's working tree
|
|
9
|
+
yarn add -D @neolution-ch/eslint-config-neolution
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
Edit the `.eslintrc.js` of your project:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
module.exports = {
|
|
18
|
+
...
|
|
19
|
+
extends: ["@neolution-ch/eslint-config-neolution"],
|
|
20
|
+
...
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### React
|
|
25
|
+
|
|
26
|
+
For React project you might need to adjust the "@typescript-eslint/naming-convention" rule to allow PascalCase for component names.
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
module.exports = {
|
|
30
|
+
...
|
|
31
|
+
rules: {
|
|
32
|
+
"@typescript-eslint/naming-convention": ["error", {
|
|
33
|
+
selector: "default",
|
|
34
|
+
format: ["camelCase", "PascalCase"],
|
|
35
|
+
leadingUnderscore: "allow",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
selector: ["typeLike", "accessor", "enumMember"],
|
|
39
|
+
format: ["PascalCase"],
|
|
40
|
+
}],
|
|
41
|
+
}
|
|
42
|
+
...
|
|
43
|
+
}
|
|
44
|
+
```
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neolution-ch/eslint-config-neolution",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "This package provides Neolution's .eslintrc as an extensible shared config.",
|
|
5
|
+
"homepage": "https://github.com/neolution-ch/eslint-config-neolution",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prelint": "git ls-files | xargs eclint check",
|
|
12
|
+
"lint": "eslint \"**/*.js\" --cache --max-warnings 0",
|
|
13
|
+
"upgradeAll": "npm-check-updates --packageFile ./package.json -u"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/neolution-ch/eslint-config-neolution"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Neolution",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@next/eslint-plugin-next": "^12.3.1",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
24
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
25
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
26
|
+
"eslint-import-resolver-typescript": "^3.5.1",
|
|
27
|
+
"eslint-plugin-import": "^2.26.0",
|
|
28
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
29
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
30
|
+
"eslint-plugin-react": "^7.31.8",
|
|
31
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"eslint": "^8.20.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"eclint": "^2.8.1",
|
|
38
|
+
"eslint": "^8.24.0",
|
|
39
|
+
"npm-check-updates": "^16.3.8",
|
|
40
|
+
"typescript": "^4.8.4"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/rules/eslint.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"eslint-config-airbnb",
|
|
4
|
+
].map(require.resolve),
|
|
5
|
+
|
|
6
|
+
// View link below for eslint rules documentation
|
|
7
|
+
// https://eslint.org/docs/latest/rules/
|
|
8
|
+
rules: {
|
|
9
|
+
// The airbnb config enforce that class methods use "this", but requires changing how you call the method
|
|
10
|
+
// https://eslint.org/docs/latest/rules/class-methods-use-this
|
|
11
|
+
"class-methods-use-this": "off",
|
|
12
|
+
|
|
13
|
+
// The airbnb config enforces consistent return, but we got problems with some external libraries, TypeScript enforces this anyway
|
|
14
|
+
// https://eslint.org/docs/latest/rules/consistent-return
|
|
15
|
+
"consistent-return": "off",
|
|
16
|
+
|
|
17
|
+
// The airbnb config forces unix style, but somebody also works on windows
|
|
18
|
+
// https://eslint.org/docs/latest/rules/linebreak-style
|
|
19
|
+
"linebreak-style": "off",
|
|
20
|
+
|
|
21
|
+
// The airbnb config limits to 100 ignoring some lines, instad we allow 160 but don't ignore lines
|
|
22
|
+
// https://eslint.org/docs/rules/max-len
|
|
23
|
+
"max-len": ["error", 160, 2, {
|
|
24
|
+
ignoreComments: false,
|
|
25
|
+
ignoreTrailingComments: false,
|
|
26
|
+
ignoreUrls: false,
|
|
27
|
+
ignoreStrings: false,
|
|
28
|
+
ignoreTemplateLiterals: false,
|
|
29
|
+
ignoreRegExpLiterals: false,
|
|
30
|
+
}],
|
|
31
|
+
|
|
32
|
+
// The airbnb config disallow await inside of loops, but it cannot always be avoided
|
|
33
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
34
|
+
"no-await-in-loop": "off",
|
|
35
|
+
|
|
36
|
+
// The airbnb config disallow use of the continue statement, but it's ok to have it
|
|
37
|
+
// https://eslint.org/docs/latest/rules/no-continue
|
|
38
|
+
"no-continue": "off",
|
|
39
|
+
|
|
40
|
+
// The airbnb config disallow use of unary operators (++ and --), but it's ok to have them
|
|
41
|
+
// https://eslint.org/docs/rules/no-plusplus
|
|
42
|
+
"no-plusplus": "off",
|
|
43
|
+
|
|
44
|
+
// The airbnb config also restrict ForOfStatement, but we want to use it
|
|
45
|
+
// https://eslint.org/docs/latest/rules/no-restricted-syntax
|
|
46
|
+
"no-restricted-syntax": [
|
|
47
|
+
"error",
|
|
48
|
+
{
|
|
49
|
+
selector: "ForInStatement",
|
|
50
|
+
message: "for..in loops iterate over the entire prototype chain, which is virtually never what you want. "
|
|
51
|
+
+"Use Object.{keys,values,entries}, and iterate over the resulting array.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
selector: "LabeledStatement",
|
|
55
|
+
message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
selector: "WithStatement",
|
|
59
|
+
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
|
|
63
|
+
// The airbnb config forces single quote, but we prefer double quote
|
|
64
|
+
// https://eslint.org/docs/latest/rules/quotes
|
|
65
|
+
quotes: ["error", "double", { avoidEscape: true }],
|
|
66
|
+
},
|
|
67
|
+
};
|
package/rules/import.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"plugin:import/recommended"
|
|
4
|
+
],
|
|
5
|
+
|
|
6
|
+
plugins: [
|
|
7
|
+
"import",
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
settings: {
|
|
11
|
+
"import/resolver": {
|
|
12
|
+
node: {
|
|
13
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// View link below for import rules documentation
|
|
19
|
+
// https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
|
|
20
|
+
rules: {
|
|
21
|
+
// same as airbnb but with ts/tsx extensions
|
|
22
|
+
"import/extensions": [
|
|
23
|
+
"error",
|
|
24
|
+
"ignorePackages",
|
|
25
|
+
{
|
|
26
|
+
js: "never",
|
|
27
|
+
jsx: "never",
|
|
28
|
+
ts: "never",
|
|
29
|
+
tsx: "never"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
};
|
package/rules/jsdoc.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"plugin:jsdoc/recommended"
|
|
4
|
+
],
|
|
5
|
+
|
|
6
|
+
plugins: [
|
|
7
|
+
"jsdoc"
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
// View link below for jsdoc rules documentation
|
|
11
|
+
// https://github.com/gajus/eslint-plugin-jsdoc#user-content-eslint-plugin-jsdoc-rules
|
|
12
|
+
rules: {
|
|
13
|
+
// Do not enforce the empty line after the description block
|
|
14
|
+
// https://github.com/gajus/eslint-plugin-jsdoc#newline-after-description
|
|
15
|
+
"jsdoc/newline-after-description": "off",
|
|
16
|
+
|
|
17
|
+
// Do not require that each @param tag has a type value
|
|
18
|
+
// https://github.com/gajus/eslint-plugin-jsdoc#require-param-type
|
|
19
|
+
"jsdoc/require-param-type": "off",
|
|
20
|
+
|
|
21
|
+
// Do not require that @returns tag has a type value
|
|
22
|
+
// https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type
|
|
23
|
+
"jsdoc/require-returns-type": "off"
|
|
24
|
+
}
|
|
25
|
+
};
|
package/rules/next.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"plugin:@next/next/recommended"
|
|
4
|
+
],
|
|
5
|
+
|
|
6
|
+
plugins: [
|
|
7
|
+
"@next/next",
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
// View link below for next.js rules documentation
|
|
11
|
+
// https://nextjs.org/docs/basic-features/eslint#eslint-plugin
|
|
12
|
+
rules: {
|
|
13
|
+
// Disable because of this bug: https://github.com/vercel/next.js/issues/24421
|
|
14
|
+
// https://nextjs.org/docs/messages/no-img-element
|
|
15
|
+
"@next/next/no-img-element": "off",
|
|
16
|
+
},
|
|
17
|
+
};
|
package/rules/react.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
// View link below for react rules documentation
|
|
3
|
+
// https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules
|
|
4
|
+
rules: {
|
|
5
|
+
// The airbnb config forces the destructuring, but it's not always desirable
|
|
6
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
7
|
+
"react/destructuring-assignment": "off",
|
|
8
|
+
|
|
9
|
+
// The airbnb config forces function-expressions, but we prefer arrow-functions
|
|
10
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
|
|
11
|
+
"react/function-component-definition": ["error", {
|
|
12
|
+
namedComponents: "arrow-function",
|
|
13
|
+
unnamedComponents: "arrow-function",
|
|
14
|
+
}],
|
|
15
|
+
|
|
16
|
+
// The airbnb config forces only .jsx, but we support also .tsx
|
|
17
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
18
|
+
"react/jsx-filename-extension": ["error", { extensions: [".jsx", ".tsx"] }],
|
|
19
|
+
|
|
20
|
+
// The airbnb config forces one expression per line, but it's not always desirable
|
|
21
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
22
|
+
"react/jsx-one-expression-per-line": "off",
|
|
23
|
+
|
|
24
|
+
// The airbnb config forces a defaultProps definition for every prop, but we don't want it
|
|
25
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
26
|
+
"react/require-default-props": "off",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"plugin:@typescript-eslint/all"
|
|
4
|
+
],
|
|
5
|
+
|
|
6
|
+
plugins: [
|
|
7
|
+
"@typescript-eslint"
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
parser: "@typescript-eslint/parser",
|
|
11
|
+
|
|
12
|
+
parserOptions: {
|
|
13
|
+
project: "tsconfig.json"
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
// View link below for typescript rules documentation
|
|
17
|
+
// https://typescript-eslint.io/rules/
|
|
18
|
+
rules: {
|
|
19
|
+
// Enforce one true brace style (same as eslint-config-airbnb-base)
|
|
20
|
+
// https://typescript-eslint.io/rules/brace-style
|
|
21
|
+
"@typescript-eslint/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
22
|
+
|
|
23
|
+
// Require trailing commas in multiline object literals (same as eslint-config-airbnb-base)
|
|
24
|
+
// https://typescript-eslint.io/rules/comma-dangle
|
|
25
|
+
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
|
|
26
|
+
|
|
27
|
+
// Enforce spacing before and after comma (same as eslint-config-airbnb-base)
|
|
28
|
+
// https://typescript-eslint.io/rules/comma-spacing
|
|
29
|
+
"@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
|
|
30
|
+
|
|
31
|
+
// Encourages use of dot notation whenever possible (same as eslint-config-airbnb-base)
|
|
32
|
+
// https://typescript-eslint.io/rules/dot-notation
|
|
33
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
34
|
+
|
|
35
|
+
// This option sets a specific tab width for your code (same as eslint-config-airbnb-base)
|
|
36
|
+
// https://typescript-eslint.io/rules/indent
|
|
37
|
+
"@typescript-eslint/indent": ["error", 2, {
|
|
38
|
+
SwitchCase: 1,
|
|
39
|
+
VariableDeclarator: 1,
|
|
40
|
+
outerIIFEBody: 1,
|
|
41
|
+
// MemberExpression: null,
|
|
42
|
+
FunctionDeclaration: {
|
|
43
|
+
parameters: 1,
|
|
44
|
+
body: 1
|
|
45
|
+
},
|
|
46
|
+
FunctionExpression: {
|
|
47
|
+
parameters: 1,
|
|
48
|
+
body: 1
|
|
49
|
+
},
|
|
50
|
+
CallExpression: {
|
|
51
|
+
arguments: 1
|
|
52
|
+
},
|
|
53
|
+
ArrayExpression: 1,
|
|
54
|
+
ObjectExpression: 1,
|
|
55
|
+
ImportDeclaration: 1,
|
|
56
|
+
flatTernaryExpressions: false,
|
|
57
|
+
// list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
|
|
58
|
+
ignoredNodes: [
|
|
59
|
+
"JSXElement",
|
|
60
|
+
"JSXElement > *",
|
|
61
|
+
"JSXAttribute",
|
|
62
|
+
"JSXIdentifier",
|
|
63
|
+
"JSXNamespacedName",
|
|
64
|
+
"JSXMemberExpression",
|
|
65
|
+
"JSXSpreadAttribute",
|
|
66
|
+
"JSXExpressionContainer",
|
|
67
|
+
"JSXOpeningElement",
|
|
68
|
+
"JSXClosingElement",
|
|
69
|
+
"JSXFragment",
|
|
70
|
+
"JSXOpeningFragment",
|
|
71
|
+
"JSXClosingFragment",
|
|
72
|
+
"JSXText",
|
|
73
|
+
"JSXEmptyExpression",
|
|
74
|
+
"JSXSpreadChild"
|
|
75
|
+
],
|
|
76
|
+
ignoreComments: false
|
|
77
|
+
}],
|
|
78
|
+
|
|
79
|
+
// Enforce or disallow variable initializations at definition (same as eslint-config-airbnb-base)
|
|
80
|
+
// https://typescript-eslint.io/rules/init-declarations
|
|
81
|
+
"@typescript-eslint/init-declarations": "off",
|
|
82
|
+
|
|
83
|
+
// Require a space before & after certain keywords (same as eslint-config-airbnb-base)
|
|
84
|
+
// https://typescript-eslint.io/rules/keyword-spacing
|
|
85
|
+
"@typescript-eslint/keyword-spacing": ["error", {
|
|
86
|
+
before: true,
|
|
87
|
+
after: true,
|
|
88
|
+
overrides: {
|
|
89
|
+
return: { after: true },
|
|
90
|
+
throw: { after: true },
|
|
91
|
+
case: { after: true }
|
|
92
|
+
}
|
|
93
|
+
}],
|
|
94
|
+
|
|
95
|
+
// Require or disallow an empty line between class members (same as eslint-config-airbnb-base)
|
|
96
|
+
// https://typescript-eslint.io/rules/lines-between-class-members
|
|
97
|
+
"@typescript-eslint/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
|
|
98
|
+
|
|
99
|
+
// Force camelCase except for some cases
|
|
100
|
+
// https://typescript-eslint.io/rules/naming-convention
|
|
101
|
+
"@typescript-eslint/naming-convention": ["error", {
|
|
102
|
+
selector: "default",
|
|
103
|
+
format: ["camelCase"],
|
|
104
|
+
leadingUnderscore: "allow",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
selector: ["typeLike", "accessor", "enumMember"],
|
|
108
|
+
format: ["PascalCase"],
|
|
109
|
+
}],
|
|
110
|
+
|
|
111
|
+
// Disallow empty functions, except for standalone funcs/arrows (same as eslint-config-airbnb-base)
|
|
112
|
+
// https://typescript-eslint.io/rules/no-empty-function
|
|
113
|
+
"@typescript-eslint/no-empty-function": ["error", {
|
|
114
|
+
allow: [
|
|
115
|
+
"arrowFunctions",
|
|
116
|
+
"functions",
|
|
117
|
+
"methods",
|
|
118
|
+
]
|
|
119
|
+
}],
|
|
120
|
+
|
|
121
|
+
// Disallow unnecessary parentheses (same as eslint-config-airbnb-base)
|
|
122
|
+
// https://typescript-eslint.io/rules/no-extra-parens
|
|
123
|
+
"@typescript-eslint/no-extra-parens": ["off", "all", {
|
|
124
|
+
conditionalAssign: true,
|
|
125
|
+
nestedBinaryExpressions: false,
|
|
126
|
+
returnAssign: false,
|
|
127
|
+
ignoreJSX: "all", // delegate to eslint-plugin-react
|
|
128
|
+
enforceForArrowConditionals: false,
|
|
129
|
+
}],
|
|
130
|
+
|
|
131
|
+
// Disallow classes used as namespaces
|
|
132
|
+
// https://typescript-eslint.io/rules/no-extraneous-class
|
|
133
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
134
|
+
|
|
135
|
+
// Disallow void type outside of generic or return types
|
|
136
|
+
// https://typescript-eslint.io/rules/no-invalid-void-type
|
|
137
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
138
|
+
|
|
139
|
+
// Disallow magic numbers (same as eslint-config-airbnb-base)
|
|
140
|
+
// https://typescript-eslint.io/rules/no-magic-numbers
|
|
141
|
+
"@typescript-eslint/no-magic-numbers": ["off", {
|
|
142
|
+
ignore: [],
|
|
143
|
+
ignoreArrayIndexes: true,
|
|
144
|
+
enforceConst: true,
|
|
145
|
+
detectObjects: false,
|
|
146
|
+
}],
|
|
147
|
+
|
|
148
|
+
// Disallow custom TypeScript modules and namespaces
|
|
149
|
+
// https://typescript-eslint.io/rules/no-namespace
|
|
150
|
+
"@typescript-eslint/no-namespace": ["error", {
|
|
151
|
+
allowDeclarations: true,
|
|
152
|
+
allowDefinitionFiles: true,
|
|
153
|
+
}],
|
|
154
|
+
|
|
155
|
+
// Disallow type aliases
|
|
156
|
+
// https://typescript-eslint.io/rules/no-type-alias
|
|
157
|
+
"@typescript-eslint/no-type-alias": "off",
|
|
158
|
+
|
|
159
|
+
// Disallow declaration of variables that are not used in the code (same as eslint-config-airbnb-base)
|
|
160
|
+
// https://typescript-eslint.io/rules/no-unused-vars
|
|
161
|
+
"@typescript-eslint/no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],
|
|
162
|
+
|
|
163
|
+
// Require padding inside curly braces (same as eslint-config-airbnb-base)
|
|
164
|
+
// https://typescript-eslint.io/rules/object-curly-spacing
|
|
165
|
+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
|
166
|
+
|
|
167
|
+
// Require or disallow padding lines between statements (same as eslint-config-airbnb-base)
|
|
168
|
+
// https://typescript-eslint.io/rules/padding-line-between-statements
|
|
169
|
+
"@typescript-eslint/padding-line-between-statements": "off",
|
|
170
|
+
|
|
171
|
+
// Require function parameters to be typed as readonly to prevent accidental mutation of inputs
|
|
172
|
+
// https://typescript-eslint.io/rules/prefer-readonly-parameter-types
|
|
173
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
174
|
+
|
|
175
|
+
// Require `await` in `async function` (note: this is a horrible rule that should never be used) (same as eslint-config-airbnb-base)
|
|
176
|
+
// https://typescript-eslint.io/rules/require-await
|
|
177
|
+
"@typescript-eslint/require-await": "off",
|
|
178
|
+
|
|
179
|
+
// Enforce template literal expressions to be of string type, but allow numbers and booleans
|
|
180
|
+
// https://typescript-eslint.io/rules/restrict-template-expressions
|
|
181
|
+
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
182
|
+
allowNumber: true,
|
|
183
|
+
allowBoolean: true,
|
|
184
|
+
allowAny: false,
|
|
185
|
+
allowNullish: false,
|
|
186
|
+
allowRegExp: false,
|
|
187
|
+
}],
|
|
188
|
+
|
|
189
|
+
// Require or disallow space before function opening parenthesis (same as eslint-config-airbnb-base)
|
|
190
|
+
// https://typescript-eslint.io/rules/space-before-function-paren
|
|
191
|
+
"@typescript-eslint/space-before-function-paren": ["error", {
|
|
192
|
+
anonymous: "always",
|
|
193
|
+
named: "never",
|
|
194
|
+
asyncArrow: "always"
|
|
195
|
+
}],
|
|
196
|
+
},
|
|
197
|
+
};
|