Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@putout/eslint

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/eslint - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

lib/create-plugin/index.js

8

package.json
{
"name": "@putout/eslint",
"version": "1.0.1",
"version": "1.1.0",
"type": "commonjs",

@@ -8,3 +8,3 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

"homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint#readme",
"main": "lib/eslint.js",
"main": "./lib/eslint.js",
"commitType": "colon",

@@ -14,2 +14,6 @@ "release": false,

"changelog": false,
"exports": {
".": "./lib/eslint.js",
"./create-plugin": "./lib/create-plugin/index.js"
},
"repository": {

@@ -16,0 +20,0 @@ "type": "git",

@@ -16,2 +16,4 @@ # @putout/eslint [![NPM version][NPMIMGURL]][NPMURL]

### `eslint(options)`
**ESLint** begins his work as a formatter when 🐊**Putout** done his transformations. That's why it used a lot in different parts of application, for testing purpose and using **API** in a simplest possible way. You can access it with:

@@ -36,3 +38,3 @@

- ☝️ *[🐊**Putout** returns object with `code` and `places` properties](https://github.com/coderaiser/putout#plugins).*
- ☝️ ***ESLint** has a `name` property that is used to calculate configuration file.*
- ☝️ * **ESLint** has a `name` property that is used to calculate configuration file. *

@@ -72,4 +74,74 @@ And you can even override any of **ESLint** ⚙️ options with help of `config` property:

### `createPlugin(options)`
You can also simplify creating of plugins for **ESLint** with help of `createPlugin`.
🐊**Putout**-based **ESLint** plugin are highly inspired by [**Putout Plugins API**](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#readme) of [**Includer**](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#includer).
So it must contain classic `4` methods:
```js
module.exports.report = () => 'debugger statement should not be used';
module.exports.fix = (path) => {
return '';
};
module.exports.include = () => [
'DebuggerStatement',
];
module.exports.filter = (path) => {
return true;
};
```
Take a look at more sophisticated example, rule [`remove-duplicate-extensions`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/remove-duplicate-extensions#readme):
```js
const getValue = ({source}) => source?.value;
module.exports.report = () => 'Avoid duplicate extensions in relative imports';
module.exports.include = () => [
'ImportDeclaration',
'ImportExpression',
'ExportAllDeclaration',
'ExportNamedDeclaration',
];
module.exports.fix = ({text}) => {
return text.replace('.js.js', '.js');
};
module.exports.filter = ({node}) => {
const value = getValue(node);
return /\.js\.js/.test(value);
};
```
To use it just add couple lines to your main plugin file:
```js
const {createPlugin} = require('@putout/eslint/create-plugin');
const createRule = (a) => ({
[a]: createPlugin(require(`./${a}`)),
});
module.exports.rules = {
...createRule('remove-duplicate-extensions'),
};
```
Or just:
```js
const {createPlugin} = require('@putout/eslint/create-plugin');
module.exports.rules = {
'remove-duplicate-extensions': createPlugin('remove-duplicate-extensions'),
};
```
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc