@2digits/eslint-config 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
3
  var localPkg = require('local-pkg');
4
- var a = require('path');
4
+ var p = require('path');
5
5
  var url = require('url');
6
- var k = require('process');
7
- var P = require('fs');
6
+ var C = require('process');
7
+ var v = require('fs');
8
8
  var pathe = require('pathe');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
- var a__default = /*#__PURE__*/_interopDefault(a);
13
- var k__default = /*#__PURE__*/_interopDefault(k);
14
- var P__default = /*#__PURE__*/_interopDefault(P);
12
+ var p__default = /*#__PURE__*/_interopDefault(p);
13
+ var C__default = /*#__PURE__*/_interopDefault(C);
14
+ var v__default = /*#__PURE__*/_interopDefault(v);
15
15
 
16
- var m=localPkg.isPackageExists("react"),h=m?{"react/prop-types":["off"],"react/react-in-jsx-scope":["off"],"react/jsx-newline":["error",{prevent:!1}]}:{},g=m?["plugin:react/recommended","plugin:react-hooks/recommended"]:[],x=m?{react:{version:"detect"}}:{};var w={"@typescript-eslint/ban-ts-comment":["error",{"ts-ignore":"allow-with-description"}],"@typescript-eslint/consistent-type-exports":["error"],"@typescript-eslint/consistent-type-imports":["error",{prefer:"type-imports",disallowTypeAnnotations:!1,fixStyle:"separate-type-imports"}],"@typescript-eslint/naming-convention":["warn",{selector:"typeParameter",format:["PascalCase"],leadingUnderscore:"allow",custom:{regex:"^(T|\\$)[A-Z][a-zA-Z]+[0-9]*$",match:!0}}],"@typescript-eslint/no-empty-interface":["error",{allowSingleExtends:!0}],"@typescript-eslint/no-explicit-any":["warn"]};var I={"unicorn/filename-case":["off"],"unicorn/prefer-module":["off"],"unicorn/prevent-abbreviations":["off"],"unicorn/prefer-ternary":["error","only-single-line"]};var v={directory:"isDirectory",file:"isFile"};function U(t){if(!Object.hasOwnProperty.call(v,t))throw new Error(`Invalid type specified: ${t}`)}var j=(t,e)=>e[v[t]](),q=t=>t instanceof URL?url.fileURLToPath(t):t;function y(t,{cwd:e=k__default.default.cwd(),type:r="file",allowSymlinks:p=!0}={}){U(r),e=q(e);let f=p?P__default.default.statSync:P__default.default.lstatSync;for(let i of t)try{let o=f(a__default.default.resolve(e,i),{throwIfNoEntry:!1});if(!o)continue;if(j(r,o))return i}catch{}}var A=t=>t instanceof URL?url.fileURLToPath(t):t,_=Symbol("findUpStop");function z(t,e={}){let r=a__default.default.resolve(A(e.cwd)||""),{root:p}=a__default.default.parse(r),f=e.stopAt||p,i=e.limit||Number.POSITIVE_INFINITY,o=[t].flat(),T=s=>{if(typeof t!="function")return y(o,s);let l=t(s.cwd);return typeof l=="string"?y([l],s):l},u=[];for(;;){let s=T({...e,cwd:r});if(s===_||(s&&u.push(a__default.default.resolve(r,s)),r===f||u.length>=i))break;r=a__default.default.dirname(r);}return u}function b(t,e={}){return z(t,{...e,limit:1})[0]}var S=b(["pnpm-workspace.yaml","pnpm-lock.yaml"]),E=S&&pathe.dirname(S);var Y=localPkg.isPackageExists("next"),Ft={root:!0,parserOptions:{sourceType:"module",project:["./tsconfig.json","./packages/*/tsconfig.json","./apps/*/tsconfig.json"],tsconfigRootDir:E,cacheLifetime:{glob:"Infinity"}},extends:["eslint:recommended","turbo",Y&&"next","plugin:unicorn/recommended","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict",...g,"prettier"].filter(t=>!!t),parser:"@typescript-eslint/parser",env:{es6:!0,node:!0},ignorePatterns:["node_modules","dist","build","coverage","public","tmp","tmp-build","!.prettierrc.js","templates"],settings:{...x},rules:{...w,...h,...I,"sort-imports":["off"]}};
16
+ var c=localPkg.getPackageInfoSync("react")?.version,h=c?{"react/prop-types":["off"],"react/react-in-jsx-scope":["off"],"react/jsx-newline":["error",{prevent:!1}]}:{},g=c?["plugin:react/recommended","plugin:react-hooks/recommended"]:[],x=c?{react:{version:c}}:{};var w={"@typescript-eslint/ban-ts-comment":["error",{"ts-ignore":"allow-with-description"}],"@typescript-eslint/consistent-type-exports":["error"],"@typescript-eslint/consistent-type-imports":["error",{prefer:"type-imports",disallowTypeAnnotations:!1,fixStyle:"separate-type-imports"}],"@typescript-eslint/naming-convention":["warn",{selector:"typeParameter",format:["PascalCase"],leadingUnderscore:"allow",custom:{regex:"^(T|\\$)[A-Z][a-zA-Z]+[0-9]*$",match:!0}}],"@typescript-eslint/no-empty-interface":["error",{allowSingleExtends:!0}],"@typescript-eslint/no-explicit-any":["warn"],"@typescript-eslint/no-import-type-side-effects":["error"]};var I={"unicorn/filename-case":["error",{cases:{camelCase:!0,pascalCase:!0}}],"unicorn/prefer-module":["off"],"unicorn/prevent-abbreviations":["off"],"unicorn/prefer-ternary":["error","only-single-line"]};var P={directory:"isDirectory",file:"isFile"};function U(t){if(!Object.hasOwnProperty.call(P,t))throw new Error(`Invalid type specified: ${t}`)}var j=(t,e)=>e[P[t]](),q=t=>t instanceof URL?url.fileURLToPath(t):t;function y(t,{cwd:e=C__default.default.cwd(),type:r="file",allowSymlinks:f=!0}={}){U(r),e=q(e);let u=f?v__default.default.statSync:v__default.default.lstatSync;for(let i of t)try{let o=u(p__default.default.resolve(e,i),{throwIfNoEntry:!1});if(!o)continue;if(j(r,o))return i}catch{}}var A=t=>t instanceof URL?url.fileURLToPath(t):t,_=Symbol("findUpStop");function z(t,e={}){let r=p__default.default.resolve(A(e.cwd)||""),{root:f}=p__default.default.parse(r),u=e.stopAt||f,i=e.limit||Number.POSITIVE_INFINITY,o=[t].flat(),T=s=>{if(typeof t!="function")return y(o,s);let m=t(s.cwd);return typeof m=="string"?y([m],s):m},l=[];for(;;){let s=T({...e,cwd:r});if(s===_||(s&&l.push(p__default.default.resolve(r,s)),r===u||l.length>=i))break;r=p__default.default.dirname(r);}return l}function S(t,e={}){return z(t,{...e,limit:1})[0]}var b=S(["pnpm-workspace.yaml","pnpm-lock.yaml"]),E=b&&pathe.dirname(b);var Y=localPkg.isPackageExists("next"),Ft={root:!0,parserOptions:{sourceType:"module",project:["./tsconfig.json","./packages/*/tsconfig.json","./apps/*/tsconfig.json"],tsconfigRootDir:E,cacheLifetime:{glob:"Infinity"}},extends:["eslint:recommended","turbo",Y&&"next","plugin:unicorn/recommended","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict",...g,"prettier"].filter(t=>!!t),parser:"@typescript-eslint/parser",env:{es6:!0,node:!0},ignorePatterns:["node_modules","dist","build","coverage","public","tmp","tmp-build","!.prettierrc.js","templates"],settings:{...x},rules:{...w,...h,...I,"sort-imports":["off"],"max-params":["warn"]}};
17
17
 
