{"_id":"@ayan4m1/gatsby-plugin-eslint","name":"@ayan4m1/gatsby-plugin-eslint","dist-tags":{"latest":"5.0.0"},"versions":{"5.0.0":{"name":"@ayan4m1/gatsby-plugin-eslint","description":"Gatsby plugin to add support for ESLint","version":"5.0.0","license":"MIT","author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"contributors":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"homepage":"https://github.com/ayan4m1/gatsby-plugin-eslint","bugs":{"url":"https://github.com/ayan4m1/gatsby-plugin-eslint/issues"},"repository":{"type":"git","url":"git+https://github.com/ayan4m1/gatsby-plugin-eslint.git"},"keywords":["gatsby","gatsby-plugin","eslint"],"main":"index.js","scripts":{"dev":"onchange \"src/**/*.js\" -- yarn run build","build":"babel src --out-dir .","prepare":"husky","prepublishOnly":"npm run build"},"devDependencies":{"@babel/cli":"^7.25.6","@babel/core":"^7.25.2","babel-preset-gatsby-package":"^3.13.1","husky":"^9.1.6","lint-staged":"^15.2.10","onchange":"^7.1.0","prettier":"^3.3.3"},"peerDependencies":{"eslint":"^7.18.0 || ^8 || ^9","eslint-webpack-plugin":"^2.4.3 || ^3 || ^4","gatsby":"^2 || ^3 || ^4 || ^5"},"dependencies":{"webpack-merge":"^6.0.1"},"licenseText":"MIT License\n\nCopyright (c) 2018 mongkuen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@ayan4m1/gatsby-plugin-eslint@5.0.0","dist":{"shasum":"ce8836757702c978f5c7d7f570b4df8448f2ac14","integrity":"sha512-a7UVNwu1IoA6B6p1C0P3UKFYrIpnoHtwNJtfbMfRCWr64cl67qfrOJn3IFIZ4C7PvLYgMiuVrqfLzswbXPFnFQ==","tarball":"https://registry.npmjs.org/@ayan4m1/gatsby-plugin-eslint/-/gatsby-plugin-eslint-5.0.0.tgz","fileCount":5,"unpackedSize":7426,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAvIY/m70k5cIsmcHGUERm7JyiP4KIzRmPhX0t+66Iu2AiAxv/2dB8qjzLKZ/1LVtlpqpnYh4E5yQeH92RGN8IPRgQ=="}]},"_npmUser":{"name":"ayan4m1","email":"andrew@bulletlogic.com"},"directories":{},"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-plugin-eslint_5.0.0_1727669104810_0.23051793283427946"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-30T04:05:04.662Z","5.0.0":"2024-09-30T04:05:05.010Z","modified":"2024-09-30T04:05:05.332Z"},"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"description":"Gatsby plugin to add support for ESLint","homepage":"https://github.com/ayan4m1/gatsby-plugin-eslint","keywords":["gatsby","gatsby-plugin","eslint"],"repository":{"type":"git","url":"git+https://github.com/ayan4m1/gatsby-plugin-eslint.git"},"contributors":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"bugs":{"url":"https://github.com/ayan4m1/gatsby-plugin-eslint/issues"},"license":"MIT","readme":"# gatsby-plugin-eslint\n\nReplaces Gatsby's ESLint Webpack configs, giving you full control to customize linting with the rules and developer experience you specifically need to maintain code quality.\n\nThis will COMPLETELY OVERWRITE any ESLint Webpack Plugins that Gatsby uses.\nThe installation instructions will help you reactivate the [two required rules as of writing](https://www.gatsbyjs.com/docs/how-to/custom-configuration/eslint/#configuring-eslint):\n\n- [`no-anonymous-exports-page-templates`](https://github.com/gatsbyjs/gatsby/blob/fbfe3f63dec23d279a27b54b4057dd611dce74bb/packages/gatsby/src/utils/eslint-rules/no-anonymous-exports-page-templates.ts)\n- [`limited-exports-page-templates`](https://github.com/gatsbyjs/gatsby/blob/fbfe3f63dec23d279a27b54b4057dd611dce74bb/packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts)\n\n## Installation\n\n`npm install --save-dev gatsby-plugin-eslint eslint-webpack-plugin`\n\nor\n\n`yarn add --dev gatsby-plugin-eslint eslint-webpack-plugin`\n\n## Default Settings\n\n1. Lints development mode in the `'develop'` stage. Add other [Webpack Config Stages](https://www.gatsbyjs.com/docs/production-app/#webpack-config) into `stages` array to enable linting during other Gatsby stages (eg. `build-javascript`)\n2. Lint `.js`, `.jsx`, `.ts`, and `.tsx` files.\n3. Excludes `node_modules`, `bower_components`, `.cache`, and `public` folders from linting\n4. Otherwise uses [`eslint-webpack-plugin`](https://github.com/webpack-contrib/eslint-webpack-plugin#options) option defaults\n\n## Usage\n\n1. Create `eslint.config.mjs` file in project root.\n\n   ```js\n   export default [\n     {\n       files: ['src/**/*.js'],\n       rules: {\n         'no-anonymous-exports-page-templates': 'warn',\n         'limited-exports-page-templates': 'warn'\n       }\n     }\n   ];\n   ```\n\n2. Add plugin into `gatsby-config.js`\n\n   ```js\n   // gatsby-config.js\n\n   const path = require('path');\n   // Get paths of Gatsby's required rules, which as of writing is located at\n   // https://github.com/gatsbyjs/gatsby/tree/gatsby%405.3.3/packages/gatsby/src/utils/eslint-rules\n   const gatsbyRequiredRules = path.join(\n     process.cwd(),\n     'node_modules',\n     'gatsby',\n     'dist',\n     'utils',\n     'eslint-rules'\n   );\n\n   module.exports = {\n     plugins: [\n       // ...other plugins\n       {\n         resolve: 'gatsby-plugin-eslint',\n         options: {\n           configType: 'flat',\n           eslintPath: 'eslint/use-at-your-own-risk',\n           // Optional path for Gatsby required rules\n           rulePaths: [gatsbyRequiredRules]\n           // Default settings that may be omitted or customized\n           // stages: ['develop'],\n           // extensions: ['js', 'jsx', 'ts', 'tsx'],\n           // exclude: ['node_modules', 'bower_components', '.cache', 'public']\n         }\n       }\n     ]\n   };\n   ```\n\n3. Additionally as of writing, [Gatsby's default ESLint config](https://github.com/gatsbyjs/gatsby/blob/fbfe3f63dec23d279a27b54b4057dd611dce74bb/packages/gatsby/src/utils/eslint-config.ts) may be copied over if you would still like to take advavntage of those rules.\n\n## Configuring ESLint (To Be Updated For Flat Config)\n\nMix and match your own ESLint plugins and rules depending on the React/Javascript/Typescript patterns you want to enforce. Here are three ways you can get started:\n\n### Basic React Linting with [`eslint-plugin-react`](https://github.com/yannickcr/eslint-plugin-react)\n\n1. Follow [`eslint-plugin-react`](https://github.com/yannickcr/eslint-plugin-react) plugin installation procedures:\n\n   `npm install --save-dev eslint-plugin-react babel-eslint`\n\n   or\n\n   `yarn add --dev eslint-plugin-react babel-eslint`\n\n2. Add `.eslintrc` file to project root:\n\n   ```js\n   {\n     \"parser\": \"babel-eslint\", // uses babel-eslint transforms\n     \"settings\": {\n       \"react\": {\n         \"version\": \"detect\" // detect react version\n       }\n     },\n     \"env\": {\n       \"node\": true // defines things like process.env when generating through node\n     },\n     \"extends\": [\n       \"eslint:recommended\", // use recommended configs\n       \"plugin:react/recommended\"\n     ],\n     \"rules\": {\n       \"no-anonymous-exports-page-templates\": \"warn\",\n       \"limited-exports-page-templates\": \"warn\"\n     }\n   }\n   ```\n\n### Typescript Linting with [ESLint Plugin Typescript](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin)\n\n1. Follow [`@typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin installation procedures:\n\n   `npm install --save-dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin`\n\n   or\n\n   `yarn add --dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin`\n\n2. Add `.eslintrc` file to project root:\n\n   ```js\n   {\n     \"extends\": [\n       \"eslint:recommended\",\n       \"plugin:@typescript-eslint/recommended\",\n     ],\n     \"rules\": {\n       \"no-anonymous-exports-page-templates\": \"warn\",\n       \"limited-exports-page-templates\": \"warn\"\n     }\n   }\n   ```\n","readmeFilename":"README.md"}