Skip to content

Commit

Permalink
Merge pull request #1981 from mshima/eslintv9
Browse files Browse the repository at this point in the history
update to eslint v9
  • Loading branch information
DanielFran authored Nov 15, 2024
2 parents ac9479f + de71062 commit d3c97ae
Show file tree
Hide file tree
Showing 36 changed files with 221 additions and 118 deletions.
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ updates:
open-pull-requests-limit: 30
versioning-strategy: increase
groups:
typescript-eslint:
patterns:
- '@typescript-eslint/*'
redux:
patterns:
- '@reduxjs/*'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,5 @@ Desktop.ini
/coverage/
/.nyc_output/

# added by generate-blueprint:
generators/**/package-lock.json
12 changes: 6 additions & 6 deletions generators/app/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ exports[`SubGenerator app of reactNative JHipster blueprint > run > should succe
"../client/.editorconfig": {
"stateCleared": "modified",
},
"../client/.eslintrc.js": {
"stateCleared": "modified",
},
"../client/.gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -377,6 +374,9 @@ exports[`SubGenerator app of reactNative JHipster blueprint > run > should succe
"../client/e2e/utils.js": {
"stateCleared": "modified",
},
"../client/eslint.config.mjs": {
"stateCleared": "modified",
},
"../client/metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -505,9 +505,6 @@ exports[`SubGenerator app of reactNative JHipster blueprint > with custom reactN
"../reactNative-app/.editorconfig": {
"stateCleared": "modified",
},
"../reactNative-app/.eslintrc.js": {
"stateCleared": "modified",
},
"../reactNative-app/.gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -874,6 +871,9 @@ exports[`SubGenerator app of reactNative JHipster blueprint > with custom reactN
"../reactNative-app/e2e/utils.js": {
"stateCleared": "modified",
},
"../reactNative-app/eslint.config.mjs": {
"stateCleared": "modified",
},
"../reactNative-app/metro.config.js": {
"stateCleared": "modified",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -413,6 +410,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
"e2e/utils.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -511,9 +511,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -889,6 +886,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
"babel.config.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -990,9 +990,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1398,6 +1395,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > Entity Tes
"e2e/utils.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down
36 changes: 18 additions & 18 deletions generators/react-native/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -350,6 +347,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"babel.config.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -445,9 +445,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -814,6 +811,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"e2e/utils.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -906,9 +906,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1266,6 +1263,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"babel.config.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1370,9 +1370,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1757,6 +1754,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"e2e/websockets/chat-screen.spec.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1858,9 +1858,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -2191,6 +2188,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"babel.config.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -2277,9 +2277,6 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
".editorconfig": {
"stateCleared": "modified",
},
".eslintrc.js": {
"stateCleared": "modified",
},
".gitattributes": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -2628,6 +2625,9 @@ exports[`SubGenerator reactNative of reactNative JHipster blueprint > WebSocket
"e2e/websockets/chat-screen.spec.js": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"stateCleared": "modified",
},
"metro.config.js": {
"stateCleared": "modified",
},
Expand Down
7 changes: 6 additions & 1 deletion generators/react-native/files.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const eslintConfigTemplate = sourceFile => ({
sourceFile,
destinationFile: ctx => sourceFile.replace('eslint.config.js', ctx.eslintConfigFile),
});

const files = {
common: [
{
templates: [
'.prettierignore.jhi.react-native',
'.eslintrc.js',
'.gitattributes.jhi.react-native',
'.gitignore.jhi.react-native',
eslintConfigTemplate('eslint.config.js.jhi.react-native'),
'App.js',
'app.json',
'README.md',
Expand Down
42 changes: 36 additions & 6 deletions generators/react-native/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { relative } from 'node:path';
import { readFile } from 'node:fs/promises';
import chalk from 'chalk';
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
import { generateTestEntity } from 'generator-jhipster/generators/client/support';
Expand All @@ -20,6 +21,11 @@ import {
} from './support/index.js';

export default class extends BaseApplicationGenerator {
/** @type {string | undefined} */
oldReactNativeBlueprintVersion;
/** @type { any } */
reactNativeBlueprintPackageJson;

constructor(args, opts, features) {
super(args, opts, { ...features, queueCommandTasks: true, sbsBlueprint: true, jhipster7Migration: true });

Expand Down Expand Up @@ -81,6 +87,17 @@ export default class extends BaseApplicationGenerator {
await this.dependsOnJHipster('init');
}

get [BaseApplicationGenerator.INITIALIZING]() {
return this.asInitializingTaskGroup({
async initializing({ control }) {
this.oldReactNativeBlueprintVersion =
(this.blueprintConfig.reactNativeBlueprintVersion ?? control.existingProject) ? '5.1.0' : undefined;
this.reactNativeBlueprintPackageJson = JSON.parse((await readFile(this.templatePath('../../../package.json'), 'utf-8')).toString());
this.blueprintConfig.reactNativeBlueprintVersion = this.reactNativeBlueprintPackageJson.version;
},
});
}

get [BaseApplicationGenerator.CONFIGURING]() {
return this.asConfiguringTaskGroup({
loadConfigFromBackend() {
Expand Down Expand Up @@ -140,6 +157,13 @@ export default class extends BaseApplicationGenerator {
},
});
}
get [BaseApplicationGenerator.LOADING]() {
return this.asLoadingTaskGroup({
loading({ application }) {
application.typescriptEslint = true;
},
});
}

get [BaseApplicationGenerator.PREPARING]() {
return this.asPreparingTaskGroup({
Expand All @@ -159,6 +183,18 @@ export default class extends BaseApplicationGenerator {

get [BaseApplicationGenerator.WRITING]() {
return this.asWritingTaskGroup({
async cleanup({ control }) {
if (control.existingProject) {
if (this.isVersionLessThan(this.oldReactNativeBlueprintVersion, '5.1.1')) {
this.removeFile('.eslintrc.js');
}
}
/*
control.cleanupFiles(this.oldReactNativeBlueprintVersion, {
'5.1.1': ['.eslintrc.js'],
})
*/
},
async writingTemplateTask({ application }) {
await this.writeFiles({
sections: files,
Expand Down Expand Up @@ -225,12 +261,6 @@ export default class extends BaseApplicationGenerator {

get [BaseApplicationGenerator.POST_WRITING]() {
return this.asPostWritingTaskGroup({
ignoreEslint9ConfigFile({ application }) {
const eslintConfigFile = this.env.sharedFs.get(this.destinationPath(application.eslintConfigFile));
if (eslintConfigFile) {
delete eslintConfigFile.state;
}
},
async patchUriScheme({ application }) {
this.editFile('app.json', content => {
const appConfig = JSON.parse(content);
Expand Down
6 changes: 3 additions & 3 deletions generators/react-native/support/patch-entity-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function patchEntityApi(application, entity) {
${updateMethod}
const delete${entity.entityNameCapitalized} = (${entity.entityInstance}Id) => api.delete('${microservicePath}api/${entity.entityApiUrl}/' + ${entity.entityInstance}Id);`;

let fixtureApiMethods = ` update${entity.entityNameCapitalized}: (${entity.entityInstance}) => {
let fixtureApiMethods = ` update${entity.entityNameCapitalized}: (_${entity.entityInstance}) => {
return {
ok: true,
data: require('../../shared/fixtures/update-${entity.entityFileName}.json'),
Expand All @@ -30,13 +30,13 @@ function patchEntityApi(application, entity) {
data: require('../../shared/fixtures/get-all-${entity.entityNamePluralizedAndSpinalCased}.json'),
};
},
get${entity.entityNameCapitalized}: (${entity.entityInstance}Id) => {
get${entity.entityNameCapitalized}: (_${entity.entityInstance}Id) => {
return {
ok: true,
data: require('../../shared/fixtures/get-${entity.entityFileName}.json'),
};
},
delete${entity.entityNameCapitalized}: (${entity.entityInstance}Id) => {
delete${entity.entityNameCapitalized}: (_${entity.entityInstance}Id) => {
return {
ok: true,
};
Expand Down
29 changes: 0 additions & 29 deletions generators/react-native/templates/.eslintrc.js.ejs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const chatSuccess = (state, { chat }) => {
return state.merge({ chat })
}

export const reset = state => {
export const reset = _state => {
return INITIAL_STATE
}

Expand Down
Loading

0 comments on commit d3c97ae

Please sign in to comment.