Skip to content

Commit

Permalink
chore: format/lint .cjs and .mjs files
Browse files Browse the repository at this point in the history
Make sure Prettier, ESLint and lint-staged know about .cjs and .mjs files

Use `@babel/eslint-parser` to parse .cjs and .mjs files and allow the
deprecated import assertions syntax (`assert`) for now.
  • Loading branch information
matijs committed Apr 23, 2024
1 parent e381287 commit 679b412
Show file tree
Hide file tree
Showing 6 changed files with 377 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"sourceType": "module"
},
"overrides": [
{
"files": ["*.mjs", "*.cjs"],
"parser": "@babel/eslint-parser",
"extends": ["eslint-config-prettier", "./.eslintrc.js.json"],
"plugins": ["import"]
},
{
"extends": ["plugin:json/recommended"],
"files": ["*.json"]
Expand Down
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"composer.json": "composer validate",
"package.json": "npmPkgJsonLint --allowEmptyTargets",
"*.md": ["markdownlint", "prettier --check"],
"*.{js,jsx,ts,tsx}": ["eslint --no-error-on-unmatched-pattern", "prettier --check"],
"*.{js,cjs,mjs,jsx,ts,tsx}": ["eslint --no-error-on-unmatched-pattern", "prettier --check"],
"*.{css,scss}": ["stylelint --allow-empty-input", "prettier --check"]
}
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"overrides": [
{
"files": ["*.js", "*.jsx"],
"files": ["*.js", "*.cjs", "*.mjs", "*.jsx"],
"options": {
"parser": "flow",
"printWidth": 120,
Expand Down
10 changes: 10 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": [
[
"@babel/plugin-syntax-import-attributes",
{
"deprecatedAssertSyntax": true
}
]
]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"./packages/*"
],
"devDependencies": {
"@babel/core": "7.24.3",
"@babel/eslint-parser": "7.24.1",
"@babel/plugin-syntax-import-attributes": "7.24.1",
"@lerna-lite/cli": "3.3.1",
"@lerna-lite/publish": "3.3.1",
"@lerna-lite/version": "3.3.1",
Expand All @@ -41,11 +44,11 @@
"build": "pnpm run --recursive --aggregate-output build",
"clean": "pnpm run --recursive --aggregate-output --parallel clean",
"lint": "npm-run-all --continue-on-error lint:** lint-workspaces",
"lint:js": "eslint --ext '.js,.json,.jsx,.mdx,.ts,.tsx' --report-unused-disable-directives .",
"lint:js": "eslint --ext .js,.cjs,.mjs,.json,.jsx,.mdx,.ts,.tsx --report-unused-disable-directives .",
"lint:md": "markdownlint '**/*.md'",
"lint:package-json": "npmPkgJsonLint '**/package.json'",
"lint-fix": "npm-run-all --continue-on-error lint-fix:** prettier",
"lint-fix:js": "eslint --ext '.js,.json,.jsx,.mdx,.ts,.tsx' --fix --report-unused-disable-directives .",
"lint-fix:js": "eslint --ext .js,.cjs,.mjs,.json,.jsx,.mdx,.ts,.tsx --fix --report-unused-disable-directives .",
"lint-fix:md": "markdownlint --fix '**/*.md'",
"lint-workspaces": "pnpm run --recursive --aggregate-output --no-bail lint",
"prepare": "husky",
Expand Down
Loading

0 comments on commit 679b412

Please sign in to comment.