Skip to content

Commit 974e804

Browse files
shazronclaude
andauthored
chore: update @oclif/core to v4 and eslint to v9 with neostandard (#905) (#908)
Update @oclif/core from v2.11.6 to v4.9.0 and modernize the ESLint setup by migrating to @adobe/eslint-config-aio-lib-config v5 with neostandard and ESLint 9 flat config. oclif v4's parse() now calls config.runHook('preparse') before parsing, so all tests that instantiate commands directly need a mock config with runHook returning { successes: [] }. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e1c266c commit 974e804

42 files changed

Lines changed: 172 additions & 116 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

eslint.config.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const config = require('@adobe/eslint-config-aio-lib-config')
2+
3+
module.exports = [
4+
...config,
5+
{
6+
languageOptions: {
7+
globals: {
8+
NoErrorThrownError: true,
9+
getErrorForCallThatShouldThrowAnError: true,
10+
fixturePath: true,
11+
fixtureFile: true,
12+
fixtureJson: true,
13+
fixtureHjson: true,
14+
fixtureYaml: true,
15+
fakeFileSystem: true,
16+
setFetchMock: true,
17+
createOclifMockConfig: true,
18+
loadFixtureApp: true,
19+
defaultAppHostName: true,
20+
defaultTvmUrl: true,
21+
defaultOwApihost: true,
22+
fakeS3Bucket: true,
23+
fakeOrgId: true,
24+
fakeConfig: true,
25+
aioLegacyAppConfig: true,
26+
fakeS3Creds: true,
27+
extraConfig: true,
28+
fakeTVMResponse: true
29+
}
30+
},
31+
settings: {
32+
jsdoc: {
33+
ignorePrivate: true
34+
}
35+
},
36+
rules: {
37+
'jsdoc/no-defaults': 0,
38+
'jsdoc/tag-lines': [
39+
'error',
40+
'never',
41+
{
42+
startLines: null
43+
}
44+
]
45+
}
46+
},
47+
{
48+
files: ['test/**/*.js'],
49+
languageOptions: {
50+
globals: {
51+
jest: true,
52+
describe: true,
53+
test: true,
54+
it: true,
55+
expect: true,
56+
beforeEach: true,
57+
afterEach: true,
58+
beforeAll: true,
59+
afterAll: true
60+
}
61+
}
62+
}
63+
]

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@adobe/generator-aio-app": "^9",
2020
"@adobe/generator-app-common-lib": "^3",
2121
"@adobe/inquirer-table-checkbox": "^2",
22-
"@oclif/core": "^2.11.6",
22+
"@oclif/core": "^4.9.0",
2323
"@octokit/rest": "^19.0.11",
2424
"@parcel/core": "^2.7.0",
2525
"@parcel/reporter-cli": "^2.7.0",
@@ -51,19 +51,14 @@
5151
},
5252
"devDependencies": {
5353
"@adobe/aio-lib-test-proxy": "^2",
54-
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
54+
"@adobe/eslint-config-aio-lib-config": "^5.0.0",
5555
"@types/jest": "^29",
5656
"babel-runtime": "^6.26.0",
5757
"core-js": "^3",
5858
"eol": "^0.9.1",
59-
"eslint": "^8.57.1",
60-
"eslint-config-standard": "^17.1.0",
61-
"eslint-plugin-import": "^2.31.0",
62-
"eslint-plugin-jest": "^27.9.0",
59+
"eslint": "^9",
6360
"eslint-plugin-jsdoc": "^48.11.0",
64-
"eslint-plugin-n": "^15.7.0",
65-
"eslint-plugin-node": "^11.1.0",
66-
"eslint-plugin-promise": "^6.6.0",
61+
"neostandard": "^0",
6762
"jest": "^29.5.0",
6863
"nock": "^13.2.9",
6964
"oclif": "^4.17.13",

src/commands/app/install.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const jsYaml = require('js-yaml')
2222
const { USER_CONFIG_FILE, DEPLOY_CONFIG_FILE, PACKAGE_LOCK_FILE } = require('../../lib/defaults')
2323
const ora = require('ora')
2424

25-
// eslint-disable-next-line node/no-missing-require
2625
const libConfig = require('@adobe/aio-cli-lib-app-config')
2726

2827
class InstallCommand extends BaseCommand {

src/commands/app/pack.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const { getObjectValue } = require('../../lib/app-helper')
2222
const ora = require('ora')
2323
const junk = require('junk')
2424

25-
// eslint-disable-next-line node/no-missing-require
2625
const libConfig = require('@adobe/aio-cli-lib-app-config')
2726

2827
const DIST_FOLDER = 'dist'

src/lib/cleanup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class Cleanup {
4040
try {
4141
await this.run()
4242
aioLogger.info('exiting!')
43-
process.exit(0) // eslint-disable-line no-process-exit
43+
process.exit(0)
4444
} catch (e) {
4545
aioLogger.error('unexpected error while cleaning up!')
4646
aioLogger.error(e)
47-
process.exit(1) // eslint-disable-line no-process-exit
47+
process.exit(1)
4848
}
4949
})
5050
}

