-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from SparkPost/SAA-466
SAA-466 Updated all deps and prepped for v3 release.
- Loading branch information
Showing
10 changed files
with
2,660 additions
and
1,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @sparkpost/team-saz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run eslint --fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased][unreleased] | ||
- There are no unreleased features at this time | ||
|
||
## [3.0.0 - 2022-01-27][3.0.0] | ||
### Added | ||
- Mocha specific config for linting testing files. This can be utilized by adding an `.eslintrc` file to your tests directory or adding an overrides | ||
section and extending `sparkpost/mocha` within it. | ||
- TypeScript specific config for linting TypeScript projects. Typescript projects can now extend `sparkpost/typescript`. | ||
|
||
### Updated | ||
- Updated the required version of ESLint to be 8.7 or above | ||
|
||
### Removed | ||
- Removed TypeScript(TS) specific rules from the default config since they add TS dependencies to non-TS projects. | ||
This will be followed by a TS specific linting config for TS projects that will potentially inherit base JS settings from this configuration. | ||
- Moved Mocha specific plugins to be optional peer dependencies. This allows non-Mocha based projects to not install the Mocha plugins if they're not | ||
needed. This has been replaced with a mocha specific config `sparkpost/mocha` which can be added to an `.eslintrc` file in the tests directory of | ||
Mocha based projects. | ||
|
||
[3.0.0]: https://github.com/sparkpost/eslint-config-sparkpost/compare/v2.1.2...v3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,77 @@ | ||
# eslint-config-sparkpost | ||
ESLint configuration for Javascript based SparkPost projects | ||
|
||
|
||
|
||
## Notes for Docs in Libraries | ||
|
||
This config has extra rules specifically around JSDocs to help have better documentation in our libraries. | ||
This can help in knowledge sharing and will hopefully promote better docs in our shared JS modules. | ||
|
||
To use, add the following to your `.eslintrc.json`: | ||
```json | ||
{ | ||
"extends": "sparkpost/lib" | ||
} | ||
ESLint configuration for Javascript and TypeScript based SparkPost projects | ||
|
||
## Upgrading from 2.x to 3.x | ||
There were several breaking changes including moving from ESLint 5.x to ESLint 8.x. This change alone caused some minimal breaking changes. Since | ||
we ultimately extend `eslint:recommended` in our base configuration, the upgrade from eslint 5.x to 8.x changed that 'recommended' config and the | ||
rules between versions have definitely changed. We compensated to match our existing config as best we could, but you may find other changes when | ||
running ESLint in your projects. | ||
|
||
We also moved several specific configs from overrides in the base config to their own specific configs. Mocha and TypeScript are used by some projects, | ||
however they are not used by every project so we have separated them to their own configs and moved their dependencies to optional peer dependencies | ||
so that we no longer need to install and maintain them in projects that don't use them. | ||
|
||
### Special Concerns for Mocha Based Projects | ||
Traditionally we've setup special rules for `mocha` based projects, however not all projects use `mocha`. This would lead to dependencies being | ||
installed that were unrelated to the project. For this reason, we have split `mocha` configuration into its own configuration. You can take | ||
advantage of it by extending `sparkpost/mocha` from this package. This will require you to install the plugin `eslint-plugin-mocha` in the project's | ||
dev dependencies. | ||
|
||
Example: | ||
```shell | ||
npm i -D eslint-plugin-mocha | ||
``` | ||
|
||
|
||
The scripts below in this README are purely for reference and can make managing documentation in your shared lib much easier. | ||
|
||
### Useful NPM scripts | ||
In your `.eslintrc` file: | ||
```json | ||
{ | ||
"scripts": { | ||
"chk-changelog": "grep `node -e 'console.log(require(\"./package.json\").version);'` CHANGELOG.md || echo 'Please update CHANGELOG.md with your updates'; exit 255", | ||
"docs": "doxdox index.js 'mocks/**/*.js' 'lib/**/*.js' --layout markdown --output DOCUMENTATION.md", | ||
"lint": "eslint . --fix", | ||
"nice-docs": "doxdox 'index.js' 'mocks/**/*.js' 'lib/**/*.js' --layout bootstrap --output docs/index.html && open docs/index.html", | ||
"prepublishOnly": "npm run chk-changelog", | ||
"prepush": "npm run docs -- && git add DOCUMENTATION.md && if git commit --no-verify -m \"`git rev-parse --abbrev-ref HEAD` Updated Documentation\"; then exit 0; else echo 'No documentation updates'; fi " | ||
} | ||
"normal": "stuff <- comment", | ||
"overrides": [ | ||
{ | ||
"files": ["test/**/*.spec.js"], | ||
"extends": ["sparkpost/mocha"] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Generating Docs | ||
#### Install `doxdox` | ||
```bash | ||
npm i --save-dev doxdox | ||
``` | ||
### Special Concerns for TypeScript Projects | ||
We have several `typescript` based projects, however not all projects use `typescript`. This would lead to dependencies being | ||
installed that were unrelated to the project. For this reason, we have split `typescript` configuration into its own configuration. You can take | ||
advantage of it by extending `sparkpost/typescript` from this package. This will require you to install several plugins and configs in the project's | ||
dev dependencies. | ||
|
||
#### Add and modify the npm script. | ||
The list below (`index.js 'mocks/**/*.js 'lib/**/*.js`) will probably need to be changed for your lib. | ||
```json | ||
{ | ||
"docs": "doxdox index.js 'mocks/**/*.js' 'lib/**/*.js' --layout markdown --output DOCUMENTATION.md" | ||
} | ||
Example: | ||
```shell | ||
npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier | ||
``` | ||
|
||
#### Run the script | ||
```bash | ||
npm run docs | ||
``` | ||
This will generate a ./DOCUMENTATION.md file that will include all JSDoc references in your module. | ||
|
||
#### Auto generating the docs | ||
Given that you have husky installed, adding an npm script for `prepush` will automatically generate and commit docs anytime you push to git. | ||
In your `.eslintrc` file: | ||
```json | ||
{ | ||
"prepush": "npm run docs -- && git add DOCUMENTATION.md && if git commit --no-verify -m \"`git rev-parse --abbrev-ref HEAD` Updated Documentation\"; then exit 0; else echo 'No documentation updates'; fi " | ||
"normal": "stuff <- comment", | ||
"extends": ["sparkpost/typescript"], | ||
"rules": { | ||
"other": "rules that override the base typescript config <- comment" | ||
} | ||
} | ||
``` | ||
|
||
#### Generating nicer docs | ||
I recommend adding docs to your gitignore if its not already there. | ||
```bash | ||
echo docs >> .gitignore | ||
``` | ||
## Docs in Libraries | ||
This config has extra rules specifically around JSDocs to help have better documentation in our libraries. | ||
This can help in knowledge sharing and will hopefully promote better docs in our shared JS modules. | ||
|
||
Add the npm script: | ||
To use, add the following to your `.eslintrc` file: | ||
```json | ||
{ | ||
"nice-docs": "doxdox 'index.js' 'mocks/**/*.js' 'lib/**/*.js' --layout bootstrap --output docs/index.html && open docs/index.html" | ||
"extends": "sparkpost/lib" | ||
} | ||
``` | ||
|
||
Run the npm script | ||
```bash | ||
npm run nice-docs | ||
``` | ||
|
||
### Checking Changelogs | ||
### Automation for Checking Changelogs | ||
#### Add the npm scripts | ||
```json | ||
{ | ||
"chk-changelog": "grep `node -e 'console.log(require(\"./package.json\").version);'` CHANGELOG.md || echo 'Please update CHANGELOG.md with your updates'; exit 255", | ||
"prepublishOnly": "npm run chk-changelog" | ||
} | ||
``` | ||
This will check your changelog for an entry for your current version when you publish. | ||
This will check your changelog for an entry for your current version when you publish. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
|
||
module.exports = { | ||
env: { | ||
node: true, | ||
mocha: true | ||
node: true | ||
}, | ||
extends: 'sparkpost/index' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
module.exports = { | ||
env: { | ||
es6: true, | ||
node: true, | ||
mocha: true | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2021 | ||
}, | ||
plugins: ['mocha'], | ||
extends: ['sparkpost/index'], | ||
rules: { | ||
'max-params': 'off', | ||
'func-names': 'off', | ||
'prefer-arrow-callback': 'off', | ||
'require-jsdoc': 'off', | ||
'valid-jsdoc': 'off', | ||
'mocha/no-exclusive-tests': 'error', | ||
'mocha/no-mocha-arrows': 'error', | ||
'mocha/no-identical-title': 'error', | ||
'mocha/no-sibling-hooks': 'error' | ||
} | ||
} |
Oops, something went wrong.