Skip to content

Commit

Permalink
chore(deps): update dependency @netlify/eslint-config-node to v6 (#4501)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency @netlify/eslint-config-node to v6

* chore: fix eslintrc

* chore: fix linting

* chore: update shrinkwrap file

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: ehmicky <[email protected]>
Co-authored-by: erezrokah <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Apr 11, 2022
1 parent 15f34db commit 1cb5a91
Show file tree
Hide file tree
Showing 22 changed files with 752 additions and 1,067 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
'no-process-exit': 0,
'fp/no-loops': 'error',
'import/max-dependencies': 0,
'node/no-sync': 0,
'n/no-process-exit': 0,
'n/no-sync': 0,
'sort-destructure-keys/sort-destructure-keys': 2,
'unicorn/consistent-destructuring': 0,
// TODO: harmonize with filename snake_case in other Netlify Dev projects
Expand Down Expand Up @@ -47,8 +48,8 @@ module.exports = {
rules: {
'require-await': 0,
'import/no-unresolved': 0,
'node/no-missing-require': 0,
'node/no-unsupported-features/es-syntax': 0,
'n/no-missing-require': 0,
'n/no-unsupported-features/es-syntax': 0,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { createMainCommand } = require('../src/commands')
const UPDATE_CHECK_INTERVAL = 432e5

if (require.main === module) {
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const pkg = require('../package.json')

try {
Expand Down
1,752 changes: 718 additions & 1,034 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
},
"devDependencies": {
"@babel/preset-react": "^7.12.13",
"@netlify/eslint-config-node": "^5.1.8",
"@netlify/eslint-config-node": "^6.0.0",
"ava": "^4.0.0",
"c8": "^7.11.0",
"eslint-plugin-sort-destructure-keys": "^1.3.5",
Expand Down
6 changes: 3 additions & 3 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const format = (message, styles) => {
let func = id
try {
// this fails sometimes on outdated npm versions
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
func = require('chalk')
styles.forEach((style) => {
func = func[style]
Expand All @@ -26,9 +26,9 @@ const postInstall = () => {
// as yarn pnp analyzes everything inside the postinstall
// yarn pnp executes it out of a .yarn folder .yarn/unplugged/netlify-cli-file-fb026a3a6d/node_modules/netlify-cli/scripts/postinstall.js
if (!process.argv[1].includes('.yarn')) {
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { createMainCommand } = require('../src/commands')
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { createAutocompletion } = require('../src/lib/completion')

// create or update the autocompletion definition
Expand Down
2 changes: 1 addition & 1 deletion site/src/_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default class Layout extends React.Component {

state = {
menu: false,
// eslint-disable-next-line no-invalid-this

update: (fn) => this.setState(fn),
}

Expand Down
8 changes: 4 additions & 4 deletions src/commands/functions/functions-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const formatRegistryArrayForInquirer = function (lang) {
const registry = folderNames
// filter out markdown files
.filter((folderName) => !folderName.endsWith('.md'))
// eslint-disable-next-line node/global-require, import/no-dynamic-require
// eslint-disable-next-line n/global-require, import/no-dynamic-require
.map((folderName) => require(path.join(templatesDir, lang, folderName, '.netlify-function-template.js')))
.sort((folderNameA, folderNameB) => {
const priorityDiff = (folderNameA.priority || DEFAULT_PRIORITY) - (folderNameB.priority || DEFAULT_PRIORITY)
Expand Down Expand Up @@ -298,7 +298,7 @@ const downloadFromURL = async function (command, options, argumentName, function
// read, execute, and delete function template file if exists
const fnTemplateFile = path.join(fnFolder, '.netlify-function-template.js')
if (fs.existsSync(fnTemplateFile)) {
// eslint-disable-next-line node/global-require, import/no-dynamic-require
// eslint-disable-next-line n/global-require, import/no-dynamic-require
const { onComplete, addons = [] } = require(fnTemplateFile)

await installAddons(command, addons, path.resolve(fnFolder))
Expand All @@ -323,7 +323,7 @@ const getNpmInstallPackages = (existingPackages = {}, neededPackages = {}) =>
// we don't do this check, we may be upgrading the version of a module used in
// another part of the project, which we don't want to do.
const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) => {
// eslint-disable-next-line import/no-dynamic-require, node/global-require
// eslint-disable-next-line import/no-dynamic-require, n/global-require
const { dependencies: functionDependencies, devDependencies: functionDevDependencies } = require(functionPackageJson)
const sitePackageJson = await findUp('package.json', { cwd: functionsDir })
const npmInstallFlags = ['--no-audit', '--no-fund']
Expand All @@ -337,7 +337,7 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir })
return
}

// eslint-disable-next-line import/no-dynamic-require, node/global-require
// eslint-disable-next-line import/no-dynamic-require, n/global-require
const { dependencies: siteDependencies, devDependencies: siteDevDependencies } = require(sitePackageJson)
const dependencies = getNpmInstallPackages(siteDependencies, functionDependencies)
const devDependencies = getNpmInstallPackages(siteDevDependencies, functionDevDependencies)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/functions/functions-invoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const processPayloadFromFlag = function (payloadString) {
if (pathexists) {
try {
// there is code execution potential here
// eslint-disable-next-line node/global-require, import/no-dynamic-require
// eslint-disable-next-line n/global-require, import/no-dynamic-require
payload = require(payloadpath)
return payload
} catch (error_) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/graph/graph-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const graphHandler = async (userOperationName, options, command) => {
const filterOperationNames = (operationChoices, input) =>
operationChoices.filter((operation) => operation.value.toLowerCase().match(input.toLowerCase()))

// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const inquirerAutocompletePrompt = require('inquirer-autocomplete-prompt')
/** multiple matching detectors, make the user choose */
inquirer.registerPrompt('autocomplete', inquirerAutocompletePrompt)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const SUGGESTION_TIMEOUT = 1e4

const getVersionPage = async () => {
// performance optimization - load envinfo on demand
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const envinfo = require('envinfo')
const data = await envinfo.run({
System: ['OS', 'CPU'],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/functions/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FunctionsRegistry {
this.functionWatchers = new Map()

// Performance optimization: load '@netlify/zip-it-and-ship-it' on demand.
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { listFunctions } = require('@netlify/zip-it-and-ship-it')

this.listFunctions = listFunctions
Expand Down
4 changes: 2 additions & 2 deletions src/lib/functions/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ const createHandler = function (options) {
const getFunctionsServer = function (options) {
const { buildersPrefix = '', functionsPrefix = '', functionsRegistry, siteUrl } = options
// performance optimization, load express on demand
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const express = require('express')
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const expressLogging = require('express-logging')
const app = express()
const functionHandler = createHandler(options)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/deploy/hash-fns.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getFunctionZips = async ({

if (manifestPath) {
try {
// eslint-disable-next-line import/no-dynamic-require, node/global-require
// eslint-disable-next-line import/no-dynamic-require, n/global-require
const { functions, timestamp } = require(manifestPath)
const manifestAge = Date.now() - timestamp

Expand Down
4 changes: 2 additions & 2 deletions src/utils/detect-server-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ const detectFrameworkSettings = async ({ projectDir }) => {

if (frameworks.length > 1) {
// performance optimization, load inquirer on demand
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const inquirer = require('inquirer')
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const inquirerAutocompletePrompt = require('inquirer-autocomplete-prompt')
/** multiple matching detectors, make the user choose */
inquirer.registerPrompt('autocomplete', inquirerAutocompletePrompt)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/functions/get-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getFunctions = async (functionsSrcDir, config = {}) => {
}

// performance optimization, load '@netlify/zip-it-and-ship-it' on demand
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { listFunctions } = require('@netlify/zip-it-and-ship-it')
const functions = await listFunctions(functionsSrcDir, {
config: config.functions ? extractSchedule(config.functions) : undefined,
Expand All @@ -42,7 +42,7 @@ const getFunctionsAndWatchDirs = async (functionsSrcDir) => {
}

// performance optimization, load '@netlify/zip-it-and-ship-it' on demand
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { listFunctions } = require('@netlify/zip-it-and-ship-it')

// get all functions files so we know which directories to watch
Expand Down
4 changes: 2 additions & 2 deletions src/utils/read-repo-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const GITHUB = 'GitHub'
*/
const readRepoURL = async function (_url) {
// TODO: use `url.URL()` instead
// eslint-disable-next-line node/no-deprecated-api
// eslint-disable-next-line n/no-deprecated-api
const URL = url.parse(_url)
const repoHost = validateRepoURL(_url)
if (repoHost !== GITHUB) throw new Error('only GitHub repos are supported for now')
Expand All @@ -38,7 +38,7 @@ const getRepoURLContents = async function (repoHost, ownerAndRepo, contentsPath)

const validateRepoURL = function (_url) {
// TODO: use `url.URL()` instead
// eslint-disable-next-line node/no-deprecated-api
// eslint-disable-next-line n/no-deprecated-api
const URL = url.parse(_url)
if (URL.host !== 'github.com') return null
// other validation logic here
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/20.command.functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ test('should install function template dependencies on a site-level `package.jso

await childProcess

// eslint-disable-next-line import/no-dynamic-require, node/global-require
// eslint-disable-next-line import/no-dynamic-require, n/global-require
const { dependencies } = require(`${builder.directory}/package.json`)

// NOTE: Ideally we should be running this test with a specific template,
Expand Down Expand Up @@ -801,7 +801,7 @@ test('should inject env variables', async (t) => {
path: 'echo-env.js',
handler: async () => ({
statusCode: 200,
// eslint-disable-next-line node/prefer-global/process
// eslint-disable-next-line n/prefer-global/process
body: `${process.env.TEST}`,
}),
})
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/210.command.deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ if (process.env.NETLIFY_TEST_DISABLE_LIVE !== 'true') {
name: 'mutator',
plugin: {
onPreBuild: async ({ netlifyConfig }) => {
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { mkdir, writeFile } = require('fs').promises

const generatedFunctionsDir = 'new_functions'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/330.serving-functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ test('Serves functions that dynamically load files included in the `functions.in
handler: async (event) => {
const { name } = event.queryStringParameters

// eslint-disable-next-line import/no-dynamic-require, node/global-require
// eslint-disable-next-line import/no-dynamic-require, n/global-require
const { data } = require(`../files/${name}.json`)

return {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/completion/completion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test.afterEach(() => {
test('should generate a completion file', (t) => {
const stub = sinon.stub(fs, 'writeFileSync').callsFake(() => {})
const program = createTestCommand()
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { createAutocompletion } = require('../../../../src/lib/completion/generate-autocompletion')
createAutocompletion(program)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/exec-fetcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const sinon = require('sinon')
const { rewiremock } = require('../../integration/utils/rewiremock')

const fetchLatestSpy = sinon.stub()
// eslint-disable-next-line node/global-require
// eslint-disable-next-line n/global-require
const { fetchLatestVersion, getArch, getExecName } = rewiremock.proxy(() => require('../../../src/lib/exec-fetcher'), {
'gh-release-fetch': {
fetchLatest: fetchLatestSpy,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/functions/get-functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test.skip('should return additional watch dirs when functions requires a file ou
path: 'index.js',
// eslint-disable-next-line require-await
handler: async () => {
// eslint-disable-next-line node/global-require, import/no-unresolved
// eslint-disable-next-line n/global-require, import/no-unresolved
const { logHello } = require('../utils')
logHello()
return { statusCode: 200, body: 'Logged Hello!' }
Expand Down

1 comment on commit 1cb5a91

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 380 MB

Please sign in to comment.