Skip to content

Commit

Permalink
Chore: improve auto-generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jun 2, 2017
1 parent d4e6bc4 commit cf36e6d
Show file tree
Hide file tree
Showing 19 changed files with 214 additions and 133 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,6 +1,5 @@
/.nyc_output
/coverage
/index.js
/npm-debug.log
/node_modules
/test.js
58 changes: 35 additions & 23 deletions README.md
Expand Up @@ -8,7 +8,7 @@

Additional ESLint's rules for Node.js

## :cd: Install & Usage
## 💿 Install & Usage

```
$ npm install --save-dev eslint eslint-plugin-node
Expand Down Expand Up @@ -43,27 +43,39 @@ $ npm install --save-dev eslint eslint-plugin-node
}
```

## :bulb: Rules
## 📖 Rules

- :star: - the mark of recommended rules.
- :pencil: - the mark of fixable rules.
- ⭐️ - the mark of recommended rules.
- ✒️ - the mark of fixable rules.

| | | Rule ID | Description |
|:------:|:--------:|:-----------------------------------------------------------------|:------------|
| | | [exports-style](docs/rules/exports-style.md) | Enforce either `module.exports` or `exports`.
| :star: | | [no-deprecated-api](docs/rules/no-deprecated-api.md) | Disallow deprecated API.
| | | [no-extraneous-import](docs/rules/no-extraneous-import.md) | Disallow `import` declarations of extraneous packages. :warning:
| :star: | | [no-extraneous-require](docs/rules/no-extraneous-require.md) | Disallow `require()` expressions of extraneous packages.
| | | [no-missing-import](docs/rules/no-missing-import.md) | Disallow `import` declarations of files that don't exist. :warning:
| :star: | | [no-missing-require](docs/rules/no-missing-require.md) | Disallow `require()` expressions of files that don't exist.
| :star: | | [no-unpublished-bin](docs/rules/no-unpublished-bin.md) | Disallow `bin` files that npm ignores.
| | | [no-unpublished-import](docs/rules/no-unpublished-import.md) | Disallow `import` declarations of files that npm ignores. :warning:
| :star: | | [no-unpublished-require](docs/rules/no-unpublished-require.md) | Disallow `require()` expressions of files that npm ignores.
| :star: | | [no-unsupported-features](docs/rules/no-unsupported-features.md) | Disallow unsupported ECMAScript features on the specified version.
| :star: | | [process-exit-as-throw](docs/rules/process-exit-as-throw.md) | Make the same code path as throw at `process.exit()`.
| :star: | :pencil: | [shebang](docs/rules/shebang.md) | Suggest correct usage of shebang.
<!--RULES_TABLE_START-->
### Possible Errors
| | Rule ID | Description |
|:---|:--------|:------------|
| | [no-extraneous-import](./docs/rules/no-extraneous-import.md) | disallow `import` declarations of extraneous packages |
| ⭐️ | [no-extraneous-require](./docs/rules/no-extraneous-require.md) | disallow `require()` expressions of extraneous packages |
| | [no-missing-import](./docs/rules/no-missing-import.md) | disallow `import` declarations of missing files |
| ⭐️ | [no-missing-require](./docs/rules/no-missing-require.md) | disallow `require()` expressions of missing files |
| ⭐️ | [no-unpublished-bin](./docs/rules/no-unpublished-bin.md) | disallow 'bin' files which are ignored by npm |
| | [no-unpublished-import](./docs/rules/no-unpublished-import.md) | disallow `import` declarations of private things |
| ⭐️ | [no-unpublished-require](./docs/rules/no-unpublished-require.md) | disallow `require()` expressions of private things |
| ⭐️ | [no-unsupported-features](./docs/rules/no-unsupported-features.md) | disallow unsupported ECMAScript features on the specified version |
| ⭐️ | [process-exit-as-throw](./docs/rules/process-exit-as-throw.md) | make `process.exit()` expressions the same code path as `throw` |
| ⭐️✒️ | [shebang](./docs/rules/shebang.md) | enforce the correct usage of shebang |

## :wrench: Configs
### Best Practices
| | Rule ID | Description |
|:---|:--------|:------------|
| ⭐️ | [no-deprecated-api](./docs/rules/no-deprecated-api.md) | disallow deprecated APIs |

### Stylistic Issues
| | Rule ID | Description |
|:---|:--------|:------------|
| | [exports-style](./docs/rules/exports-style.md) | enforce either `module.exports` or `exports` |

<!--RULES_TABLE_END-->

## 🔧 Configs

