{"name":"rc-config-loader","version":"4.1.4","description":"load config file from .{product}rc.{json,yml,js}","keywords":["config","configuration","json","loader","rc","yaml","yml"],"homepage":"https://github.com/azu/rc-config-loader","bugs":{"url":"https://github.com/azu/rc-config-loader/issues"},"repository":{"type":"git","url":"git+https://github.com/azu/rc-config-loader.git"},"license":"MIT","author":{"name":"azu"},"main":"lib/rc-config-loader.js","types":"lib/rc-config-loader.d.ts","directories":{"test":"test"},"scripts":{"build":"tsc -p .","prepublish":"npm run --if-present build","test":"mocha \"test/**/*.{js,ts}\"","watch":"tsc -p . --watch","format":"prettier --write \"**/*.{js,jsx,ts,tsx,css}\"","prepare":"git config --local core.hooksPath .githooks"},"husky":{"hooks":{"post-commit":"git reset","pre-commit":"lint-staged"}},"lint-staged":{"*.{js,jsx,ts,tsx,css}":["prettier --write"]},"prettier":{"singleQuote":false,"printWidth":120,"tabWidth":4,"trailingComma":"none"},"dependencies":{"debug":"^4.4.3","js-yaml":"^4.1.1","json5":"^2.2.3","require-from-string":"^2.0.2"},"devDependencies":{"@types/mocha":"^10.0.10","@types/node":"^25.3.2","@types/require-from-string":"^1.2.3","lint-staged":"^16.2.7","mocha":"^11.7.5","prettier":"^3.8.1","ts-node":"^10.9.2","ts-node-test-register":"^10.0.0","typescript":"^5.9.3"},"packageManager":"yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610","gitHead":"0af7b97af8b99c2cb224c5172956d5e23634cd72","_id":"rc-config-loader@4.1.4","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-3GiwEzklkbXTDp52UR5nT8iXgYAx1V9ZG/kDZT7p60u2GCv2XTwQq4NzinMoMpNtXhmt3WkhYXcj6HH8HdwCEQ==","shasum":"6cc79042ac193ebed9f082fcba7b823d9dc143cc","tarball":"http://registry-npm.ywwl.com/rc-config-loader/download/rc-config-loader-4.1.4.tgz","fileCount":11,"unpackedSize":28696,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/rc-config-loader@4.1.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDgyjrZoi3wX0SyXagxGKBYU1oQUdG3e282+YBZD5gWvAIhAL+KUumfAQM9eDo3s6KOwN8CJAOrkRbYmbk4+SImBj9X"}],"size":7430,"noattachment":false,"key":"/rc-config-loader/-/rc-config-loader-4.1.4.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3d19b8a4-3a10-483a-b35e-cb2b87eb014f"}},"maintainers":[{"name":"azu","email":"azuciao@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rc-config-loader_4.1.4_1772173252492_0.2875729913873799"},"_hasShrinkwrap":false,"readme":"# rc-config-loader [![Actions Status: test](https://github.com/azu/rc-config-loader/workflows/test/badge.svg)](https://github.com/azu/rc-config-loader/actions?query=workflow%3A\"test\")\n\nLoad config from `.{product}rc.{json,yml,js}` file.\n\nIt is a Node.js library for loading `.textlintrc`, `.eslintrc`, `.stylelintrc` etc...\n\n## Features\n\nFind and load a configuration object from:\n\n- a `package.json` property if it is needed\n- a JSON or YAML, JS \"rc file\"\n    - `.<product>rc` or `.<product>rc.json` or `.<product>rc.js` or`.<product>rc.yml`, `.<product>rc.yaml`\n- TypeScript support\n    - Includes `.d.ts`\n\n## Difference\n\n### with [MoOx/rc-loader](https://github.com/MoOx/rc-loader \"MoOx/rc-loader\")\n\n- Safe API\n    - `rc` contains shabang in `.js` file\n- Enhance Error message\n\n### with [cosmiconfig](https://github.com/davidtheclark/cosmiconfig \"cosmiconfig\")\n\n- <del>Sync loading</del>\n    - [cosmiconfig@3+](https://github.com/davidtheclark/cosmiconfig/blob/master/CHANGELOG.md#300) support `sync` option\n- <del>Built-in TypeScript support</del>\n    - [comisconfig@6*](https://github.com/davidtheclark/cosmiconfig/blob/master/CHANGELOG.md#600) is written by TypeScript\n\nIf you want to async support and customize loader, recommended to use [cosmiconfig](https://github.com/davidtheclark/cosmiconfig).\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n    npm install rc-config-loader\n\n## Usage\n\n### API\n\n```ts\nexport interface rcConfigLoaderOption {\n    // does look for `package.json`\n    packageJSON?:\n        | boolean\n        | {\n              fieldName: string;\n          };\n    // if config file name is not same with packageName, set the name\n    configFileName?: string;\n    // treat default(no ext file) as some extension\n    defaultExtension?: string | string[];\n    // where start to load\n    cwd?: string;\n}\n/**\n * Find and load rcfile, return { config, filePath }\n * If not found any rcfile, throw an Error.\n * @param {string} pkgName\n * @param {rcConfigLoaderOption} [opts]\n * @returns {{ config: Object, filePath:string } | undefined}\n */\nexport declare function rcFile<R extends {}>(pkgName: string, opts?: rcConfigLoaderOption): {\n    config: R;\n    filePath: string;\n} | undefined;\n\n```\n\n`rcFile` return `{ config, filePath }` object.\n\n- `config`: it is config object\n- `filePath`: absolute path to config file\n\n**Note:**\n \n- `rcFile` function return `undefined` if the config file is not found\n- `rcFile` throw an Error if the config file content is malformed (causing a parsing error)\n\nRecommenced usage:\n\n```js\nimport { rcFile } from \"rc-config-loader\"\n\nfunction loadRcFile(rcFileName){\n    try {\n        const results = rcFile(rcFileName);\n        // Not Found\n        if (!results) {\n            return {};\n        }\n        return results.config;\n    } catch (error) {\n        // Found it, but it is parsing error\n        return {} ; // default value\n    }\n}\n// load config\nconst config = loadRcFile(\"your-application\");\nconsole.log(config); // => rcfile content\n```\n\nIt will check these files and return config file if found it.\n\n- `.your-applicationrc.json`\n- `.your-applicationrc.yml`\n- `.your-applicationrc.yaml`\n- `.your-applicationrc.js`\n- [optional] `package.json`\n  - if `packageJSON` option is enabled\n\n### Example\n\n```js\nimport { rcFile } from \"rc-config-loader\"\n// load .eslintrc from current dir\nconsole.log(rcFile(\"eslint\"));\n\n// load .eslintrc from specific path\nconsole.log(rcFile(\"eslint\", {\n    configFileName: `${__dirname}/test/fixtures/.eslintrc`\n}));\n/*\nconfig: { extends: 'standard',\n  rules:\n   { 'comma-dangle': [ 2, 'always-multiline' ],\n     'arrow-parens': [ 2, 'as-needed' ] } }\nfilePath: ${__dirname}/test/fixtures/.eslintrc\n */\n\n// load property from package.json\nconsole.log(rcFile(\"rc-config-loader\", {\n    packageJSON: {\n        fieldName: \"directories\"\n    }\n}));\n/*\nconfig: { test: 'test' }\nfilePath: /path/to/package.json\n */\n\n// load .eslintrc from specific dir\nconsole.log(rcFile(\"eslint\", {\n    cwd: `${__dirname}/test/fixtures`\n}));\n\n// load specific filename from current dir\nconsole.log(rcFile(\"travis\", {configFileName: \".travis\"}));\n/*\nconfig: { sudo: false, language: 'node_js', node_js: 'stable' }\nfilePath: /path/to/.travis\n */\n\n// try to load as .json, .yml, js\nconsole.log(rcFile(\"bar\", {\n    configFileName: `${__dirname}/test/fixtures/.barrc`,\n    defaultExtension: [\".json\", \".yml\", \".js\"]\n}));\n\n// try to load as foobar, but .foobarrc is not found\nconsole.log(rcFile(\"foorbar\")); // => undefined\n\n// try to load as .json, but it is not json\n// throw SyntaxError\ntry {\n    rcFile(\"unknown\", {\n        // This is not json\n        configFileName: `${__dirname}/test/fixtures/.unknownrc`,\n        defaultExtension: \".json\"\n    })\n} catch (error) {\n    console.log(error);\n    /*\n    SyntaxError: Cannot read config file: /test/fixtures/.unknownrc\n    */\n}\n```\n\n## Users\n\n- [textlint](https://github.com/textlint/textlint \"textlint\")\n\n## Changelog\n\nSee [Releases page](https://github.com/azu/rc-config-loader/releases).\n\n## Running tests\n\nInstall devDependencies and Run `npm test`:\n\n    npm i -d && npm test\n\n## Contributing\n\nPull requests and stars are always welcome.\n\nFor bugs and feature requests, [please create an issue](https://github.com/azu/rc-config-loader/issues).\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n- [github/azu](https://github.com/azu)\n- [twitter/azu_re](https://twitter.com/azu_re)\n\n## License\n\nMIT © azu\n\n## Acknowledgement\n\n- [zkochan/rcfile: Loads library configuration in all possible ways](https://github.com/zkochan/rcfile \"zkochan/rcfile: Loads library configuration in all possible ways\")\n\n**Difference**\n\n- support multiple `defaultExtension`  \n","publish_time":1772173252640,"_cnpm_publish_time":1772173252640,"dist-tags":{"latest":"4.1.4"}}