Package Exports
- eslint-plugin-astro
- eslint-plugin-astro/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-astro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Introduction
eslint-plugin-astro
is ESLint plugin for Astro components.
You can check on the Online DEMO.
This parser is in the experimental stages of development.
📛 What is this plugin?
ESLint plugin for Astro components.
📖 Documentation
See documents.
💿 Installation
npm install --save-dev eslint eslint-plugin-astro astro-eslint-parser @typescript-eslint/parser
Requirements
- ESLint v7.0.0 and above
- Node.js v14.17.x, v16.x and above
📖 Usage
Configuration
Use .eslintrc.*
file to configure rules. See also: https://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
module.exports = {
// ...
overrides: [
{
files: ["*.astro"],
// Enable this plugin
plugins: ["astro"],
env: {
// Enables global variables available in Astro components.
node: true,
"astro/astro": true,
},
parser: "astro-eslint-parser",
// Parse the script in `.astro` as TypeScript by adding the following configuration.
parserOptions: {
parser: "@typescript-eslint/parser",
extraFileExtensions: [".astro"],
},
rules: {
// override/add rules settings here, such as:
// 'astro/rule-name': 'error'
},
},
{
// Define the configuration for `<script>` tag.
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
files: ["**/*.astro/*.js", "*.astro/*.js"],
env: {
browser: true,
},
},
// ...
],
}
Parser Configuration
See https://github.com/ota-meshi/astro-eslint-parser#readme.
Running ESLint from the command line
If you want to run eslint
from the command line, make sure you include the .astro
extension using the --ext
option or a glob pattern, because ESLint targets only .js
files by default.
Examples:
eslint --ext .js,.astro src
eslint "src/**/*.{js,astro}"
💻 Editor Integrations
Visual Studio Code
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You have to configure the eslint.validate
option of the extension to check .astro
files, because the extension targets only *.js
or *.jsx
files by default.
Example .vscode/settings.json:
{
"eslint.validate": ["javascript", "javascriptreact", "astro"]
}
✅ Rules
The --fix
option on the command line automatically fixes problems reported by rules which have a wrench 🔧 below.
No rules have been provided yet.
🍻 Contributing
Welcome contributing!
Please use GitHub's Issues/PRs.
Development Tools
npm test
runs tests and measures coverage.npm run update
runs in order to update readme and recommended configuration.
Working With Rules
This plugin uses astro-eslint-parser for the parser. Check here to find out about AST.
🔒 License
See the LICENSE file for license rights and limitations (MIT).