src/lib/install-helper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const ajvAddFormats = require('ajv-formats')
2020
* @returns {object} with keys valid (boolean) and errors (object). errors is null if no errors
2121
*/
2222
function validateJsonWithSchema (fileJson, schemaName) {
23-
/* eslint-disable-next-line node/no-unpublished-require */
2423
const schemas = require('../../schema/index')
2524
const ajv = new Ajv({
2625
allErrors: true,

src/lib/run-dev.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
99
OF ANY KIND, either express or implied. See the License for the specific language
1010
governing permissions and limitations under the License.
1111
*/
12-
/* eslint-disable no-template-curly-in-string */
1312
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:runDev', { provider: 'debug' })
1413
const rtLib = require('@adobe/aio-lib-runtime')
1514
const rtLibUtils = rtLib.utils

test/BaseCommand.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,23 @@ describe('getLibConsoleCLI', () => {
282282

283283
test('init', async () => {
284284
const cmd = new TheCommand([])
285-
cmd.config = {}
285+
cmd.config = global.createOclifMockConfig()
286286
await cmd.init()
287287
expect(cmd.prompt).toBe(mockExtensionPrompt)
288288
expect(inquirer.createPromptModule).toHaveBeenCalledWith({ output: process.stderr })
289289
})
290290

291291
test('catch', async () => {
292292
const cmd = new TheCommand([])
293+
cmd.config = global.createOclifMockConfig()
293294
cmd.error = jest.fn()
294295
await cmd.catch(new Error('fake error'))
295296
expect(cmd.error).toHaveBeenCalledWith('fake error')
296297
})
297298

298299
test('will change error message when aio app outside of the application root', async () => {
299300
const cmd = new TheCommand([])
301+
cmd.config = global.createOclifMockConfig()
300302
cmd.error = jest.fn()
301303
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))
302304

@@ -308,6 +310,7 @@ test('will change error message when aio app outside of the application root', a
308310

309311
test('will change error message when aio app outside of the application root (--verbose)', async () => {
310312
const cmd = new TheCommand(['--verbose'])
313+
cmd.config = global.createOclifMockConfig()
311314
cmd.error = jest.fn()
312315
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))
313316

@@ -319,6 +322,7 @@ test('will change error message when aio app outside of the application root (--
319322

320323
test('will handle errors without stack traces when using --verbose flag', async () => {
321324
const cmd = new TheCommand(['--verbose'])
325+
cmd.config = global.createOclifMockConfig()
322326
cmd.error = jest.fn()
323327
const errorWithoutStack = new Error('fake error')
324328
delete errorWithoutStack.stack
@@ -329,6 +333,7 @@ test('will handle errors without stack traces when using --verbose flag', async
329333

330334
test('will handle errors without stack traces when not using --verbose flag', async () => {
331335
const cmd = new TheCommand([])
336+
cmd.config = global.createOclifMockConfig()
332337
cmd.error = jest.fn()
333338
const errorWithoutStack = new Error('fake error')
334339
delete errorWithoutStack.stack

test/TemplatesCommand.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ beforeEach(() => {
9797
command = new TheCommand()
9898
command.config = {
9999
runCommand: jest.fn(),
100-
runHook: jest.fn()
100+
runHook: jest.fn().mockResolvedValue({ successes: [] })
101101
}
102102

103103
inquirer.registerPrompt.mockReset()

0 commit comments

Comments
 (0)