18
18
  module.exports = Ft;
19
19
  //# sourceMappingURL=out.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/rules/react.ts","../src/rules/typescript.ts","../src/rules/unicorn.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js","../src/utils.ts"],"names":["isPackageExists","reactInProject","rules","extendsConfig","settings","typescript","unicorn","path","fileURLToPath","process","fs","fsPromises","Node","value","Queue","#head","#tail","#size","node","current","typeMappings","checkType","type","matchType","stat","toPath","urlOrPath","locatePathSync","paths","cwd","allowSymlinks","statFunction","path_","findUpStop","findUpMultipleSync","name","options","directory","root","stopAt","limit","runMatcher","locateOptions","foundPath","matches","findUpSync","dirname","workspaceRoot","tsconfigRootDir","isNextInProject","src_default","a"],"mappings":"AACA,OAAS,mBAAAA,MAAuB,YCAhC,OAAS,mBAAAA,MAAuB,YAEhC,IAAMC,EAAiBD,EAAgB,OAAO,EAEjCE,EACXD,EACI,CACE,m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ACA,wCACA,gEACA,mCAEA,GAAS9C,EAET,UACF,EAAE,OAAQgD,GAA4B,CAAC,CAACA,CAAC,EACzC,OAAQ,4BACR,IAAK,CACH,IAAK,GACL,KAAM,EACR,EACA,eAAgB,CACd,eACA,OACA,QACA,WACA,SACA,MACA,YACA,kBACA,WACF,EACA,SAAU,CACR,GAAS/C,CACX,EACA,MAAO,CACL,GAAGC,EAEH,GAASH,EAET,GAAGI,EAEH,eAAgB,CAAC,KAAK,CACxB,CACF","sourcesContent":["import type { KnownExtensions } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nimport * as React from './rules/react';\nimport { typescript } from './rules/typescript';\nimport { unicorn } from './rules/unicorn';\nimport { defineConfig, tsconfigRootDir } from './utils';\n\nconst isNextInProject = isPackageExists('next');\n\nexport default defineConfig({\n root: true,\n parserOptions: {\n sourceType: 'module',\n project: ['./tsconfig.json', './packages/*/tsconfig.json', './apps/*/tsconfig.json'],\n tsconfigRootDir,\n cacheLifetime: {\n glob: 'Infinity',\n },\n },\n extends: [\n 'eslint:recommended',\n 'turbo',\n\n isNextInProject && 'next',\n\n 'plugin:unicorn/recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@typescript-eslint/recommended-requiring-type-checking',\n 'plugin:@typescript-eslint/strict',\n\n ...React.extendsConfig,\n\n 'prettier',\n ].filter((a): a is KnownExtensions => !!a),\n parser: '@typescript-eslint/parser',\n env: {\n es6: true,\n node: true,\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n 'public',\n 'tmp',\n 'tmp-build',\n '!.prettierrc.js',\n 'templates',\n ],\n settings: {\n ...React.settings,\n },\n rules: {\n ...typescript,\n\n ...React.rules,\n\n ...unicorn,\n\n 'sort-imports': ['off'],\n },\n});\n","import type { Extends, Rules, Settings } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nconst reactInProject = isPackageExists('react');\n\nexport const rules = (\n reactInProject\n ? {\n 'react/prop-types': ['off'],\n 'react/react-in-jsx-scope': ['off'],\n 'react/jsx-newline': [\n 'error',\n {\n prevent: false,\n },\n ],\n }\n : {}\n) satisfies Rules;\n\nexport const extendsConfig = (\n reactInProject ? ['plugin:react/recommended', 'plugin:react-hooks/recommended'] : []\n) satisfies Extends;\n\nexport const settings = (\n reactInProject\n ? {\n react: {\n version: 'detect',\n },\n }\n : {}\n) satisfies Settings;\n","import type { Rules } from 'eslint-define-config';\n\nexport const typescript = {\n '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],\n '@typescript-eslint/consistent-type-exports': ['error'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n disallowTypeAnnotations: false,\n fixStyle: 'separate-type-imports',\n },\n ],\n '@typescript-eslint/naming-convention': [\n 'warn',\n {\n selector: 'typeParameter',\n format: ['PascalCase'],\n leadingUnderscore: 'allow',\n custom: { regex: '^(T|\\\\$)[A-Z][a-zA-Z]+[0-9]*$', match: true },\n },\n ],\n '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],\n '@typescript-eslint/no-explicit-any': ['warn'],\n} satisfies Rules;\n","import type { Rules } from 'eslint-define-config';\n\nexport const unicorn = {\n 'unicorn/filename-case': ['off'],\n 'unicorn/prefer-module': ['off'],\n 'unicorn/prevent-abbreviations': ['off'],\n 'unicorn/prefer-ternary': ['error', 'only-single-line'],\n} satisfies Rules;\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import type { ESLintConfig } from 'eslint-define-config';\nimport { findUpSync } from 'find-up';\nimport { dirname } from 'pathe';\n\nexport function defineConfig<const TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n\nconst workspaceRoot = findUpSync(['pnpm-workspace.yaml', 'pnpm-lock.yaml']);\n\nexport const tsconfigRootDir = workspaceRoot && dirname(workspaceRoot);\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/rules/react.ts","../src/rules/typescript.ts","../src/rules/unicorn.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js","../src/utils.ts"],"names":["isPackageExists","getPackageInfoSync","reactVersion","rules","extendsConfig","settings","typescript","unicorn","path","fileURLToPath","process","fs","fsPromises","Node","value","Queue","#head","#tail","#size","node","current","typeMappings","checkType","type","matchType","stat","toPath","urlOrPath","locatePathSync","paths","cwd","allowSymlinks","statFunction","path_","findUpStop","findUpMultipleSync","name","options","directory","root","stopAt","limit","runMatcher","locateOptions","foundPath","matches","findUpSync","dirname","workspaceRoot","tsconfigRootDir","isNextInProject","src_default","a"],"mappings":"AACA,OAAS,mBAAAA,MAAuB,YCAhC,OAAS,sBAAAC,MAA0B,YAEnC,IAAMC,EAAeD,EAAmB,OAAO,GAAG,QAErCE,EACXD,EACI,CACE,mBAAoB,CAAC,KAAK,EAC1B,2BAA4B,CAAC,KAAK,EAClC,oBAAqB,CACnB,QACA,CACE,QAAS,EACX,CACF,CACF,EACA,CAAC,EAGME,EACXF,EAAe,CAAC,2BAA4B,gCAAgC,EAAI,CAAC,EAGtEG,EACXH,EACI,CACE,MAAO,CACL,QAASA,CACX,CACF,EACA,CAAC,EC7BA,IAAMI,EAAa,CACxB,oCAAqC,CAAC,QAAS,CAAE,YAAa,wBAAyB,CAAC,EACxF,6CAA8C,CAAC,OAAO,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C,EAEH,GAASH,EAET,GAAGI,EAEH,eAAgB,CAAC,KAAK,EACtB,aAAc,CAAC,MAAM,CACvB,CACF","sourcesContent":["import type { KnownExtensions } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nimport * as React from './rules/react';\nimport { typescript } from './rules/typescript';\nimport { unicorn } from './rules/unicorn';\nimport { defineConfig, tsconfigRootDir } from './utils';\n\nconst isNextInProject = isPackageExists('next');\n\nexport default defineConfig({\n root: true,\n parserOptions: {\n sourceType: 'module',\n project: ['./tsconfig.json', './packages/*/tsconfig.json', './apps/*/tsconfig.json'],\n tsconfigRootDir,\n cacheLifetime: {\n glob: 'Infinity',\n },\n },\n extends: [\n 'eslint:recommended',\n 'turbo',\n\n isNextInProject && 'next',\n\n 'plugin:unicorn/recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@typescript-eslint/recommended-requiring-type-checking',\n 'plugin:@typescript-eslint/strict',\n\n ...React.extendsConfig,\n\n 'prettier',\n ].filter((a): a is KnownExtensions => !!a),\n parser: '@typescript-eslint/parser',\n env: {\n es6: true,\n node: true,\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n 'public',\n 'tmp',\n 'tmp-build',\n '!.prettierrc.js',\n 'templates',\n ],\n settings: {\n ...React.settings,\n },\n rules: {\n ...typescript,\n\n ...React.rules,\n\n ...unicorn,\n\n 'sort-imports': ['off'],\n 'max-params': ['warn'],\n },\n});\n","import type { Extends, Rules, Settings } from 'eslint-define-config';\nimport { getPackageInfoSync } from 'local-pkg';\n\nconst reactVersion = getPackageInfoSync('react')?.version;\n\nexport const rules = (\n reactVersion\n ? {\n 'react/prop-types': ['off'],\n 'react/react-in-jsx-scope': ['off'],\n 'react/jsx-newline': [\n 'error',\n {\n prevent: false,\n },\n ],\n }\n : {}\n) satisfies Rules;\n\nexport const extendsConfig = (\n reactVersion ? ['plugin:react/recommended', 'plugin:react-hooks/recommended'] : []\n) satisfies Extends;\n\nexport const settings = (\n reactVersion\n ? {\n react: {\n version: reactVersion,\n },\n }\n : {}\n) satisfies Settings;\n","import type { Rules } from 'eslint-define-config';\n\nexport const typescript = {\n '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],\n '@typescript-eslint/consistent-type-exports': ['error'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n disallowTypeAnnotations: false,\n fixStyle: 'separate-type-imports',\n },\n ],\n '@typescript-eslint/naming-convention': [\n 'warn',\n {\n selector: 'typeParameter',\n format: ['PascalCase'],\n leadingUnderscore: 'allow',\n custom: { regex: '^(T|\\\\$)[A-Z][a-zA-Z]+[0-9]*$', match: true },\n },\n ],\n '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],\n '@typescript-eslint/no-explicit-any': ['warn'],\n '@typescript-eslint/no-import-type-side-effects': ['error'],\n} satisfies Rules;\n","import type { Rules } from 'eslint-define-config';\n\nexport const unicorn = {\n 'unicorn/filename-case': ['error', { cases: { camelCase: true, pascalCase: true } }],\n 'unicorn/prefer-module': ['off'],\n 'unicorn/prevent-abbreviations': ['off'],\n 'unicorn/prefer-ternary': ['error', 'only-single-line'],\n} satisfies Rules;\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import type { ESLintConfig } from 'eslint-define-config';\nimport { findUpSync } from 'find-up';\nimport { dirname } from 'pathe';\n\nexport function defineConfig<const TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n\nconst workspaceRoot = findUpSync(['pnpm-workspace.yaml', 'pnpm-lock.yaml']);\n\nexport const tsconfigRootDir = workspaceRoot && dirname(workspaceRoot);\n"]}
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { isPackageExists } from 'local-pkg';
2
- import p from 'node:path';
1
+ import { getPackageInfoSync, isPackageExists } from 'local-pkg';
2
+ import f from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
- import C from 'node:process';
5
- import v from 'node:fs';
4
+ import k from 'node:process';
5
+ import P from 'node:fs';
6
6
  import { dirname } from 'pathe';
