Skip to content

Commit

Permalink
chore(deps-dev): bump eslint from 8.42.0 to 9.0.0; update to new esli…
Browse files Browse the repository at this point in the history
…nt flat file config (#3954)

In eslint@9 there is a new suggested config file format ("flat")
https://github.com/eslint/rfcs/tree/main/designs/2019-config-simplification
https://eslint.org/docs/latest/use/configure/configuration-files

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: David Luna <[email protected]>
Co-authored-by: Trent Mick <[email protected]>
  • Loading branch information
3 people authored Apr 10, 2024
1 parent c0ed986 commit 335ab65
Show file tree
Hide file tree
Showing 23 changed files with 429 additions and 594 deletions.
111 changes: 0 additions & 111 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm run lint

Expand Down
124 changes: 124 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

const globals = require('globals');
const eslintJs = require('@eslint/js');
const prettierConfig = require('eslint-config-prettier');
const licenseHeaderPlugin = require('eslint-plugin-license-header');
const nPlugin = require('eslint-plugin-n');
const promisePlugin = require('eslint-plugin-promise');
const importPlugin = require('eslint-plugin-import');
const prettierPlugin = require('eslint-plugin-prettier');

module.exports = [
{
// This block should *only* have the "ignores" property.
// https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
ignores: [
'*.example.js', // a pattern for uncommited local dev files to avoid linting
'*.example.mjs', // a pattern for uncommited local dev files to avoid linting

'test_output/**',
'tmp/**',
'.nyc_output/**',
'build/**',
'node_modules/**',
'**/elastic-apm-node.js',
'**/.next/**',

'examples/esbuild/dist/**',
'examples/typescript/dist/**',
'examples/an-azure-function-app/**',
'lib/opentelemetry-bridge/opentelemetry-core-mini/**',
'test/babel/out.js',
'test/lambda/fixtures/esbuild-bundled-handler/hello.js',
'test/sourcemaps/fixtures/lib/**',
'test/sourcemaps/fixtures/src/**',
'test/stacktraces/fixtures/dist/**',
'test/types/transpile/index.js',
'test/types/transpile-default/index.js',
],
},
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
fetch: false, // not present in node globals (readonly)
},
parserOptions: {
ecmaFeatures: {
jsx: true, // to parse nextjs files
},
},
},
plugins: {
'license-header': licenseHeaderPlugin,
n: nPlugin,
promise: promisePlugin,
import: importPlugin,
prettier: prettierPlugin,
},
rules: {
...eslintJs.configs.recommended.rules,
...prettierConfig.rules,
'prettier/prettier': ['error'],
'license-header/header': ['error', './dev-utils/license-header.js'],

// Restoring some config from standardjs that we want to maintain at least
// for now -- to assist with transition to prettier.
'no-unused-vars': [
// See taav for possible better 'no-unused-vars' rule.
'error',
{
args: 'none',
caughtErrors: 'none',
ignoreRestSiblings: true,
vars: 'all',
},
],
'no-empty': [
'error',
{
allowEmptyCatch: true,
},
],
'no-constant-condition': [
'error',
{
checkLoops: false,
},
],
'n/handle-callback-err': ['error', '^(err|error)$'],
'n/no-callback-literal': ['error'],
'n/no-deprecated-api': ['error'],
'n/no-exports-assign': ['error'],
'n/no-new-require': ['error'],
'n/no-path-concat': ['error'],
'n/process-exit-as-throw': ['error'],
'promise/param-names': ['error'],
// Undo this config from eslint:recommended for now (standardjs didn't have it.)
'require-yield': ['off'],
'import/export': 'error',
'import/first': 'error',
'import/no-absolute-path': [
'error',
{ esmodule: true, commonjs: true, amd: false },
],
'import/no-duplicates': 'error',
'import/no-named-default': 'error',
'import/no-webpack-loader-syntax': 'error',
// Some defaults have changed in v9
'dot-notation': ['error'],
'new-cap': ['error', { capIsNew: false }],
'no-eval': ['error', { allowIndirect: true }],
'no-new': ['error'],
yoda: ['error'],
'valid-typeof': ['error'],
},
},
];
10 changes: 8 additions & 2 deletions examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
}
};

module.exports = nextConfig
module.exports = nextConfig;
12 changes: 9 additions & 3 deletions examples/nextjs/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import '../styles/globals.css'
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
return <Component {...pageProps} />;
}

export default MyApp
export default MyApp;
8 changes: 7 additions & 1 deletion examples/nextjs/pages/api/hello.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
res.status(200).json({ name: 'John Doe' });
}
15 changes: 11 additions & 4 deletions examples/nextjs/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

/* eslint-disable no-unused-vars */
import Head from 'next/head';
import Image from 'next/image';
import styles from '../styles/Home.module.css';

export default function Home() {
return (
Expand Down Expand Up @@ -65,5 +72,5 @@ export default function Home() {
</a>
</footer>
</div>
)
);
}
3 changes: 2 additions & 1 deletion lib/instrumentation/run-context/AbstractRunContextManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class AbstractRunContextManager {
constructor(log, runContextClass = RunContext) {
this._log = log;
this._kListeners = Symbol('ElasticListeners');
this._root = new runContextClass(); // eslint-disable-line new-cap
// eslint-disable-next-line new-cap
this._root = new runContextClass();
}

// Get the root run context. This is always empty (no current trans or span).
Expand Down
1 change: 0 additions & 1 deletion lib/opentelemetry-bridge/OTelSpan.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function isHomogeneousArrayOfStrNumBool(arr) {
return false;
}
} else if (typeof elem !== elemType) {
// eslint-disable-line valid-typeof
return false;
}
}
Expand Down
Loading

0 comments on commit 335ab65

Please sign in to comment.