A platform for community discussion. Free, open, simple.
DEV: Lint .mjs and .cjs files locally (#42110)
Sérgio Saquetim79b187189c78
diff --git a/bin/lint b/bin/lintindex 277b0fd4f42..2fa3ad3d431 100755--- a/bin/lint+++ b/bin/lint@@ -13,7 +13,7 @@ PROJECT_ROOT = File.expand_path("..", __dir__)class ExternalLinterRUBY_EXTENSIONS = %w[rb rake thor].freezePRETTIER_EXTENSIONS = %w[css scss js gjs cjs mjs ts gts mts cts].freeze- ESLINT_EXTENSIONS = %w[js gjs ts gts mts cts].freeze+ ESLINT_EXTENSIONS = %w[js gjs cjs mjs ts gts mts cts].freezeSTYLELINT_EXTENSIONS = %w[scss].freezeJS_EXTENSIONS = (PRETTIER_EXTENSIONS + ESLINT_EXTENSIONS + STYLELINT_EXTENSIONS).uniq.freeze@@ -239,7 +239,7 @@ class LefthookLinterend# Check if file extension is lintable- lintable_extensions = %w[rb rake js gjs ts gts mts cts hbs scss css yml yaml thor]+ lintable_extensions = %w[rb rake js gjs cjs mjs ts gts mts cts hbs scss css yml yaml thor]lintable_extensions.include?(ext)enddiff --git a/lefthook.yml b/lefthook.ymlindex 9288cae1fde..16e514c14c7 100644--- a/lefthook.yml+++ b/lefthook.yml@@ -37,9 +37,9 @@ pre-commit:run: pnpm pprettier --list-different {staged_files}eslint:glob: &eslint_glob- - "frontend/**/*.{js,gjs,ts,gts,mts,cts}"- - "plugins/**/*.{js,gjs,ts,gts,mts,cts}"- - "themes/**/*.{js,gjs,ts,gts,mts,cts}"+ - "frontend/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs}"+ - "plugins/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs}"+ - "themes/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs}"run: pnpm eslint --max-warnings 0 {staged_files}yaml-syntax:glob: &yaml_glob "**/*.{yaml,yml}"diff --git a/package.json b/package.jsonindex 0ab205bd455..878e5d43612 100644--- a/package.json+++ b/package.json@@ -32,8 +32,8 @@"lint:css:fix": "pnpm stylelint --fix 'app/assets/stylesheets/**/*.scss' $(script/list_bundled_plugins '/assets/stylesheets/**/*.scss') 'themes/**/*.scss'","lint:js": "eslint ./frontend $(script/list_bundled_plugins) ./themes --cache --no-error-on-unmatched-pattern --max-warnings 0","lint:js:fix": "eslint --fix ./frontend $(script/list_bundled_plugins) ./themes --no-error-on-unmatched-pattern",- "lint:prettier": "pnpm pprettier --list-different 'app/assets/stylesheets/**/*.scss' 'frontend/**/*.{js,gjs,ts,gts,mts,cts,css}' $(script/list_bundled_plugins '/assets/stylesheets/**/*.scss') $(script/list_bundled_plugins '/{assets,admin/assets,test}/javascripts/**/*.{js,gjs,ts,gts,mts,cts}') 'themes/**/*.{js,gjs,ts,gts,scss}'",- "lint:prettier:fix": "pnpm prettier -w --no-error-on-unmatched-pattern 'app/assets/stylesheets/**/*.scss' 'frontend/**/*.{js,gjs,ts,gts,mts,cts,css}' $(script/list_bundled_plugins '/assets/stylesheets/**/*.scss') $(script/list_bundled_plugins '/{assets,admin/assets,test}/javascripts/**/*.{js,gjs,ts,gts,mts,cts}') 'themes/**/*.{js,gjs,ts,gts,scss}'",+ "lint:prettier": "pnpm pprettier --list-different 'app/assets/stylesheets/**/*.scss' 'frontend/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs,css}' $(script/list_bundled_plugins '/assets/stylesheets/**/*.scss') $(script/list_bundled_plugins '/{assets,admin/assets,test}/javascripts/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs}') 'themes/**/*.{js,gjs,ts,gts,cjs,mjs,scss}'",+ "lint:prettier:fix": "pnpm prettier -w --no-error-on-unmatched-pattern 'app/assets/stylesheets/**/*.scss' 'frontend/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs,css}' $(script/list_bundled_plugins '/assets/stylesheets/**/*.scss') $(script/list_bundled_plugins '/{assets,admin/assets,test}/javascripts/**/*.{js,gjs,ts,gts,mts,cts,cjs,mjs}') 'themes/**/*.{js,gjs,ts,gts,cjs,mjs,scss}'","lint:types": "ember-tsc -b","types:generate": "pnpm --dir=frontend/discourse-i18n ember-tsc && pnpm --dir=frontend/discourse-types generate-external","types:watch": "pnpm types:generate && pnpm ember-tsc -b --watch --preserveWatchOutput",