Skip to content
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

[TECH] Mise à jour de ESLint vers la V9 (PIX-15823) #10870

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions junior/.eslintignore

This file was deleted.

60 changes: 0 additions & 60 deletions junior/.eslintrc.cjs

This file was deleted.

2 changes: 2 additions & 0 deletions junior/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

# ember-try
/.node_modules.ember-try/

/translations
2 changes: 1 addition & 1 deletion junior/.template-lintrc.js → junior/.template-lintrc.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
export default {
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
plugins: ['ember-template-lint-plugin-prettier'],
ignore: ['blueprints/**'],
Expand Down
1 change: 1 addition & 0 deletions junior/app/components/challenge/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default class Challenge extends Component {
await this.answer.save({ adapterOptions: { assessmentId: this.#assessmentId, isPreview: this.#isPreview } });
this.answerHasBeenValidated = true;
this.scrollToTop();
// eslint-disable-next-line no-unused-vars
} catch (error) {
this.answer.rollbackAttributes();
}
Expand Down
14 changes: 7 additions & 7 deletions junior/ember-cli-build.js → junior/ember-cli-build.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
import pkg from '@embroider/compat';
import { Webpack } from '@embroider/webpack';
import EmberApp from 'ember-cli/lib/broccoli/ember-app.js';

const { compatBuild } = pkg;
const sourceMapConfig = {
production: 'source-map',
test: false,
default: 'eval-source-map',
};

module.exports = function (defaults) {
export default function (defaults) {
const app = new EmberApp(defaults, {
sassOptions: {
includePaths: ['node_modules/@1024pix/pix-ui/addon/styles'],
Expand Down Expand Up @@ -42,12 +43,11 @@ module.exports = function (defaults) {
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

const { Webpack } = require('@embroider/webpack');
return require('@embroider/compat').compatBuild(app, Webpack, {
return compatBuild(app, Webpack, {
packagerOptions: {
webpackConfig: {
devtool: sourceMapConfig[process.env.CI ? 'test' : (process.env.NODE_ENV ?? 'default')],
},
},
});
};
}
120 changes: 120 additions & 0 deletions junior/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import pixRecommendedConfig from '@1024pix/eslint-plugin/config';
import babelParser from '@babel/eslint-parser';
import emberParser from 'ember-eslint-parser';
import emberRecommendedConfig from 'eslint-plugin-ember/configs/recommended';
import emberGjsRecommendedConfig from 'eslint-plugin-ember/configs/recommended-gjs';
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
import nRecommendedConfig from 'eslint-plugin-n';
import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
import qunitRecommendedConfig from 'eslint-plugin-qunit/configs/recommended';
import globals from 'globals';

const unconventionalJsFiles = ['blueprints/**/files/*', 'app/vendor/*'];
const compiledOutputFiles = ['dist/*', 'tmp/*'];
const dependenciesFiles = ['node_modules/*'];
const miscFiles = ['coverage/*', '!**/.*', '**/.eslintcache'];
const emberTryFiles = ['.node_modules.ember-try/*', 'bower.json.ember-try', 'package.json.ember-try'];
const nonPhraseGeneratedFiles = ['translations/en.json', 'translations/fr.json'];

const nodeFiles = [
'eslint.config.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,
);

export default [
...pixRecommendedConfig,
...emberRecommendedConfig,
...emberGjsRecommendedConfig,
qunitRecommendedConfig,
prettierRecommendedConfig,
{
ignores: [...unconventionalJsFiles, ...compiledOutputFiles, ...dependenciesFiles, ...miscFiles, ...emberTryFiles],
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parser: babelParser,
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
requireConfigFile: false,
babelOptions: {
configFile: false,
babelrc: false,
plugins: [['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }]],
},
},
},
rules: {
'no-irregular-whitespace': 'off',
'no-restricted-imports': ['error', { paths: ['lodash'] }],
},
},
{
files: ['**/*.gjs'],
languageOptions: {
parser: emberPatchedParser,
sourceType: 'module',
},
},
{
...nRecommendedConfig.configs['flat/recommended'],
files: nodeFiles,

languageOptions: {
globals: {
...globals.node,
},

ecmaVersion: 5,
sourceType: 'script',
},
rules: {
'n/no-extraneous-import': [
'error',
{
allowModules: ['eslint-plugin-i18n-json'],
},
],
},
},
{
files: ['tests/**/*.js', 'tests/**/*.gjs'],

languageOptions: {
globals: {
...globals.embertest,
server: false,
},
},
},
{
files: nonPhraseGeneratedFiles,
plugins: { 'i18n-json': i18nJsonPlugin },
processor: {
meta: { name: '.json' },
...i18nJsonPlugin.processors['.json'],
},
rules: {
...i18nJsonPlugin.configs.recommended.rules,
},
},
];
Loading
Loading