diff --git a/.eslintignore b/.eslintignore index 775881bd7..317684639 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,6 +11,7 @@ coverage **/*.d.ts /config.js .clinic/ +.cache/ # generated code **/*.generated.ts diff --git a/.eslintrc.js b/.eslintrc.js index 190ad0dec..f00e8962d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,10 +28,11 @@ module.exports = { * checks done by typescript. * * https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import + * required for esm check */ - 'import/default': 0, - 'import/named': 0, - 'import/namespace': 0, + 'import/default': 2, + 'import/named': 2, + 'import/namespace': 2, 'import/no-named-as-default-member': 0, 'import/prefer-default-export': 0, // no benefit @@ -120,6 +121,10 @@ module.exports = { }, }, overrides: [ + { + // files to check, so no `--ext` is required + files: ['**/*.{js,mjs,cjs,ts}'], + }, { files: ['**/*.spec.ts', 'test/**'], env: { @@ -143,7 +148,7 @@ module.exports = { }, }, { - files: ['**/*.{js,mjs}'], + files: ['**/*.{js,mjs,cjs}'], rules: { '@typescript-eslint/explicit-function-return-type': 0, @@ -152,7 +157,7 @@ module.exports = { }, }, { - files: ['tools/**/*.{ts,js,mjs}'], + files: ['tools/**/*.{ts,js,mjs,cjs}'], env: { node: true, }, @@ -164,7 +169,7 @@ module.exports = { }, }, { - files: ['tools/**/*.js'], + files: ['tools/**/*.{js,cjs}', 'bin/*.{js,cjs}'], rules: { // need commonjs '@typescript-eslint/no-var-requires': 'off', diff --git a/bin/clean-cache.js b/bin/clean-cache.js deleted file mode 100644 index d30379390..000000000 --- a/bin/clean-cache.js +++ /dev/null @@ -1,10 +0,0 @@ -const fs = require('fs-extra'); -const os = require('os'); -const path = require('path'); - -(async () => { - const tmpDir = process.env.RENOVATE_TMPDIR || os.tmpdir(); - const renovateDir = path.join(tmpDir, 'renovate'); - console.log('Removing ' + renovateDir); - await fs.remove(renovateDir); -})(); diff --git a/bin/clean-cache.mjs b/bin/clean-cache.mjs new file mode 100644 index 000000000..38a65f547 --- /dev/null +++ b/bin/clean-cache.mjs @@ -0,0 +1,12 @@ +import { tmpdir } from 'os'; +import { join } from 'path'; +import { remove } from 'fs-extra'; + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +(async () => { + const tmpDir = process.env.RENOVATE_TMPDIR || tmpdir(); + const renovateDir = join(tmpDir, 'renovate'); + // eslint-disable-next-line no-console + console.log('Removing ' + renovateDir); + await remove(renovateDir); +})(); diff --git a/bin/create-json-schema.js b/bin/create-json-schema.js index 973b89c6f..d30f6adb9 100644 --- a/bin/create-json-schema.js +++ b/bin/create-json-schema.js @@ -10,8 +10,12 @@ const schema = { }; const options = getOptions(); options.sort((a, b) => { - if (a.name < b.name) return -1; - if (a.name > b.name) return 1; + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); const properties = {}; @@ -34,7 +38,7 @@ function createSingleConfig(option) { temp.items.enum = option.allowedValues; } } - if (option.subType == 'string' && option.allowString === true) { + if (option.subType === 'string' && option.allowString === true) { const items = temp.items; delete temp.items; delete temp.type; diff --git a/package.json b/package.json index f1942b03a..d6803d3dc 100644 --- a/package.json +++ b/package.json @@ -10,15 +10,15 @@ "build": "run-s clean generate:* compile:*", "build:docs": "run-s \"release:prepare {@}\"", "clean": "rimraf dist tmp", - "clean-cache": "node bin/clean-cache.js", + "clean-cache": "node bin/clean-cache.mjs", "compile:ts": "tsc -p tsconfig.app.json", "config-validator": "node -r ts-node/register/transpile-only -- lib/config-validator.ts", "create-json-schema": "node -r ts-node/register/transpile-only -- bin/create-json-schema.js && prettier --write \"renovate-schema.json\"", "debug": "node --inspect-brk -r ts-node/register/transpile-only -- lib/renovate.ts", "doc-fix": "run-s markdown-lint-fix prettier-fix", "doc-fence-check": "node tools/check-fenced-code.mjs", - "eslint": "eslint --ext .js,.mjs,.ts lib/ test/ tools/ --report-unused-disable-directives", - "eslint-fix": "eslint --ext .js,.mjs,.ts --fix lib/ test/ tools/ --report-unused-disable-directives", + "eslint": "eslint . --report-unused-disable-directives", + "eslint-fix": "eslint --fix . --report-unused-disable-directives", "generate": "run-s generate:*", "generate:imports": "node tools/generate-imports.mjs", "git-check": "node tools/check-git-version.mjs", diff --git a/tsconfig.json b/tsconfig.json index 0d58542ac..636b8bb24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,6 @@ "./.cache", "./dist", "**/__mocks__/*", - "bin", "coverage", "config.js", "tmp" diff --git a/tsconfig.lint.json b/tsconfig.lint.json index 8565ac3fd..5be74aead 100644 --- a/tsconfig.lint.json +++ b/tsconfig.lint.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig", - "include": [".eslintrc.js", "**/*.ts", "**/*.js", "**/*.mjs"] + "include": [".eslintrc.js", "**/*.ts", "**/*.js", "**/*.mjs", "**/*.cjs"] }