Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"husky": "^9.1.7",
"lerna": "^9.0.7",
"lint-staged": "^17.0.8",
"prettier": "npm:wp-prettier@3.0.3",
"prettier": "npm:wp-prettier@^3.0.3",
"syncpack": "^14.3.1",
"vitest": "^3.2.6"
}
Expand Down
17 changes: 4 additions & 13 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,13 @@
"author": "",
"license": "ISC",
"dependencies": {
"@babel/eslint-parser": "^7.25.7",
"@babel/preset-react": "^7.29.7",
"@eslint/compat": "^2.1.0",
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.1",
"@typescript-eslint/eslint-plugin": "^8.60.1",
"@typescript-eslint/parser": "^8.60.1",
"@wordpress/eslint-plugin": "^24.5.0",
"eslint-config-prettier": "^10.1.8",
"@wordpress/eslint-plugin": "^25.6.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-react-hooks": "^7.1.1",
"globals": "^17.6.0"
"globals": "^17.7.0",
"typescript-eslint": "^8.62.1"
Comment on lines 20 to +24

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Linting gaat via de @yardinternet/toolkit package, en daar staat hij bij. Hier is ie niet nodig

},
"devDependencies": {
"eslint": "^9.39.4",
"eslint": "^10.6.0",
"vitest": "^3.2.6"
}
}
63 changes: 16 additions & 47 deletions packages/eslint-config/src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
const globals = require( 'globals' );
const babelParser = require( '@babel/eslint-parser' );
const tsParser = require( '@typescript-eslint/parser' );
const tsPlugin = require( '@typescript-eslint/eslint-plugin' );
const { fixupConfigRules } = require( '@eslint/compat' );
const js = require( '@eslint/js' );
const { FlatCompat } = require( '@eslint/eslintrc' );
const wordpress = require( '@wordpress/eslint-plugin' );
const tseslint = require( 'typescript-eslint' );
const resolveImportAliases = require( './utils/resolve-import-aliases' );

const compat = new FlatCompat( {
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
} );
// The plugin only registers prettier when `prettier` is installed. Referencing
// prettier/prettier otherwise throws "Could not find plugin 'prettier'".
const prettierRegistered = wordpress.configs.recommended.some(
( config ) => config.plugins && config.plugins.prettier
);

// Shared between the JS/JSX and TS/TSX configs.
const sharedGlobals = {
Expand All @@ -29,37 +25,18 @@ const sharedSettings = {

// Formatting is owned by Prettier (`pnpm format`), not ESLint.
const sharedRules = {
'prettier/prettier': 0,
'jsdoc/require-param': 0,
'import/no-extraneous-dependencies': 0,
...( prettierRegistered ? { 'prettier/prettier': 0 } : {} ),
};

module.exports = [
...fixupConfigRules(
compat.extends(
'plugin:@wordpress/eslint-plugin/recommended',
'prettier'
)
),
...wordpress.configs.recommended,
{
files: [ '**/*.js', '**/*.jsx' ],
languageOptions: {
globals: sharedGlobals,

parser: babelParser,

parserOptions: {
requireConfigFile: false,

babelOptions: {
presets: [ '@babel/preset-react' ],
},
ecmaFeatures: {
jsx: true,
},
},
},

rules: {
...sharedRules,
'no-unused-expressions': [
Expand All @@ -70,32 +47,25 @@ module.exports = [
],
'import/no-unresolved': [ 'error', { ignore: [ '^@wordpress/' ] } ],
},

settings: {
...sharedSettings,
'import/resolver': {
alias: resolveImportAliases(),
},
},
},
// Register TS ourselves so it works regardless of whether the consumer has
// `typescript` installed. Scoped to TS files to keep the babel parser on JS.
...tseslint.configs.recommended.map( ( config ) => ( {
...config,
files: [ '**/*.ts', '**/*.tsx' ],
Comment on lines +59 to +63

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True maar we gebruiken nooit .mts of .cts bestanden, dus deze laat ik

} ) ),
{
files: [ '**/*.ts', '**/*.tsx' ],
languageOptions: {
globals: sharedGlobals,

// The @typescript-eslint plugin is already registered by
// @wordpress/eslint-plugin/recommended above; only set the parser.
parser: tsParser,

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

rules: {
...tsPlugin.configs.recommended.rules,
...sharedRules,
// TS-aware version replaces the core rule.
'no-unused-expressions': 0,
Expand All @@ -105,10 +75,9 @@ module.exports = [
allowTernary: true,
},
],
// TypeScript + the bundler resolve modules (incl. path aliases).
// TS + bundler resolve modules, incl. path aliases.
'import/no-unresolved': 0,
},

settings: sharedSettings,
},
];
Loading