astro-eslint-parser 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -11,6 +11,7 @@ You can check it on [Online DEMO](https://ota-meshi.github.io/astro-eslint-parse
11
11
  [![NPM downloads](https://img.shields.io/npm/dy/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)
12
12
  [![NPM downloads](https://img.shields.io/npm/dt/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)
13
13
  [![Build Status](https://github.com/ota-meshi/astro-eslint-parser/workflows/CI/badge.svg?branch=main)](https://github.com/ota-meshi/astro-eslint-parser/actions?query=workflow%3ACI)
14
+ [![Coverage Status](https://coveralls.io/repos/github/ota-meshi/astro-eslint-parser/badge.svg?branch=main)](https://coveralls.io/github/ota-meshi/astro-eslint-parser?branch=main)
14
15
 
15
16
  This parser is in the ***experimental stages*** of development.
16
17
 
@@ -133,6 +134,17 @@ Example **.vscode/settings.json**:
133
134
  }
134
135
  ```
135
136
 
137
+ ## Compatibility With Existing ESLint Rules
138
+
139
+ Most of the rules in the ESLint core work for the script part, but some rules are incompatible.
140
+ For example, the [semi] rule doesn't work.
141
+ This parser will generate a JSX compatible AST for most of the HTML part of the Astro component. Therefore, some rules of [eslint-plugin-react] may work.
142
+ For example, the [react/jsx-no-target-blank] rule works fine.
143
+
144
+ [semi]: https://eslint.org/docs/rules/semi
145
+ [eslint-plugin-react]: https://github.com/jsx-eslint/eslint-plugin-react/
146
+ [react/jsx-no-target-blank]: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
147
+
136
148
  ## Usage for Custom Rules / Plugins
137
149
 
138
150
  - TBA
@@ -46,6 +46,11 @@ class ScriptContext {
46
46
  if (last.expression.type !== "JSXFragment") {
47
47
  throw new errors_1.ParseError("Unknown state error: Expected JSXFragment", last.expression.range[0], this.ctx);
48
48
  }
49
+ // Process for Astro
50
+ const rootFragment = (result.ast.body[result.ast.body.length - 1] = last.expression);
51
+ delete rootFragment.closingFragment;
52
+ delete rootFragment.openingFragment;
53
+ rootFragment.type = "AstroRootFragment";
49
54
  // remap locations
50
55
  const traversed = new Set();
51
56
  (0, traverse_1.traverseNodes)(result.ast, {
@@ -72,11 +77,6 @@ class ScriptContext {
72
77
  for (const token of result.ast.comments || []) {
73
78
  this.remapLocation(token);
74
79
  }
75
- // Process for Astro
76
- delete last.expression.closingFragment;
77
- delete last.expression.openingFragment;
78
- last.expression.type =
79
- "AstroRootFragment";
80
80
  let restoreNodeProcesses = this.restoreNodeProcesses;
81
81
  for (const node of traversed) {
82
82
  restoreNodeProcesses = restoreNodeProcesses.filter((proc) => !proc(node, result));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-eslint-parser",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Astro parser for ESLint",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -62,7 +62,7 @@
62
62
  "benchmark": "^2.1.4",
63
63
  "chai": "^4.3.4",
64
64
  "code-red": "^0.2.3",
65
- "eslint": "^8.2.0",
65
+ "eslint": "^8.14.0",
66
66
  "eslint-config-prettier": "^8.3.0",
67
67
  "eslint-formatter-codeframe": "^7.32.1",
68
68
  "eslint-plugin-eslint-comments": "^3.2.0",
@@ -71,12 +71,13 @@
71
71
  "eslint-plugin-node": "^11.1.0",
72
72
  "eslint-plugin-node-dependencies": "^0.8.0",
73
73
  "eslint-plugin-prettier": "^4.0.0",
74
+ "eslint-plugin-react": "^7.29.4",
74
75
  "eslint-plugin-regexp": "^1.5.0",
75
76
  "eslint-plugin-vue": "^8.0.3",
76
77
  "estree-walker": "^3.0.0",
77
78
  "locate-character": "^2.0.5",
78
79
  "magic-string": "^0.26.0",
79
- "mocha": "^9.1.3",
80
+ "mocha": "^10.0.0",
80
81
  "mocha-chai-jest-snapshot": "^1.1.3",
81
82
  "nyc": "^15.1.0",
82
83
  "prettier": "^2.0.5",