7
7
 
8
- var d=isPackageExists("react"),g=d?{"react/prop-types":["off"],"react/react-in-jsx-scope":["off"],"react/jsx-newline":["error",{prevent:!1}]}:{},x=d?["plugin:react/recommended","plugin:react-hooks/recommended"]:[],w=d?{react:{version:"detect"}}:{};var I={"@typescript-eslint/ban-ts-comment":["error",{"ts-ignore":"allow-with-description"}],"@typescript-eslint/consistent-type-exports":["error"],"@typescript-eslint/consistent-type-imports":["error",{prefer:"type-imports",disallowTypeAnnotations:!1,fixStyle:"separate-type-imports"}],"@typescript-eslint/naming-convention":["warn",{selector:"typeParameter",format:["PascalCase"],leadingUnderscore:"allow",custom:{regex:"^(T|\\$)[A-Z][a-zA-Z]+[0-9]*$",match:!0}}],"@typescript-eslint/no-empty-interface":["error",{allowSingleExtends:!0}],"@typescript-eslint/no-explicit-any":["warn"]};var P={"unicorn/filename-case":["off"],"unicorn/prefer-module":["off"],"unicorn/prevent-abbreviations":["off"],"unicorn/prefer-ternary":["error","only-single-line"]};var b={directory:"isDirectory",file:"isFile"};function j(t){if(!Object.hasOwnProperty.call(b,t))throw new Error(`Invalid type specified: ${t}`)}var q=(t,e)=>e[b[t]](),F=t=>t instanceof URL?fileURLToPath(t):t;function h(t,{cwd:e=C.cwd(),type:r="file",allowSymlinks:f=!0}={}){j(r),e=F(e);let u=f?v.statSync:v.lstatSync;for(let o of t)try{let c=u(p.resolve(e,o),{throwIfNoEntry:!1});if(!c)continue;if(q(r,c))return o}catch{}}var _=t=>t instanceof URL?fileURLToPath(t):t,z=Symbol("findUpStop");function M(t,e={}){let r=p.resolve(_(e.cwd)||""),{root:f}=p.parse(r),u=e.stopAt||f,o=e.limit||Number.POSITIVE_INFINITY,c=[t].flat(),N=i=>{if(typeof t!="function")return h(c,i);let m=t(i.cwd);return typeof m=="string"?h([m],i):m},l=[];for(;;){let i=N({...e,cwd:r});if(i===z||(i&&l.push(p.resolve(r,i)),r===u||l.length>=o))break;r=p.dirname(r);}return l}function S(t,e={}){return M(t,{...e,limit:1})[0]}var E=S(["pnpm-workspace.yaml","pnpm-lock.yaml"]),T=E&&dirname(E);var D=isPackageExists("next"),jt={root:!0,parserOptions:{sourceType:"module",project:["./tsconfig.json","./packages/*/tsconfig.json","./apps/*/tsconfig.json"],tsconfigRootDir:T,cacheLifetime:{glob:"Infinity"}},extends:["eslint:recommended","turbo",D&&"next","plugin:unicorn/recommended","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict",...x,"prettier"].filter(t=>!!t),parser:"@typescript-eslint/parser",env:{es6:!0,node:!0},ignorePatterns:["node_modules","dist","build","coverage","public","tmp","tmp-build","!.prettierrc.js","templates"],settings:{...w},rules:{...I,...g,...P,"sort-imports":["off"]}};
8
+ var a=getPackageInfoSync("react")?.version,g=a?{"react/prop-types":["off"],"react/react-in-jsx-scope":["off"],"react/jsx-newline":["error",{prevent:!1}]}:{},x=a?["plugin:react/recommended","plugin:react-hooks/recommended"]:[],w=a?{react:{version:a}}:{};var I={"@typescript-eslint/ban-ts-comment":["error",{"ts-ignore":"allow-with-description"}],"@typescript-eslint/consistent-type-exports":["error"],"@typescript-eslint/consistent-type-imports":["error",{prefer:"type-imports",disallowTypeAnnotations:!1,fixStyle:"separate-type-imports"}],"@typescript-eslint/naming-convention":["warn",{selector:"typeParameter",format:["PascalCase"],leadingUnderscore:"allow",custom:{regex:"^(T|\\$)[A-Z][a-zA-Z]+[0-9]*$",match:!0}}],"@typescript-eslint/no-empty-interface":["error",{allowSingleExtends:!0}],"@typescript-eslint/no-explicit-any":["warn"],"@typescript-eslint/no-import-type-side-effects":["error"]};var v={"unicorn/filename-case":["error",{cases:{camelCase:!0,pascalCase:!0}}],"unicorn/prefer-module":["off"],"unicorn/prevent-abbreviations":["off"],"unicorn/prefer-ternary":["error","only-single-line"]};var S={directory:"isDirectory",file:"isFile"};function j(t){if(!Object.hasOwnProperty.call(S,t))throw new Error(`Invalid type specified: ${t}`)}var q=(t,e)=>e[S[t]](),F=t=>t instanceof URL?fileURLToPath(t):t;function h(t,{cwd:e=k.cwd(),type:r="file",allowSymlinks:u=!0}={}){j(r),e=F(e);let l=u?P.statSync:P.lstatSync;for(let o of t)try{let c=l(f.resolve(e,o),{throwIfNoEntry:!1});if(!c)continue;if(q(r,c))return o}catch{}}var _=t=>t instanceof URL?fileURLToPath(t):t,z=Symbol("findUpStop");function V(t,e={}){let r=f.resolve(_(e.cwd)||""),{root:u}=f.parse(r),l=e.stopAt||u,o=e.limit||Number.POSITIVE_INFINITY,c=[t].flat(),N=i=>{if(typeof t!="function")return h(c,i);let d=t(i.cwd);return typeof d=="string"?h([d],i):d},m=[];for(;;){let i=N({...e,cwd:r});if(i===z||(i&&m.push(f.resolve(r,i)),r===l||m.length>=o))break;r=f.dirname(r);}return m}function b(t,e={}){return V(t,{...e,limit:1})[0]}var E=b(["pnpm-workspace.yaml","pnpm-lock.yaml"]),T=E&&dirname(E);var D=isPackageExists("next"),jt={root:!0,parserOptions:{sourceType:"module",project:["./tsconfig.json","./packages/*/tsconfig.json","./apps/*/tsconfig.json"],tsconfigRootDir:T,cacheLifetime:{glob:"Infinity"}},extends:["eslint:recommended","turbo",D&&"next","plugin:unicorn/recommended","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict",...x,"prettier"].filter(t=>!!t),parser:"@typescript-eslint/parser",env:{es6:!0,node:!0},ignorePatterns:["node_modules","dist","build","coverage","public","tmp","tmp-build","!.prettierrc.js","templates"],settings:{...w},rules:{...I,...g,...v,"sort-imports":["off"],"max-params":["warn"]}};
9
9
 
