{"name":"@putout/eslint","version":"1.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"Wrapper that simplifies ESLint API and makes it compatible with 🐊Putout","homepage":"https://github.com/coderaiser/putout/tree/master/packages/eslint#readme","main":"lib/eslint.js","commitType":"colon","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{"try-to-catch":"^3.0.1"},"keywords":["putout","eslint"],"devDependencies":{"c8":"^7.5.0","eslint":"^8.0.1","eslint-plugin-n":"^15.2.4","eslint-plugin-putout":"^16.0.0","just-camel-case":"^4.0.2","lerna":"^5.0.0","madrun":"^9.0.0","mock-require":"^3.0.3","montag":"^1.0.0","nodemon":"^2.0.1","putout":"*","supertape":"^7.0.0","try-catch":"^3.0.0"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"gitHead":"ab109a576807c49412eb212427af66c4dad6cf7c","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_id":"@putout/eslint@1.0.0","_nodeVersion":"18.7.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-JexMeHawI5dminxErSPsrk/ZrWcLvLs/cRDGxBqXd45q+ZsWCPzQkVxr84eiwck1qU5ocGNkmos0xnghAYAtZg==","shasum":"6ef688204d01e57fb298cd51d7c6218eed89571b","tarball":"http://registry-npm.ywwl.com/@putout/eslint/download/@putout/eslint-1.0.0.tgz","fileCount":6,"unpackedSize":8350,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4uG0ZbtAzJz9uviWKsZu+ANYGvMqY673ebEkDUORBkwIhAIDpvWItVYRUaUmTmJzaVDTIKmKZsi5+RqcpU99zFAME"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjCzN9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmogTQ//ad5VNLOw3Nabnyy6gIpoc9xJW/ZQQe95lOguugICHrdOLOCK\r\n700wHE9DtV5uDcpzjVylbYHyBcdjETZAMKZbysC7yV9lqCFnRYp6bV4U1tL4\r\n/0l+pvP8uur1juhgPDFGE7yn9LfwCNvE/SsWd7ykQ/pb5awsfVG6xGoMxS34\r\nrxvHS0IO3HFsvqjeMangcgOWPCJl2zGnbjQVNyNhcGsRockujwuYrFKTFy+5\r\nGEta8WMCFEYjMuIZBh/EOjqqzI+sSQ9mvF616Pi6fbwhXwIkYUyQJhx9Jc2C\r\n5PqE0vnkxD84g2lJ9+G+Y9V2ss/Ukyn0MpJWGdTwrVo+jUXC0HuuL7AO1Wzg\r\nHs+HSdG89a0Sr74KwviOWqF6J/U+eOaHcI3ha03eKjObcp+4EJd/yVc7rkbG\r\n6m86FlVUmeRYrz7eYniEOVdevLLecxuwVirh7EjmcY/ruGUxGDmxwlcp2LhL\r\nFkQV77d9K66U3xev8fW7sXc3gMme+W7WWfzT1AHeIgm49fCrS4G9FD8MVjC8\r\n0aehRaQzaOMc1CXU/ArKcrlCk/JFMI1jBWi/I09YgmhpeHXL98zImG/4K8Ss\r\n7XCthMsyJORWpsxK3qEE32FimjsuPK8QmFroO3bR+PlWvQJXHl6E4R2cMfal\r\ndONKAqwiQvKtryIl5AWvzuPdRtkKPf6Qqjc=\r\n=ON97\r\n-----END PGP SIGNATURE-----\r\n","size":3517,"noattachment":false,"key":"/@putout/eslint/-/@putout/eslint-1.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint_1.0.0_1661678461505_0.18991282411096222"},"_hasShrinkwrap":false,"readme":"# @putout/eslint [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/eslint.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/eslint \"npm\"\n\nWrapper that simplifies [**ESLint**](https://eslint.org/) API and makes it compatible with 🐊[**Putout**](https://github.com/coderaiser/putout).\n\n☝️ *[FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/) supported from the box.*\n\n## Install\n\n```\nnpm i @putout/eslint\n```\n\n## Environment Variables\n\n- ☝️ To set custom config file for **ESLint** use `ESLINT_CONFIG_FILE` env variable:\n- ☝️ To disable **ESLint** support use `NO_ESLINT=1` env variable:\n- ☝️ If you want to ignore **ESLint** warnings (which is unfixable errors in 🐊**Putout** language) use `NO_ESLINT_WARNINGS=1`:\n\n````sh\nNO_ESLINT_WARNINGS=1 putout --fix lib\n\n## API\n\n### `eslint(options)`\n\n**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:\n\n```js\nimport eslint from '@putout/eslint';\n````\n\nTo use it simply write:\n\n```js\nconst [source, places] = await eslint({\n    name: 'hello.js',\n    code: `const t = 'hi'\\n`,\n    fix: false,\n});\n```\n\nIsn't it looks similar to 🐊**Putout** way? It definitely is! But... It has a couple differences you should remember:\n\n- ☝️ *[🐊**Putout** returns object with `code` and `places` properties](https://github.com/coderaiser/putout#plugins), and **ESLint* returns a tuple**\n- ☝️ ***ESLint** has a `name` property that is used to calculate configuration file.*\n\nAnd you can even override any of **ESLint** ⚙️ options with help of `config` property:\n\n```js\nconst [source, places] = await eslint({\n    name: 'hello.js',\n    code: `const t = 'hi'\\n`,\n    fix: false,\n    config: {\n        extends: ['plugin:putout/recommended'],\n    },\n});\n```\n\nIf you want to apply 🐊**Putout** transformations using [`putout/putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) **ESLint** rule, enable 🐊**Putout** with the same called but lowercased flag:\n\n```js\nconst [source, places] = await eslint({\n    name: 'hello.js',\n    code: `const t = 'hi'\\n`,\n    fix: true,\n    putout: true,\n    config: {\n        extends: ['plugin:putout/recommended'],\n    },\n});\n```\n\nIt is disabled by default, because **ESLint** always runs after 🐊**Putout** transformations, so there is no need to traverse tree again.\n\n### `createPlugin(options)`\n\nYou can also simplify creating of plugins for **ESLint** with help of `createPlugin`.\n🐊**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).\n\nSo it must contain classic `4` methods:\n\n```js\nmodule.exports.report = () => 'debugger statement should not be used';\n\nmodule.exports.fix = (path) => {\n    return '';\n};\n\nmodule.exports.include = () => [\n    'DebuggerStatement',\n];\n\nmodule.exports.filter = (path) => {\n    return true;\n};\n```\n\nThe main difference with [Includer](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#includer) is:\n\n- `fix` works with text;\n- `include` does not support 🦎[PutoutScript](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript);\n- there is no `exclude`;\n\nTake 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):\n\n```js\nconst getValue = ({source}) => source?.value;\n\nmodule.exports.report = () => 'Avoid duplicate extensions in relative imports';\nmodule.exports.include = () => [\n    'ImportDeclaration',\n    'ImportExpression',\n    'ExportAllDeclaration',\n    'ExportNamedDeclaration',\n];\n\nmodule.exports.fix = ({text}) => {\n    return text.replace('.js.js', '.js');\n};\n\nmodule.exports.filter = ({node}) => {\n    const value = getValue(node);\n    return /\\.js\\.js/.test(value);\n};\n```\n\nTo use it just add couple lines to your main plugin file:\n\n```js\nconst {createPlugin} = require('@putout/eslint/create-plugin');\n\nconst createRule = (a) => ({\n    [a]: createPlugin(require(`./${a}`)),\n});\n\nmodule.exports.rules = {\n    ...createRule('remove-duplicate-extensions'),\n};\n```\n\nOr just:\n\n```js\nconst {createPlugin} = require('@putout/eslint/create-plugin');\n\nmodule.exports.rules = {\n    'remove-duplicate-extensions': createPlugin(require('./remove-duplicate-extensions')),\n};\n```\n\n### `lint(source, {fix, plugins, options, filename})`\n\nWhen you need to run **ESLint** with one plugin (*rule*), just use `lint` it will do the thing.\n\n```js\nconst lint = require('@putout/eslint/lint');\nconst {createPlugin} = require('@putout/eslint/create-plugin');\nconst removeDebugger = require('./remove-debugger');\n\nconst [code, places] = lint('debugger', {\n    fix: true, // default\n    plugins: [\n        ['remove-debugger', createPlugin(removeDebugger)],\n    ],\n});\n```\n\nWhen you want to skip plugins, and just provide `options` and `filename` you can:\n\n```js\nconst lint = require('@putout/eslint/lint');\n\nconst [code, places] = lint('debugger', {\n    filename: 'index.js',\n    options: [{\n        rules: {\n            semi: 'error',\n        },\n    }],\n});\n```\n\n## License\n\nMIT\n","publish_time":1661678461702,"_cnpm_publish_time":1661678461702,"dist-tags":{"latest":"6.1.0"}}