This plugin provides `plugin:node/recommended` preset config.
This preset config:
Expand All @@ -73,12 +85,12 @@ This preset config:
- enables [no-process-exit](http://eslint.org/docs/rules/no-process-exit) rule because [the official document](https://nodejs.org/api/process.html#process_process_exit_code) does not recommend a use of `process.exit()`.
- adds `{ecmaVersion: 8}` into `parserOptions`.

## :couple: FAQ
## 👫 FAQ

- Q: The `no-missing-import` / `no-missing-require` rules don't work with nested folders in SublimeLinter-eslint
- A: See [context.getFilename() in rule returns relative path](https://github.com/roadhump/SublimeLinter-eslint#contextgetfilename-in-rule-returns-relative-path) in the SublimeLinter-eslint FAQ.

## :anchor: Semantic Versioning Policy
## 🚥 Semantic Versioning Policy

`eslint-plugin-node` follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).

Expand All @@ -100,11 +112,11 @@ This preset config:
- An existing option of a rule is removed.
- An existing config is updated.

## :newspaper: Changelog
## 📰 Changelog

- [GitHub Releases](https://github.com/mysticatea/eslint-plugin-node/releases)

## :muscle: Contributing
## 💎 Contributing

Welcome contributing!

Expand Down
19 changes: 0 additions & 19 deletions conf/recommended.json

This file was deleted.

11 changes: 11 additions & 0 deletions lib/index.js
@@ -0,0 +1,11 @@
/**
* @author Toru Nagashima
* @copyright 2017 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict"

module.exports = {
configs: {recommended: require("./recommended.json")},
rules: require("./rules.js"),
}
24 changes: 24 additions & 0 deletions lib/recommended.json
@@ -0,0 +1,24 @@
{
"parserOptions": {
"ecmaVersion": 8
},
"env": {
"es6": true,
"node": true
},
"rules": {
"no-process-exit": "error",
"node/exports-style": "off",
"node/no-deprecated-api": "error",
"node/no-extraneous-import": "off",
"node/no-extraneous-require": "error",
"node/no-missing-import": "off",
"node/no-missing-require": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "error",
"node/no-unsupported-features": "error",
"node/process-exit-as-throw": "error",
"node/shebang": "error"
}
}
22 changes: 22 additions & 0 deletions lib/rules.js
@@ -0,0 +1,22 @@
/**
* @author Toru Nagashima
* @copyright 2017 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict"

module.exports = {
"exports-style": require("./rules/exports-style"),
"no-deprecated-api": require("./rules/no-deprecated-api"),
"no-extraneous-import": require("./rules/no-extraneous-import"),
"no-extraneous-require": require("./rules/no-extraneous-require"),
"no-hide-core-modules": require("./rules/no-hide-core-modules"),
"no-missing-import": require("./rules/no-missing-import"),
"no-missing-require": require("./rules/no-missing-require"),
"no-unpublished-bin": require("./rules/no-unpublished-bin"),
"no-unpublished-import": require("./rules/no-unpublished-import"),
"no-unpublished-require": require("./rules/no-unpublished-require"),
"no-unsupported-features": require("./rules/no-unsupported-features"),
"process-exit-as-throw": require("./rules/process-exit-as-throw"),
"shebang": require("./rules/shebang"),
}
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated-api.js
Expand Up @@ -546,7 +546,7 @@ module.exports = {
docs: {
description: "disallow deprecated APIs",
category: "Best Practices",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-extraneous-require.js
Expand Up @@ -49,9 +49,9 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow `require()` expressions for extraneous packages",
description: "disallow `require()` expressions of extraneous packages",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-missing-import.js
Expand Up @@ -49,7 +49,7 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow import declarations for files that don't exist",
description: "disallow `import` declarations of missing files",
category: "Possible Errors",
recommended: false,
},
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-missing-require.js
Expand Up @@ -49,9 +49,9 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow `require()` expressions for files that don't exist",
description: "disallow `require()` expressions of missing files",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-unpublished-bin.js
Expand Up @@ -96,9 +96,9 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow 'bin' files that npm ignores",
description: "disallow 'bin' files which are ignored by npm",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unpublished-import.js
Expand Up @@ -50,7 +50,7 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow import declarations for files that npm ignores",
description: "disallow `import` declarations of private things",
category: "Possible Errors",
recommended: false,
},
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-unpublished-require.js
Expand Up @@ -50,9 +50,9 @@ module.exports = {
create,
meta: {
docs: {
description: "disallow `require()` expressions for files that npm ignores",
description: "disallow `require()` expressions of private things",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unsupported-features.js
Expand Up @@ -725,7 +725,7 @@ module.exports = {
docs: {
description: "disallow unsupported ECMAScript features on the specified version",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/process-exit-as-throw.js
Expand Up @@ -144,9 +144,9 @@ const visitor = CodePathAnalyzer == null ? {} : {
module.exports = {
meta: {
docs: {
description: "make the same code path as `throw` at `process.exit()`",
description: "make `process.exit()` expressions the same code path as `throw`",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: false,
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/shebang.js
Expand Up @@ -145,7 +145,7 @@ module.exports = {
docs: {
description: "enforce the correct usage of shebang",
category: "Possible Errors",
recommended: false,
recommended: true,
},
fixable: "code",
schema: [
Expand Down
11 changes: 5 additions & 6 deletions package.json
Expand Up @@ -2,20 +2,19 @@
"name": "eslint-plugin-node",
"version": "4.2.2",
"description": "Additional ESLint's rules for Node.js",
"main": "lib/index.js",
"files": [
"conf",
"lib",
"index.js"
"lib"
],
"scripts": {
"build": "node scripts/generate-index.js",
"clean": "rimraf .nyc_output coverage index.js",
"build": "node scripts/update.js",
"clean": "rimraf .nyc_output coverage",
"codecov": "nyc report -r lcovonly && codecov",
"coverage": "nyc report -r lcov && opener ./coverage/lcov-report/index.html",
"lint": "eslint lib tests/lib index.js",
"postversion": "git push && git push --tags",
"pretest": "npm run -s lint",
"preversion": "npm t && npm run build",
"preversion": "npm t && npm run -s build",
"test": "nyc npm run -s test:_mocha",
"test:_mocha": "_mocha tests/lib/**/*.js --reporter progress",
"watch": "npm run test:_mocha -- --watch --growl"
Expand Down
69 changes: 0 additions & 69 deletions scripts/generate-index.js

This file was deleted.

0 comments on commit cf36e6d

Please sign in to comment.