10
10
  export { jt as default };
11
11
  //# sourceMappingURL=out.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/rules/react.ts","../src/rules/typescript.ts","../src/rules/unicorn.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../src/utils.ts"],"names":["isPackageExists","reactInProject","rules","extendsConfig","settings","typescript","unicorn","path","fileURLToPath","process","fs","fsPromises","Node","value","Queue","#head","#tail","#size","node","current","typeMappings","checkType","type","matchType","stat","toPath","urlOrPath","locatePathSync","paths","cwd","allowSymlinks","statFunction","path_","findUpStop","findUpMultipleSync","name","options","directory","root","stopAt","limit","runMatcher","locateOptions","foundPath","matches","findUpSync","dirname","workspaceRoot","tsconfigRootDir","isNextInProject","src_default","a"],"mappings":"AACA,OAAS,mBAAAA,MAAuB,YCAhC,OAAS,mBAAAA,MAAuB,YAEhC,IAAMC,EAAiBD,EAAgB,OAAO,EAEjCE,EACXD,EACI,CACE,mBAAoB,CAAC,KAAK,EAC1B,2BAA4B,CAAC,KAAK,EAClC,oBAAqB,CACnB,QACA,CACE,QAAS,EACX,CACF,CACF,EACA,CAAC,EAGME,EACXF,EAAiB,CAAC,2BAA4B,gCAAgC,EAAI,CAAC,EAGxEG,EACXH,EACI,CACE,MAAO,CACL,QAAS,QACX,CACF,EACA,CAAC,EC7BA,IAAMI,EAAa,CACxB,oCAAqC,CAAC,QAAS,CAAE,YAAa,wBAAyB,CAAC,EACxF,6CAA8C,CAAC,OAAO,EACtD,6CAA8C,CAC5C,QACA,CACE,OAAQ,eACR,wBAAyB,GACzB,SAAU,uBACZ,CACF,EACA,uCAAwC,CACtC,OACA,CACE,SAAU,gBACV,OA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C,EAAU,CAAC,EAEjB,OAAa,CACZ,IAAMD,EAAYF,EAAW,CAAC,GAAGL,EAAS,IAAKC,CAAS,CAAC,EAUzD,GARIM,IAAcV,IAIdU,GACHC,EAAQ,KAAKrC,EAAK,QAAQ8B,EAAWM,CAAS,CAAC,EAG5CN,IAAcE,GAAUK,EAAQ,QAAUJ,GAC7C,MAGDH,EAAY9B,EAAK,QAAQ8B,CAAS,EAGnC,OAAOO,CACR,CAOO,SAASC,EAAWV,EAAMC,EAAU,CAAC,EAAG,CAE9C,OADgBF,EAAmBC,EAAM,CAAC,GAAGC,EAAS,MAAO,CAAC,CAAC,EAChD,CAAC,CACjB,CGrGA,OAAS,WAAAU,MAAe,QAMxB,IAAMC,EAAgBF,EAAW,CAAC,sBAAuB,gBAAgB,CAAC,EAE7DG,EAAkBD,GAAiBD,EAAQC,CAAa,EPFrE,IAAME,EAAkBjD,EAAgB,MAAM,EAEvCkD,GAAqB,CAC1B,KAAM,GACN,cAAe,CACb,WAAY,SACZ,QAAS,CAAC,kBAAmB,6BAA8B,wBAAwB,EACnF,gBAAAF,EACA,cAAe,CACb,KAAM,UACR,CACF,EACA,QAAS,CACP,qBACA,QAEAC,GAAmB,OAEnB,6BACA,wCACA,gEACA,mCAEA,GAAS9C,EAET,UACF,EAAE,OAAQgD,GAA4B,CAAC,CAACA,CAAC,EACzC,OAAQ,4BACR,IAAK,CACH,IAAK,GACL,KAAM,EACR,EACA,eAAgB,CACd,eACA,OACA,QACA,WACA,SACA,MACA,YACA,kBACA,WACF,EACA,SAAU,CACR,GAAS/C,CACX,EACA,MAAO,CACL,GAAGC,EAEH,GAASH,EAET,GAAGI,EAEH,eAAgB,CAAC,KAAK,CACxB,CACF","sourcesContent":["import type { KnownExtensions } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nimport * as React from './rules/react';\nimport { typescript } from './rules/typescript';\nimport { unicorn } from './rules/unicorn';\nimport { defineConfig, tsconfigRootDir } from './utils';\n\nconst isNextInProject = isPackageExists('next');\n\nexport default defineConfig({\n root: true,\n parserOptions: {\n sourceType: 'module',\n project: ['./tsconfig.json', './packages/*/tsconfig.json', './apps/*/tsconfig.json'],\n tsconfigRootDir,\n cacheLifetime: {\n glob: 'Infinity',\n },\n },\n extends: [\n 'eslint:recommended',\n 'turbo',\n\n isNextInProject && 'next',\n\n 'plugin:unicorn/recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@typescript-eslint/recommended-requiring-type-checking',\n 'plugin:@typescript-eslint/strict',\n\n ...React.extendsConfig,\n\n 'prettier',\n ].filter((a): a is KnownExtensions => !!a),\n parser: '@typescript-eslint/parser',\n env: {\n es6: true,\n node: true,\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n 'public',\n 'tmp',\n 'tmp-build',\n '!.prettierrc.js',\n 'templates',\n ],\n settings: {\n ...React.settings,\n },\n rules: {\n ...typescript,\n\n ...React.rules,\n\n ...unicorn,\n\n 'sort-imports': ['off'],\n },\n});\n","import type { Extends, Rules, Settings } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nconst reactInProject = isPackageExists('react');\n\nexport const rules = (\n reactInProject\n ? {\n 'react/prop-types': ['off'],\n 'react/react-in-jsx-scope': ['off'],\n 'react/jsx-newline': [\n 'error',\n {\n prevent: false,\n },\n ],\n }\n : {}\n) satisfies Rules;\n\nexport const extendsConfig = (\n reactInProject ? ['plugin:react/recommended', 'plugin:react-hooks/recommended'] : []\n) satisfies Extends;\n\nexport const settings = (\n reactInProject\n ? {\n react: {\n version: 'detect',\n },\n }\n : {}\n) satisfies Settings;\n","import type { Rules } from 'eslint-define-config';\n\nexport const typescript = {\n '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],\n '@typescript-eslint/consistent-type-exports': ['error'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n disallowTypeAnnotations: false,\n fixStyle: 'separate-type-imports',\n },\n ],\n '@typescript-eslint/naming-convention': [\n 'warn',\n {\n selector: 'typeParameter',\n format: ['PascalCase'],\n leadingUnderscore: 'allow',\n custom: { regex: '^(T|\\\\$)[A-Z][a-zA-Z]+[0-9]*$', match: true },\n },\n ],\n '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],\n '@typescript-eslint/no-explicit-any': ['warn'],\n} satisfies Rules;\n","import type { Rules } from 'eslint-define-config';\n\nexport const unicorn = {\n 'unicorn/filename-case': ['off'],\n 'unicorn/prefer-module': ['off'],\n 'unicorn/prevent-abbreviations': ['off'],\n 'unicorn/prefer-ternary': ['error', 'only-single-line'],\n} satisfies Rules;\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import type { ESLintConfig } from 'eslint-define-config';\nimport { findUpSync } from 'find-up';\nimport { dirname } from 'pathe';\n\nexport function defineConfig<const TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n\nconst workspaceRoot = findUpSync(['pnpm-workspace.yaml', 'pnpm-lock.yaml']);\n\nexport const tsconfigRootDir = workspaceRoot && dirname(workspaceRoot);\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/rules/react.ts","../src/rules/typescript.ts","../src/rules/unicorn.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../src/utils.ts"],"names":["isPackageExists","getPackageInfoSync","reactVersion","rules","extendsConfig","settings","typescript","unicorn","path","fileURLToPath","process","fs","fsPromises","Node","value","Queue","#head","#tail","#size","node","current","typeMappings","checkType","type","matchType","stat","toPath","urlOrPath","locatePathSync","paths","cwd","allowSymlinks","statFunction","path_","findUpStop","findUpMultipleSync","name","options","directory","root","stopAt","limit","runMatcher","locateOptions","foundPath","matches","findUpSync","dir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ME,EAAkBlD,EAAgB,MAAM,EAEvCmD,GAAqB,CAC1B,KAAM,GACN,cAAe,CACb,WAAY,SACZ,QAAS,CAAC,kBAAmB,6BAA8B,wBAAwB,EACnF,gBAAAF,EACA,cAAe,CACb,KAAM,UACR,CACF,EACA,QAAS,CACP,qBACA,QAEAC,GAAmB,OAEnB,6BACA,wCACA,gEACA,mCAEA,GAAS9C,EAET,UACF,EAAE,OAAQgD,GAA4B,CAAC,CAACA,CAAC,EACzC,OAAQ,4BACR,IAAK,CACH,IAAK,GACL,KAAM,EACR,EACA,eAAgB,CACd,eACA,OACA,QACA,WACA,SACA,MACA,YACA,kBACA,WACF,EACA,SAAU,CACR,GAAS/C,CACX,EACA,MAAO,CACL,GAAGC,EAEH,GAASH,EAET,GAAGI,EAEH,eAAgB,CAAC,KAAK,EACtB,aAAc,CAAC,MAAM,CACvB,CACF","sourcesContent":["import type { KnownExtensions } from 'eslint-define-config';\nimport { isPackageExists } from 'local-pkg';\n\nimport * as React from './rules/react';\nimport { typescript } from './rules/typescript';\nimport { unicorn } from './rules/unicorn';\nimport { defineConfig, tsconfigRootDir } from './utils';\n\nconst isNextInProject = isPackageExists('next');\n\nexport default defineConfig({\n root: true,\n parserOptions: {\n sourceType: 'module',\n project: ['./tsconfig.json', './packages/*/tsconfig.json', './apps/*/tsconfig.json'],\n tsconfigRootDir,\n cacheLifetime: {\n glob: 'Infinity',\n },\n },\n extends: [\n 'eslint:recommended',\n 'turbo',\n\n isNextInProject && 'next',\n\n 'plugin:unicorn/recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@typescript-eslint/recommended-requiring-type-checking',\n 'plugin:@typescript-eslint/strict',\n\n ...React.extendsConfig,\n\n 'prettier',\n ].filter((a): a is KnownExtensions => !!a),\n parser: '@typescript-eslint/parser',\n env: {\n es6: true,\n node: true,\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n 'public',\n 'tmp',\n 'tmp-build',\n '!.prettierrc.js',\n 'templates',\n ],\n settings: {\n ...React.settings,\n },\n rules: {\n ...typescript,\n\n ...React.rules,\n\n ...unicorn,\n\n 'sort-imports': ['off'],\n 'max-params': ['warn'],\n },\n});\n","import type { Extends, Rules, Settings } from 'eslint-define-config';\nimport { getPackageInfoSync } from 'local-pkg';\n\nconst reactVersion = getPackageInfoSync('react')?.version;\n\nexport const rules = (\n reactVersion\n ? {\n 'react/prop-types': ['off'],\n 'react/react-in-jsx-scope': ['off'],\n 'react/jsx-newline': [\n 'error',\n {\n prevent: false,\n },\n ],\n }\n : {}\n) satisfies Rules;\n\nexport const extendsConfig = (\n reactVersion ? ['plugin:react/recommended', 'plugin:react-hooks/recommended'] : []\n) satisfies Extends;\n\nexport const settings = (\n reactVersion\n ? {\n react: {\n version: reactVersion,\n },\n }\n : {}\n) satisfies Settings;\n","import type { Rules } from 'eslint-define-config';\n\nexport const typescript = {\n '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],\n '@typescript-eslint/consistent-type-exports': ['error'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n disallowTypeAnnotations: false,\n fixStyle: 'separate-type-imports',\n },\n ],\n '@typescript-eslint/naming-convention': [\n 'warn',\n {\n selector: 'typeParameter',\n format: ['PascalCase'],\n leadingUnderscore: 'allow',\n custom: { regex: '^(T|\\\\$)[A-Z][a-zA-Z]+[0-9]*$', match: true },\n },\n ],\n '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],\n '@typescript-eslint/no-explicit-any': ['warn'],\n '@typescript-eslint/no-import-type-side-effects': ['error'],\n} satisfies Rules;\n","import type { Rules } from 'eslint-define-config';\n\nexport const unicorn = {\n 'unicorn/filename-case': ['error', { cases: { camelCase: true, pascalCase: true } }],\n 'unicorn/prefer-module': ['off'],\n 'unicorn/prevent-abbreviations': ['off'],\n 'unicorn/prefer-ternary': ['error', 'only-single-line'],\n} satisfies Rules;\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import type { ESLintConfig } from 'eslint-define-config';\nimport { findUpSync } from 'find-up';\nimport { dirname } from 'pathe';\n\nexport function defineConfig<const TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n\nconst workspaceRoot = findUpSync(['pnpm-workspace.yaml', 'pnpm-lock.yaml']);\n\nexport const tsconfigRootDir = workspaceRoot && dirname(workspaceRoot);\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@2digits/eslint-config",
