{"name":"flatlint","version":"3.0.0","keywords":["flatlint","scripts","package","npm","npm run","npm-scripts","tool","cli","command","task","parallel","serial","run","commandline"],"author":{"url":"http://coderaiser.github.io/","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"flatlint@3.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/flatlint","bugs":{"url":"https://github.com/coderaiser/flatlint/issues"},"dist":{"shasum":"04c4f04ed3173e5efdc04df34248454e76d53e70","tarball":"http://registry-npm.ywwl.com/flatlint/download/flatlint-3.0.0.tgz","fileCount":42,"integrity":"sha512-Cvem/rG3lrNO+d5kNn8Lo37ur8dAzsfiLbvkBy6v0HK1azXHO/XNIlUZtNBVy3rc5IOvkLnxlrnzhGs3l+ThkA==","signatures":[{"sig":"MEUCIFIDBl/VdQNa8OHMlVH7cbfB6h+lXUMjSA799quRA9D+AiEA1s6tELSqsI2PGaITzIUK4m/UgWNaRlHnPTQp04UaliU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76881,"size":17091,"noattachment":false,"key":"/flatlint/-/flatlint-3.0.0.tgz"},"main":"lib/flatlint.js","type":"module","engines":{"node":">=20"},"exports":{".":"./lib/flatlint.js","./with-plugins":"./lib/with-plugins.js"},"gitHead":"c979c83962c9d1a08267a48ecdf307c05ea26b3f","imports":{"#test":{"default":"./lib/test/test.js"},"#types":{"default":"./lib/types/types.js"},"#parser":{"default":"./lib/parser/parser.js"},"#runner":{"default":"./lib/runner/runner.js"},"#compare":{"default":"./lib/compare/compare.js"},"#printer":{"default":"./lib/printer/printer.js"},"#flatlint":{"default":"./lib/flatlint.js"},"#traverser":{"default":"./lib/traverser/traverser.js"},"#compare/values":{"default":"./lib/compare/values.js"}},"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","watcher":"madrun watcher","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:lint":"madrun watch:lint","watch:tape":"madrun watch:tape","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"repository":{"url":"git+https://github.com/coderaiser/flatlint.git","type":"git"},"_npmVersion":"11.1.0","description":"JavaScript tokens-based linter","directories":{},"_nodeVersion":"22.14.0","dependencies":{"debug":"^4.4.0","js-tokens":"^9.0.1","@putout/engine-loader":"^15.1.1","@putout/operator-keyword":"^2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","eslint":"^9.7.0","madrun":"^11.0.0","montag":"^1.0.0","putout":"^39.3.0","nodemon":"^3.0.1","supertape":"^11.0.4","@putout/test":"^13.0.0","mock-require":"^3.0.3","eslint-plugin-putout":"^26.1.0","@putout/formatter-json":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/flatlint_3.0.0_1743171755244_0.7746907503046301","host":"s3://npm-registry-packages-npm-production"},"readme":"# FlatLint[![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMURL]: https://npmjs.org/package/flatlint \"npm\"\n[NPMIMGURL]: https://img.shields.io/npm/v/flatlint.svg?style=flat\n[BuildStatusURL]: https://github.com/coderaiser/flatlint/actions?query=workflow%3A%22Node+CI%22 \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/coderaiser/flatlint/workflows/Node%20CI/badge.svg\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[CoverageURL]: https://coveralls.io/github/coderaiser/flatlint?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/flatlint/badge.svg?branch=master&service=github\n\nToken-based JavaScript linter that fixes Syntax Errors\n\n## Install\n\n```\nnpm i flatlint\n```\n\n## Available fixes\n\n<details><summary>apply import order</summary>\n\n```diff\n-import {readFile}, fs from 'node:fs';\n+import fs, {readFile} from 'node:fs';\n```\n\n</details>\n\n<details><summary>apply import <code>from</code></summary>\n\n```diff\n-import fs form 'node:fs';\n+import fs from 'node:fs';\n```\n\n</details>\n\n<details><summary>assignment without parentheses after <code>&&</code></summary>\n\n```diff\n-a && b = c;\n+a && (b = c);\n```\n\n</details>\n\n<details><summary>convert <code>assert</code> to <code>with</code></summary>\n\n```diff\n-import a from 'a' assert {type: 'json'}\n+import a from 'a' with {type: 'json'}\n```\n\n</details>\n\n<details><summary>convert comma to semicolon</summary>\n\n```diff\n-const a = 5,\n+const a = 5;\n\nfunction x() {\n-   return m,\n+   return m;\n}\n\n-import a from 'a',\n+import a from 'a';\n\n-const a = 3,\n+const a = 3;\nmodule.exports = 2;\n```\n\n</details>\n\n<details><summary>convert colon to semicolon</summary>\n\n```diff\n-console.log(a, b):\n+console.log(a, b);\n```\n\n</details>\n\n<details><summary>convert colon to comma</summary>\n\n```diff\nexport const rules = [\n-   ['apply-nesting': applyNesting],\n+   ['apply-nesting', applyNesting],\n];\n```\n\n</details>\n\n<details><summary>convert colon to <code>as</code></summary>\n\n```diff\n-import {simpleImport: _simpleImport} from './simple-import.js';\n+import {simpleImport as _simpleImport} from './simple-import.js';\n```\n\n</details>\n\n<details><summary>convert <code>from</code> to <code>require</code></summary>\n\n```diff\n-const a = from 'a';\n+const a = require('a');\n```\n\n</details>\n\n<details><summary>add missing curly brace</summary>\n\n```diff\n-function a({b, c) {}\n-function a({b, c}) {}\n\n-const {a = b;\n+const {a} = b;\n```\n\n</details>\n\n<details><summary>add missing round brace</summary>\n\n```diff\n-if a > 5 {\n+if (a > 5) {\n    alert();\n}\n\n-if (a.b() {\n+if (a.b()) {\n}\n\n-a('hello'\n+a('hello');\n\nconst m = {\n-    z: z('hello'\n+    z: z('hello')\n}\n\n-{hello} = world;\n+({hello} = world);\n\n-assign(oldPath, currentPath;\n+assign(oldPath, currentPath);\n```\n\n</details>\n\n<details><summary>add missing assign</summary>\n\n```diff\n-const a 5;\n+const a = 5;\n\n-module.exports {};\n+module.exports = {};\n```\n\n</details>\n\n<details><summary>add missing comma</summary>\n\n```diff\nimport {\n-   a\n+   a,\n    b,\n} from 'c';\n\nt.transform('declare-imports-first', {\n-   'declare-imports-first': declareImportsFirst\n+   'declare-imports-first': declareImportsFirst,\n    'convert-esm-to-commonjs': convertEsmToCommonJs,\n});\n```\n\n </details>\n\n<details><summary>add missing <code>const</code></summary>\n\n```diff\n-export {report, scan, fix} = matchFiles();\n+export const {report, scan, fix} = matchFiles();\n```\n\n </details>\n\n<details><summary>add missing arrow <code>'=>'</code></summary>\n\n```diff\n-const a = (b, c) {};\n+const a = (b, c) => {};\n```\n\n </details>\n\n<details><summary>add <code>const</code> to <code>export</code></summary>\n\n```diff\n-export x = 5;\n+export const x = 5;\n```\n\n </details>\n\n<details><summary>add missing squire brace</summary>\n\n```diff\n-const a = ['hello', 'world';\n+const a = ['hello', 'world'];\n```\n\n </details>\n\n<details><summary>remove useless round brace</summary>\n\n```diff\n-const a = 5);\n+const a = 5;\n\n-import a from 'a');\n+import a from 'a';\n\nif (a) {\n-})\n+}\n```\n\n </details>\n\n<details><summary>remove useless import curly braces</summary>\n\n```diff\n-import info from '../package.json' {\n-    with: {\n-        type: 'json',\n-    }\n+import info from '../package.json' with {\n+    type: 'json',\n-};\n```\n\n</details>\n\n<details><summary>remove useless square brace</summary>\n\n```diff\n-const a = [1, 2, 3]];\n+const a = [1, 2, 3];\n```\n\n </details>\n\n<details><summary>convert semicolon to comma</summary>\n\n```diff\nconst a = {\n-    b: 'hello';\n+    b: 'hello',\n}\n\nconst b = [\n    1,\n-   2;\n+   2,\n    3,\n]\n```\n\n </details>\n\n<details><summary>convert <code>module</code> to <code>namespace</code></summary>\n\n```diff\n-module M {\n+namespace M {\n    var a: string;\n}\n```\n\n </details>\n\n<details><summary>remove useless comma</summary>\n\n```diff\nfunction x() {\n    return m;\n-},\n+}\n\n-const expected = [],\n+const expected = [];\nt.equal(expected, []);\n```\n\n </details>\n\n<details><summary>remove useless dot</summary>\n\n```diff\n-fn([]);\n+fn([].);\n```\n\n </details>\n\n<details><summary>remove invalid character</summary>\n\n```diff\n-const {¬\n-····is,¬\n-····sArgsStr,¬\n-····isTypeParamsStr,¬\n-} = require('./is');¬\n+const {\n+    is,\n+    isArgsStr,\n+    isTypeParamsStr,\n+} = require('./is');\n```\n\n </details>\n\n<details><summary>add missing quote</summary>\n\n```diff\n-const a = 'hello\n+const a = 'hello'\n\n-fn('hello);\n+fn('hello');\n```\n\n </details>\n\n<details><summary>Remove useless arrow</summary>\n\n```diff\n-function parse(source) => {\n+function parse(source) {\n    return source;\n}\n```\n\n </details>\n\n<details><summary>Remove useless assign</summary>\n\n```diff\n-import {readFile, readdir} = from 'node:fs/promises';\n+import {readFile, readdir} from 'node:fs/promises';\n```\n\n </details>\n\n<details><summary>Remove useless coma</summary>\n\n```diff\nconst a = class {\n-    b() {},\n+    b() {}\n}\n```\n\n </details>\n\n<details><summary>add missing semicolon</summary>\n\n```diff\n-const a = 5\n+const a = 5;\n```\n\n </details>\n\n<details><summary>add missing <code>if</code></summary>\n\n```diff\n    if (a < 0)\n        console.log('hello');\n-    else (a > 3)\n+    else if (a > 3)\n        console.log('world');\n```\n\n </details>\n\n<details><summary>split <code>namespace</code> with <code>specifiers</code></summary>\n\n```diff\n-import * as plugin, {CUT} from './plugin.js';\n+import * as plugin from './plugin.js';\n+const {CUT} = plugin;\n```\n\n </details>\n\n<details><summary>apply decorator export</summary>\n\n```diff\n-export @Controller('users') class UsersController {\n+@Controller('users') \n+export class UsersController {\n  findAll() {}\n}\n```\n\n </details>\n\n<details><summary>apply decorator private</summary>\n\n```diff\nexport class GithubService {\n    constructor(\n-       private readonly @Inject('OCTOKIT') octokit: Octokit\n+       @Inject('OCTOKIT') private readonly octokit: Octokit\n    ) {}\n}\n```\n\n </details>\n\n## Template literals\n\n**FlatLint** uses language similar to 🐊[**PutoutScript**](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript).\n\nIt can look similar, but has a couple differences:\n\n- ✅ it may not be valid **JavaScript**, it can be couple tokens that can be fixed;\n- ✅ it counts each symbol as a token;\n\n### `__a`\n\nFrom `__a` to `__z` is usually identifiers, but can also be strings if used with quotes `'__a'` they can be single or double,\nit can be only one quote `'__a` - this is valid, since **FlatLint** is tokens based.\n\n### `__array`\n\nCollects everything that looks like array elements, it can start from squire brace `[__array;`, but that's not important\nto end with it, since it used to fix error patterns.\n\n### `__args`\n\nCollects arguments of function when exists.\n\n### `__expr`\n\nCollects everything that looks like expression.\n\n### `__tmpl`\n\nCollects template literal\n\n## API\n\n```js\nimport {lint, plugins} from 'flatlint/with-plugins';\n\nconst [code] = flatlint(`a && b = c`, {\n    plugins,\n});\n\n// returns\n`\na && (b = c);\n`;\n```\n\nWithout `fix`:\n\n```js\nimport {lint, plugins} from 'flatlint/with-plugins';\n\nconst [, places] = flatlint(`a && b = c`, {\n    fix: false,\n    plugins,\n});\n\n// returns\n[{\n    column: 1,\n    line: 1,\n    message: `Wrap the assignment in parentheses after '&&'`,\n    rule: 'wrap-assignment-in-parens',\n}];\n```\n\nWhen you want to use custom plugins:\n\n```js\nimport {lint} from 'flatlint';\n\nconst [code] = lint(`a && b = c`, {\n    startLine: 1,\n    plugins: [\n        ['wrap-assignment-in-parens', {\n            report: () => `Wrap the assignment in parentheses after '&&'`,\n            replace: () => ({\n                '__a && __b = __c': '__a && (__b = __c)',\n            }),\n        }],\n    ],\n});\n```\n\n## License\n\nMIT\n","publish_time":1743171755467,"_cnpm_publish_time":1743171755467,"dist-tags":{"latest":"5.10.3"}}