-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eslint should lint javascript in html <script>
tags
#1405
Comments
We need to handle disabling eslint when we copy the package.json. Subject: [PATCH] so hard, so bad
---
Index: js/grunt/lint.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/lint.js b/js/grunt/lint.js
--- a/js/grunt/lint.js (revision 2ba9214be503ebc571645ffda5c150a1d26c68b4)
+++ b/js/grunt/lint.js (date 1695934812770)
@@ -80,7 +80,7 @@
// Our custom rules live here
rulePaths: [ '../chipper/eslint/rules' ],
- extensions: [ '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs' ],
+ extensions: [ '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.html' ],
// If no lintable files are found, it is not an error
errorOnUnmatchedPattern: false
Index: eslint/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js
--- a/eslint/.eslintrc.js (revision 2ba9214be503ebc571645ffda5c150a1d26c68b4)
+++ b/eslint/.eslintrc.js (date 1695934980483)
@@ -16,6 +16,9 @@
// Without a parser, .js files are linted without es6 transpilation. Use the same parser that we use for TypeScript.
parser: '@typescript-eslint/parser',
+ // Lint javascript in HTML files too
+ plugins: [ 'html' ],
+
overrides: [
{
Index: eslint/.eslintignore
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintignore b/eslint/.eslintignore
--- a/eslint/.eslintignore (revision 2ba9214be503ebc571645ffda5c150a1d26c68b4)
+++ b/eslint/.eslintignore (date 1695935029780)
@@ -5,6 +5,7 @@
**/snapshots
**/js/parser/svgPath.js
**/templates/*.js
+**/templates/*.html
**/js/**/*Strings.ts
**/images/**/*_cur.ts
**/images/**/*_jpg.ts
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision 2ba9214be503ebc571645ffda5c150a1d26c68b4)
+++ b/package.json (date 1695934812773)
@@ -37,6 +37,7 @@
"docdash": "~1.2.0",
"eslint": "~8.28.0",
"eslint-plugin-react": "~7.31.11",
+ "eslint-plugin-html": "~7.1.0",
"grunt": "~1.5.3",
"html-webpack-plugin": "~5.3.2",
"jimp": "~0.16.1",
Index: eslint/rules/copyright.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/rules/copyright.js b/eslint/rules/copyright.js
--- a/eslint/rules/copyright.js (revision 2ba9214be503ebc571645ffda5c150a1d26c68b4)
+++ b/eslint/rules/copyright.js (date 1695935151301)
@@ -18,6 +18,12 @@
// Get the whole source code, not for node only.
const comments = context.getSourceCode().getAllComments();
+ const isHTML = context.getFilename().endsWith( '.html' );
+
+ if ( isHTML ) {
+ return;
+ }
+
if ( !comments || comments.length === 0 ) {
context.report( {
node: node, |
In #1408 I updated dev HTML and a11y view files to pass our lint (by ignoring double quotes that will occur when copying the packagejson into the file. That can be committed before turning on lint generally. |
After #1408 I saw an infinite loop occurring in fenster/. After removing that from the list, here is the report:
|
|
|
Subject: [PATCH] fix lint common code a11y views, https://github.com/phetsims/chipper/issues/1408
---
Index: js/grunt/lint.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/lint.js b/js/grunt/lint.js
--- a/js/grunt/lint.js (revision 56029937a372997654028bc63fcfb3ef2d3c77fe)
+++ b/js/grunt/lint.js (date 1696001681767)
@@ -19,7 +19,7 @@
const crypto = require( 'crypto' );
// constants
-const EXCLUDE_REPOS = [];
+const EXCLUDE_REPOS = [ 'fenster' ];
// "Pattern" is really a path, we assume here that gruntfiles help keep the right directory stucture and can just pop
// out of the repo running the command
@@ -80,7 +80,7 @@
// Our custom rules live here
rulePaths: [ '../chipper/eslint/rules' ],
- extensions: [ '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs' ],
+ extensions: [ '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.html' ],
// If no lintable files are found, it is not an error
errorOnUnmatchedPattern: false
Index: eslint/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js
--- a/eslint/.eslintrc.js (revision 56029937a372997654028bc63fcfb3ef2d3c77fe)
+++ b/eslint/.eslintrc.js (date 1696001652905)
@@ -16,6 +16,9 @@
// Without a parser, .js files are linted without es6 transpilation. Use the same parser that we use for TypeScript.
parser: '@typescript-eslint/parser',
+ // Lint javascript in HTML files too
+ plugins: [ 'html' ],
+
overrides: [
{
Index: eslint/.eslintignore
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintignore b/eslint/.eslintignore
--- a/eslint/.eslintignore (revision 56029937a372997654028bc63fcfb3ef2d3c77fe)
+++ b/eslint/.eslintignore (date 1696001652903)
@@ -5,6 +5,7 @@
**/snapshots
**/js/parser/svgPath.js
**/templates/*.js
+**/templates/*.html
**/js/**/*Strings.ts
**/images/**/*_cur.ts
**/images/**/*_jpg.ts
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision 56029937a372997654028bc63fcfb3ef2d3c77fe)
+++ b/package.json (date 1696001652907)
@@ -37,6 +37,7 @@
"docdash": "~1.2.0",
"eslint": "~8.28.0",
"eslint-plugin-react": "~7.31.11",
+ "eslint-plugin-html": "~7.1.0",
"grunt": "~1.5.3",
"html-webpack-plugin": "~5.3.2",
"jimp": "~0.16.1",
Index: eslint/rules/copyright.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/rules/copyright.js b/eslint/rules/copyright.js
--- a/eslint/rules/copyright.js (revision 56029937a372997654028bc63fcfb3ef2d3c77fe)
+++ b/eslint/rules/copyright.js (date 1696001652905)
@@ -18,6 +18,12 @@
// Get the whole source code, not for node only.
const comments = context.getSourceCode().getAllComments();
+ const isHTML = context.getFilename().endsWith( '.html' );
+
+ if ( isHTML ) {
+ return;
+ }
+
if ( !comments || comments.length === 0 ) {
context.report( {
node: node, |
I finally got to a commit point here. I would like to touch base with @samreid about a couple of things.
|
Discussed during dev meeting today:
|
I fixed a couple more files I felt like were important, I'm going to unassign from here, and let the TODOs point to this issue. Basically I'm fine closing this issue, or letting it last forever having eslint-disable directives point here. If anyone feels differently, please update the TODOs (remove them?) and feel free to close. |
This feature is having problems with ESLint 9, see #1451 (comment) |
It looks like we got JS in HTML linting again, I can test it by renaming beers-law-lab_en.html to test.html and running grunt lint. |
Reopening because there is a TODO marked for this issue. |
Oops forgot about the 60+ TODOs here, let's leave open until those are addressed. |
With a very small patch, we can lint our js into HTML. The issue will be handling the lint errors.
https://www.npmjs.com/package/eslint-plugin-html
The text was updated successfully, but these errors were encountered: