diff --git a/mon-pix/.eslintignore b/mon-pix/.eslintignore deleted file mode 100644 index 886b038e7d4..00000000000 --- a/mon-pix/.eslintignore +++ /dev/null @@ -1,26 +0,0 @@ -# https://eslint.org/docs/user-guide/configuring#eslintignore -# .file are implicitly ignored, unless explicitly specified here - -/blueprints/*/files/**/*.js - -# compiled output -/dist/ -/tmp/ - -# dependencies -/bower_components/ -/node_modules/ - -# misc -/coverage/ -!.* - -# ember-try -/.node_modules.ember-try/ -/bower.json.ember-try -/package.json.ember-try - -# Phrase generated translation files -/translations/*.json -!/translations/en.json -!/translations/fr.json diff --git a/mon-pix/.eslintrc.cjs b/mon-pix/.eslintrc.cjs deleted file mode 100644 index da3b5e932df..00000000000 --- a/mon-pix/.eslintrc.cjs +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - parser: '@babel/eslint-parser', - parserOptions: { - requireConfigFile: false, - ecmaVersion: 2018, - sourceType: 'module', - babelOptions: { - plugins: [['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }]], - }, - }, - plugins: ['ember', 'qunit'], - extends: ['@1024pix', 'plugin:ember/recommended', 'plugin:qunit/recommended', 'plugin:prettier/recommended'], - env: { - browser: true, - }, - rules: { - 'no-console': 'error', - 'no-duplicate-imports': 'error', - 'no-restricted-imports': [ - 'error', - 'lodash', - { - name: '@ember/test-helpers', - importNames: ['render', 'visit', 'find'], - message: - "Please import 'render' from '@1024pix/ember-testing-library'.\n Please import 'visit' from '@1024pix/ember-testing-library'.\n. 'find' should be replaced with '@1024pix/ember-testing-library' 'find...'/'get...'/'query...' methods to enforce accessible usages.", - }, - ], - 'ember/avoid-leaking-state-in-ember-objects': 'off', - 'ember/no-get': ['error'], - 'ember/no-empty-attrs': 'error', - 'ember/no-new-mixins': 'off', - 'ember/no-restricted-resolver-tests': 'off', - 'ember/use-ember-data-rfc-395-imports': 'error', - 'ember/order-in-models': [ - 'error', - { - order: ['attribute', 'relationship', 'single-line-function', 'multi-line-function'], - }, - ], - /* Recommended rules */ - 'ember/no-mixins': 'off', - 'no-irregular-whitespace': 'off', - }, - overrides: [ - // node files - { - files: ['**/*.gjs'], - parser: 'ember-eslint-parser', - plugins: ['ember', 'qunit'], - extends: [ - '@1024pix', - 'plugin:ember/recommended', - 'plugin:ember/recommended-gjs', - 'plugin:qunit/recommended', - 'plugin:prettier/recommended', - ], - }, - { - files: [ - '.eslintrc.cjs', - '.template-lintrc.js', - 'ember-cli-build.js', - 'testem.js', - 'blueprints/*/index.js', - 'config/**/*.js', - 'lib/*/index.js', - 'server/**/*.js', - ], - parserOptions: { - sourceType: 'script', - }, - env: { - browser: false, - node: true, - }, - extends: ['plugin:n/recommended'], - }, - // test files - { - files: ['tests/**/*.js'], - excludedFiles: ['tests/dummy/**/*.js'], - env: { - embertest: true, - }, - globals: { - server: false, - }, - }, - ], - settings: { - 'i18n-json/ignore-keys': ['pages.dashboard.presentation.link.text', 'pages.dashboard.presentation.link.url'], - }, -}; diff --git a/mon-pix/eslint.config.cjs b/mon-pix/eslint.config.cjs new file mode 100644 index 00000000000..f6f5020525d --- /dev/null +++ b/mon-pix/eslint.config.cjs @@ -0,0 +1,144 @@ +const emberRecommendedConfig = require('eslint-plugin-ember/configs/recommended'); +const emberGjsRecommendedConfig = require('eslint-plugin-ember/configs/recommended-gjs'); +const qunitRecommendedConfig = require('eslint-plugin-qunit/configs/recommended'); +const prettierRecommendedConfig = require('eslint-plugin-prettier/recommended'); +const nRecommendedConfig = require('eslint-plugin-n').configs['flat/recommended']; +const pixRecommendedConfig = require('@1024pix/eslint-plugin/config'); +const globals = require('globals'); +const babelParser = require('@babel/eslint-parser'); +const emberParser = require('ember-eslint-parser'); + +const unconventionalJsFiles = ['blueprints/**/files/*', 'app/vendor/*']; +const compiledOutputFiles = ['dist/*', 'tmp/*']; +const dependenciesFiles = ['bower_components/*', 'node_modules/*']; +const miscFiles = ['coverage/*', '!**/.*', '**/.eslintcache']; +const emberTryFiles = ['.node_modules.ember-try/*', 'bower.json.ember-try', 'package.json.ember-try']; +const phraseGeneratedFiles = ['translations/*.json', '!translations/en.json', '!translations/fr.json']; + +const nodeFiles = [ + 'eslint.config.cjs', + '.template-lintrc.js', + 'ember-cli-build.js', + 'testem.js', + 'blueprints/*/index.js', + 'config/**/*.js', + 'lib/*/index.js', + 'server/**/*.js', +]; + +const emberPatchedParser = Object.assign( + { + meta: { + name: 'ember-eslint-parser', + version: '*', + }, + }, + emberParser, +); + +module.exports = [ + ...pixRecommendedConfig, + ...emberRecommendedConfig, + ...emberGjsRecommendedConfig, + qunitRecommendedConfig, + prettierRecommendedConfig, + { + ignores: [ + ...unconventionalJsFiles, + ...compiledOutputFiles, + ...dependenciesFiles, + ...miscFiles, + ...emberTryFiles, + ...phraseGeneratedFiles, + ], + }, + { + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: babelParser, + ecmaVersion: 2018, + sourceType: 'module', + + parserOptions: { + requireConfigFile: false, + + babelOptions: { + plugins: [ + [ + '@babel/plugin-proposal-decorators', + { + decoratorsBeforeExport: true, + }, + ], + ], + }, + }, + }, + + rules: { + 'no-console': 'error', + 'no-duplicate-imports': 'error', + + 'no-restricted-imports': [ + 'error', + 'lodash', + { + name: '@ember/test-helpers', + importNames: ['render', 'visit', 'find'], + message: + "Please import 'render' from '@1024pix/ember-testing-library'.\n Please import 'visit' from '@1024pix/ember-testing-library'.\n. 'find' should be replaced with '@1024pix/ember-testing-library' 'find...'/'get...'/'query...' methods to enforce accessible usages.", + }, + ], + + 'ember/avoid-leaking-state-in-ember-objects': 'off', + 'ember/no-get': ['error'], + 'ember/no-empty-attrs': 'error', + 'ember/no-new-mixins': 'off', + 'ember/no-restricted-resolver-tests': 'off', + 'ember/use-ember-data-rfc-395-imports': 'error', + + 'ember/order-in-models': [ + 'error', + { + order: ['attribute', 'relationship', 'single-line-function', 'multi-line-function'], + }, + ], + + 'ember/no-mixins': 'off', + 'no-irregular-whitespace': 'off', + }, + }, + { + files: ['**/*.gjs'], + languageOptions: { + parser: emberPatchedParser, + sourceType: 'module', + }, + }, + { + ...nRecommendedConfig, + files: nodeFiles, + + languageOptions: { + globals: { + ...globals.node, + }, + + ecmaVersion: 5, + sourceType: 'script', + }, + }, + { + files: ['tests/**/*.js', 'tests/**/*.gjs'], + + languageOptions: { + globals: { + ...globals.embertest, + server: false, + }, + }, + }, +]; diff --git a/mon-pix/package-lock.json b/mon-pix/package-lock.json index edeb7d8b787..7509e4635ce 100644 --- a/mon-pix/package-lock.json +++ b/mon-pix/package-lock.json @@ -13,7 +13,7 @@ "@1024pix/ember-api-actions": "^1.1.0", "@1024pix/ember-matomo-tag-manager": "^2.4.3", "@1024pix/ember-testing-library": "^3.0.6", - "@1024pix/eslint-config": "^1.3.7", + "@1024pix/eslint-plugin": "^1.3.1", "@1024pix/pix-ui": "^46.12.21", "@1024pix/stylelint-config": "^5.1.16", "@babel/eslint-parser": "^7.19.1", @@ -82,6 +82,7 @@ "eslint-plugin-n": "^17.0.0", "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-qunit": "^8.0.0", + "globals": "^15.9.0", "js-yaml": "^3.14.1", "jwt-decode": "^4.0.0", "loader.js": "^4.7.0", @@ -823,22 +824,6 @@ "node": "^20 || ^22" } }, - "node_modules/@1024pix/eslint-config": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/@1024pix/eslint-config/-/eslint-config-1.3.7.tgz", - "integrity": "sha512-7DLc3kaHhKbQ3KMspu92TJRczugYhEvNAYWT+haV7K7gBpwE8oNKVrSQVJn2bKcaQanxFjT139z2BBOzyiVpPw==", - "dev": true, - "dependencies": { - "@1024pix/eslint-plugin": "^1.1.2", - "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0", - "eslint-plugin-i18n-json": "^4.0.0", - "eslint-plugin-simple-import-sort": "^12.0.0", - "eslint-plugin-yml": "^1.8.0" - }, - "peerDependencies": { - "eslint": ">=8.57.0" - } - }, "node_modules/@1024pix/eslint-plugin": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@1024pix/eslint-plugin/-/eslint-plugin-1.3.1.tgz", @@ -2666,6 +2651,16 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-classes/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.7.tgz", @@ -3595,6 +3590,16 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.25.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.0.tgz", @@ -8371,16 +8376,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/@formatjs/ecma402-abstract": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-2.0.0.tgz", @@ -33955,19 +33950,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/eslint-plugin-n/node_modules/globals": { - "version": "15.8.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.8.0.tgz", - "integrity": "sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint-plugin-n/node_modules/minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", @@ -34128,6 +34110,16 @@ "node": ">=10" } }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -35904,13 +35896,16 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", "dev": true, "license": "MIT", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globalthis": { diff --git a/mon-pix/package.json b/mon-pix/package.json index 3dfcb696f2e..586752997b0 100644 --- a/mon-pix/package.json +++ b/mon-pix/package.json @@ -31,8 +31,6 @@ "lint:js:uncached": "eslint .", "lint:scss": "stylelint 'app/**/*.scss'", "lint:scss:fix": "npm run lint:scss -- --fix", - "lint:translations": "eslint --ext .json --format node_modules/eslint-plugin-i18n-json/formatter.js translations", - "lint:translations:fix": "npm run lint:translations -- --fix", "build": "ember build --environment $BUILD_ENVIRONMENT", "preinstall": "npx check-engine", "dev": "ember serve --proxy http://localhost:3000", @@ -46,7 +44,7 @@ "@1024pix/ember-api-actions": "^1.1.0", "@1024pix/ember-matomo-tag-manager": "^2.4.3", "@1024pix/ember-testing-library": "^3.0.6", - "@1024pix/eslint-config": "^1.3.7", + "@1024pix/eslint-plugin": "^1.3.1", "@1024pix/pix-ui": "^46.12.21", "@1024pix/stylelint-config": "^5.1.16", "@babel/eslint-parser": "^7.19.1", @@ -115,6 +113,7 @@ "eslint-plugin-n": "^17.0.0", "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-qunit": "^8.0.0", + "globals": "^15.9.0", "js-yaml": "^3.14.1", "jwt-decode": "^4.0.0", "loader.js": "^4.7.0",