Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to eslint 9, use flat config #5429

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { dirname } from 'path';
import { fileURLToPath } from 'url';

import commonConfig from './shared/config/eslint/common.mjs'
import govukFrontendConfig from './shared/config/eslint/govuk-frontend-config.mjs'

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export default [
...commonConfig,
...govukFrontendConfig(__dirname),
]
3,932 changes: 2,430 additions & 1,502 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "@govuk-frontend/repository",
"description": "Used only for the development of GOV.UK Frontend, see `packages/govuk-frontend/package.json` for the published `package.json`",
"engines": {
"node": "^20.9.0",
"node": "^22.11.0",
"npm": "^10.1.0"
},
"license": "MIT",
Expand Down Expand Up @@ -48,40 +48,41 @@
"prepare": "node -e \"try { (await import('husky')).default() } catch (e) { if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e }\" --input-type module"
},
"devDependencies": {
"@babel/core": "^7.25.8",
"@babel/preset-env": "^7.25.8",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@eslint/js": "^9.13.0",
"@govuk-frontend/config": "*",
"@govuk-frontend/eslint-config": "*",
"@govuk-frontend/helpers": "*",
"@govuk-frontend/lib": "*",
"@govuk-frontend/tasks": "*",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/jest-dom": "^6.6.2",
"@types/testing-library__jest-dom": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"del-cli": "^5.1.0",
"editorconfig-checker": "^5.1.8",
"eslint": "^8.57.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-es-x": "^7.6.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-es-x": "^8.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-jsdoc": "^48.2.2",
"eslint-plugin-markdown": "^4.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-jsdoc": "^50.4.3",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-n": "^17.11.1",
"eslint-plugin-promise": "^7.1.0",
"globals": "^15.11.0",
"gulp": "^5.0.0",
"gulp-cli": "^3.0.0",
"husky": "^9.1.6",
"jest": "^29.7.0",
"jest-environment-node-single-context": "^29.4.0",
"jest-puppeteer": "^10.1.2",
"jest-puppeteer": "^10.1.4",
"jest-regex-util": "^29.4.3",
"jest-serializer-html": "^7.1.0",
"lint-staged": "^15.2.10",
"neostandard": "^0.11.7",
"postcss-markdown": "^1.2.0",
"postcss-scss": "^4.0.9",
"prettier": "^3.3.3",
Expand All @@ -90,7 +91,8 @@
"stylelint": "^16.9.0",
"stylelint-config-gds": "^2.0.0",
"stylelint-order": "^6.0.4",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"typescript-eslint": "^8.11.0"
},
"optionalDependencies": {
"@actions/github": "^6.0.0",
Expand All @@ -100,11 +102,11 @@
"@types/browser-sync": "^2.29.0",
"@types/express": "^5.0.0",
"@types/gulp": "^4.0.17",
"@types/jest": "^29.5.13",
"@types/jest": "^29.5.14",
"@types/jest-axe": "^3.5.9",
"@types/js-yaml": "^4.0.9",
"@types/mime-types": "^2.1.4",
"@types/node": "^22.7.7",
"@types/node": "^22.8.1",
"@types/nunjucks": "^3.2.6",
"@types/slug": "^5.0.9",
"@types/vinyl": "^2.0.12",
Expand Down
178 changes: 89 additions & 89 deletions packages/govuk-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
const { join } = require('path')
// const { join } = require('path')

module.exports = {
settings: {
node: {
version: '^18.12.0'
}
},
overrides: [
{
files: ['src/govuk/**/*.mjs'],
excludedFiles: ['**/*.test.mjs'],
parser: '@typescript-eslint/parser',
parserOptions: {
// Note: Allow ES2015 for import/export syntax
ecmaVersion: '2015',
project: [join(__dirname, 'tsconfig.build.json')]
},
plugins: ['@typescript-eslint', 'es-x'],
extends: [
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:es-x/restrict-to-es2015',
'prettier'
],
env: {
browser: true
},
rules: {
// Allow void return shorthand in arrow functions
'@typescript-eslint/no-confusing-void-expression': [
'error',
{
ignoreArrowShorthand: true
}
],
// module.exports = {
// settings: {
// node: {
// version: '^18.12.0'
// }
// },
// overrides: [
// {
// files: ['src/govuk/**/*.mjs'],
// excludedFiles: ['**/*.test.mjs'],
// parser: '@typescript-eslint/parser',
// parserOptions: {
// // Note: Allow ES2015 for import/export syntax
// ecmaVersion: '2015',
// project: [join(__dirname, 'tsconfig.build.json')]
// },
// plugins: ['@typescript-eslint', 'es-x'],
// extends: [
// 'plugin:@typescript-eslint/strict-type-checked',
// 'plugin:@typescript-eslint/stylistic-type-checked',
// 'plugin:es-x/restrict-to-es2015',
// 'prettier'
// ],
// env: {
// browser: true
// },
// rules: {
// // Allow void return shorthand in arrow functions
// '@typescript-eslint/no-confusing-void-expression': [
// 'error',
// {
// ignoreArrowShorthand: true
// }
// ],

// Check type support for template string implicit `.toString()`
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowBoolean: true,
allowNumber: true
}
],
// // Check type support for template string implicit `.toString()`
// '@typescript-eslint/restrict-template-expressions': [
// 'error',
// {
// allowBoolean: true,
// allowNumber: true
// }
// ],

// Babel transpiles ES2020 class fields
'es-x/no-class-fields': 'off',
// // Babel transpiles ES2020 class fields
// 'es-x/no-class-fields': 'off',

// ES modules include ES2016 '[].includes()' coverage
// https://browsersl.ist/#q=supports+es6-module+and+not+supports+array-includes
'es-x/no-array-prototype-includes': 'off',
// // ES modules include ES2016 '[].includes()' coverage
// // https://browsersl.ist/#q=supports+es6-module+and+not+supports+array-includes
// 'es-x/no-array-prototype-includes': 'off',

// Babel transpiles ES2020 `??` nullish coalescing
'es-x/no-nullish-coalescing-operators': 'off',
// // Babel transpiles ES2020 `??` nullish coalescing
// 'es-x/no-nullish-coalescing-operators': 'off',

// ES modules include ES2017 'Object.entries()' coverage
// https://browsersl.ist/#q=supports+es6-module+and+not+supports+object-entries
'es-x/no-object-entries': 'off',
// // ES modules include ES2017 'Object.entries()' coverage
// // https://browsersl.ist/#q=supports+es6-module+and+not+supports+object-entries
// 'es-x/no-object-entries': 'off',

// Babel transpiles ES2020 optional chaining
'es-x/no-optional-chaining': 'off',
// // Babel transpiles ES2020 optional chaining
// 'es-x/no-optional-chaining': 'off',

// JSDoc blocks are mandatory in source code
'jsdoc/require-jsdoc': [
'error',
{
enableFixer: false,
require: {
ClassDeclaration: true,
ClassExpression: true,
FunctionExpression: false,
MethodDefinition: true
}
}
],
// // JSDoc blocks are mandatory in source code
// 'jsdoc/require-jsdoc': [
// 'error',
// {
// enableFixer: false,
// require: {
// ClassDeclaration: true,
// ClassExpression: true,
// FunctionExpression: false,
// MethodDefinition: true
// }
// }
// ],

// JSDoc @param required in (mandatory) blocks but
// @param description is necessary in source code
'jsdoc/require-param-description': 'warn',
'jsdoc/require-param': 'error'
}
},
{
files: ['src/govuk-prototype-kit/**/*.js'],
parserOptions: {
sourceType: 'module'
},
env: {
browser: true
},
rules: {
// Allow browser import `govuk-frontend.min.js`
'n/no-missing-import': 'off'
}
}
]
}
// // JSDoc @param required in (mandatory) blocks but
// // @param description is necessary in source code
// 'jsdoc/require-param-description': 'warn',
// 'jsdoc/require-param': 'error'
// }
// },
// {
// files: ['src/govuk-prototype-kit/**/*.js'],
// parserOptions: {
// sourceType: 'module'
// },
// env: {
// browser: true
// },
// rules: {
// // Allow browser import `govuk-frontend.min.js`
// 'n/no-missing-import': 'off'
// }
// }
// ]
// }
18 changes: 18 additions & 0 deletions packages/govuk-frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { dirname } from 'path';
import { fileURLToPath } from 'url';

import commonConfig from './../../shared/config/eslint/common.mjs';
import govukFrontendConfig from './../../shared/config/eslint/govuk-frontend-config.mjs';

import { common, govukFrontendConfig } from '@govuk-frontend/eslint-config'

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

console.log('ayy')
console.log(__dirname)

export default [
...commonConfig,
...govukFrontendConfig(__dirname),
]
4 changes: 3 additions & 1 deletion packages/govuk-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@babel/core": "^7.25.8",
"@babel/preset-env": "^7.25.8",
"@govuk-frontend/config": "*",
"@govuk-frontend/eslint-config": "*",
"@govuk-frontend/helpers": "*",
"@govuk-frontend/lib": "*",
"@govuk-frontend/tasks": "*",
Expand All @@ -87,6 +88,7 @@
"sass-color-helpers": "^2.1.1",
"sass-embedded": "^1.79.4",
"sassdoc": "^2.7.4",
"slash": "^5.1.0"
"slash": "^5.1.0",
"typescript-eslint": "^8.13.0"
}
}
Loading