3
3
  "description": "Effortlessly enforce best practices and catch errors with this comprehensive ESLint configuration for TypeScript, featuring popular plugins like @typescript-eslint, eslint-plugin-react, and eslint-plugin-unicorn.",
4
- "version": "0.3.3",
4
+ "version": "0.4.0",
5
5
  "license": "MIT",
6
6
  "public": true,
7
7
  "sideEffects": false,
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@types/eslint": "^8.40.0",
31
- "@typescript-eslint/eslint-plugin": "^5.59.7",
32
- "@typescript-eslint/parser": "^5.59.7",
33
- "eslint-config-next": "^13.4.3",
31
+ "@typescript-eslint/eslint-plugin": "^5.59.8",
32
+ "@typescript-eslint/parser": "^5.59.8",
33
+ "eslint-config-next": "^13.4.4",
34
34
  "eslint-config-prettier": "^8.8.0",
35
35
  "eslint-config-turbo": "^1.9.9",
36
36
  "eslint-plugin-react": "^7.32.2",
@@ -41,12 +41,15 @@
41
41
  "pathe": "^1.1.0"
42
42
  },
43
43
  "devDependencies": {
44
+ "@2digits/tsconfig": "*",
44
45
  "eslint": ">=8.41.0",
45
46
  "eslint-define-config": "^1.20.0",
46
47
  "tsup": "^6.7.0",
47
48
  "turbo": "^1.9.9",
48
- "typescript": "^5.0.4",
49
- "@2digits/tsconfig": "0.1.2"
49
+ "typescript": "^5.0.4"
50
+ },
51
+ "eslintConfig": {
52
+ "extends": "@2digits"
50
53
  },
51
54
  "scripts": {
52
55
  "build": "tsup",