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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
build/
dist/
coverage/
6 changes: 3 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from 'eslint/config';
import eslintPlugin from 'eslint-plugin-eslint-plugin';
import { configs } from './dist/index.js';
import { configs } from './dist/index.cjs';

export default defineConfig(
configs.typescript,
eslintPlugin.configs['flat/recommended'],
...configs.typescript,
eslintPlugin.configs['recommended'],
{
files: ['src/**/*.ts'],
rules: {
Expand Down
2,641 changes: 1,819 additions & 822 deletions package-lock.json

Large diffs are not rendered by default.

115 changes: 67 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@
"name": "@croct/eslint-plugin",
"version": "0.0.0-dev",
"description": "ESLint rules and presets applied to all Croct JavaScript projects.",
"license": "MIT",
"author": {
"name": "Croct",
"email": "lib+coding-standard-js@croct.com",
"url": "https://croct.com"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/croct-tech/coding-standard-js.git"
},
"bugs": {
"url": "https://github.com/croct-tech/coding-standard-js/issues"
},
"homepage": "https://github.com/croct-tech/coding-standard-js",
"scripts": {
"lint": "eslint 'src/**/*.{ts,tsx}'",
"test": "jest -c jest.config.js --coverage",
"validate": "tsc --noEmit",
"build": "tsc -p tsconfig.build.json"
},
"keywords": [
"eslint",
"eslint-plugin",
Expand All @@ -35,39 +13,80 @@
"react",
"cypress"
],
"homepage": "https://github.com/croct-tech/coding-standard-js",
"bugs": {
"url": "https://github.com/croct-tech/coding-standard-js/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/croct-tech/coding-standard-js.git"
},
"license": "MIT",
"author": {
"name": "Croct",
"email": "lib+coding-standard-js@croct.com",
"url": "https://croct.com"
},
"main": "dist/index.cjs",
"types": "dist/index.d.cts",
"scripts": {
"build": "tsdown",
"lint": "eslint 'src/**/*.{ts,tsx}'",
"test": "jest -c jest.config.js --coverage",
"validate": "tsc --noEmit"
},
"dependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
"@stylistic/eslint-plugin": "^5.7.0",
"@typescript-eslint/utils": "^8.53.0",
"eslint-plugin-cypress": "^5.2.1",
"eslint-plugin-import-newlines": "^1.4.0",
"eslint-plugin-import-x": "^4.16.1",
"eslint-plugin-jest": "^29.12.1",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.0",
"@eslint/compat": "^2.0.2",
"@stylistic/eslint-plugin": "^5.9.0",
"@typescript-eslint/typescript-estree": "^8.56.1",
"@typescript-eslint/utils": "^8.56.1",
"eslint-plugin-cypress": "^6.1.0",
"eslint-plugin-eslint-plugin": "^7.3.1",
"eslint-plugin-import-newlines": "^2.0.0",
"eslint-plugin-jest": "^29.15.0",
"eslint-plugin-newline-destructuring": "^1.2.2",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-testing-library": "^7.15.4",
"globals": "^17.0.0",
"typescript-eslint": "^8.53.0"
"eslint-plugin-self": "^1.2.1",
"eslint-plugin-testing-library": "^7.16.0",
"globals": "^17.4.0",
"typescript-eslint": "^8.56.1"
},
"devDependencies": {
"@types/jest": "^30.0.0",
"@types/semver": "^7.5.8",
"@typescript-eslint/parser": "^8.53.0",
"@typescript-eslint/rule-tester": "^8.53.0",
"@typescript-eslint/types": "^8.53.0",
"@typescript-eslint/typescript-estree": "^8.53.0",
"eslint": "^9.28.0",
"eslint-plugin-eslint-plugin": "^6.4.0",
"eslint-plugin-self": "^1.2.1",
"jest": "^30.0.0",
"ts-jest": "^29.3.4",
"typescript": "~5.9.0"
"@types/semver": "^7.7.1",
"@typescript-eslint/parser": "^8.56.1",
"@typescript-eslint/rule-tester": "^8.56.1",
"@typescript-eslint/types": "^8.56.1",
"eslint": "^10.0.2",
"eslint-plugin-import-x": "^4.16.1",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"jest": "^30.2.0",
"ts-jest": "^29.4.6",
"tsdown": "^0.21.0-beta.2",
"typescript": "~5.9.3"
},
"peerDependencies": {
"@typescript-eslint/parser": ">= 8",
"eslint": ">= 9"
"eslint": ">= 10"
},
"overrides": {
"eslint-plugin-jsx-a11y": {
"eslint": "$eslint"
},
"eslint-plugin-jest-dom": {
"eslint": "$eslint"
},
"eslint-plugin-react": {
"eslint": "$eslint"
},
"eslint-plugin-react-hooks": {
"eslint": "$eslint"
},
"eslint-plugin-import-x": {
"eslint": "$eslint"
}
}
}
3 changes: 2 additions & 1 deletion src/configs/cypress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {Linter, ESLint} from 'eslint';
import {fixupPluginRules} from '@eslint/compat';
import cypressPlugin from 'eslint-plugin-cypress';

// Factory function to create Cypress config with the plugin reference
Expand All @@ -8,7 +9,7 @@ export function createCypressConfig(plugin: ESLint.Plugin, javascriptConfig: Lin
{
name: '@croct/cypress',
plugins: {
cypress: cypressPlugin,
cypress: fixupPluginRules(cypressPlugin),
'@croct': plugin,
},
rules: {
Expand Down
4 changes: 2 additions & 2 deletions src/configs/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {ESLint, Linter} from 'eslint';
import {fixupPluginRules} from '@eslint/compat';
import globals from 'globals';
import jest from 'eslint-plugin-jest';
import {importX} from 'eslint-plugin-import-x';
// @ts-expect-error - no types available
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
// @ts-expect-error - no types available
import importNewlines from 'eslint-plugin-import-newlines';
Expand Down Expand Up @@ -854,7 +854,7 @@ export function createJavaScriptConfig(plugin: ESLint.Plugin): Linter.Config[] {
// import-x exports types using ESLint v8 for compatibility reasons,
// but it is compatible with ESLint v9 as well.
'import-x': importX as unknown as ESLint.Plugin,
'newline-destructuring': newlineDestructuring,
'newline-destructuring': fixupPluginRules(newlineDestructuring),
'@croct': plugin,
},
languageOptions: {
Expand Down
7 changes: 4 additions & 3 deletions src/configs/react.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {ESLint, Linter} from 'eslint';
import {fixupConfigRules, fixupPluginRules} from '@eslint/compat';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import testingLibrary from 'eslint-plugin-testing-library';
Expand Down Expand Up @@ -320,14 +321,14 @@ const baseRules: Linter.RulesRecord = {
export function createReactConfig(plugin: ESLint.Plugin, javascriptConfig: Linter.Config[]): Linter.Config[] {
return [
...javascriptConfig,
reactPlugin.configs.flat.recommended,
...fixupConfigRules(reactPlugin.configs.flat.recommended),
testingLibrary.configs['flat/react'],
jestDom.configs['flat/recommended'],
...fixupConfigRules(jestDom.configs['flat/recommended']),
jsxA11y.flatConfigs.recommended as Linter.Config,
{
name: '@croct/react',
plugins: {
'react-hooks': reactHooks,
'react-hooks': fixupPluginRules(reactHooks as ESLint.Plugin),
'@stylistic': stylistic,
'@croct': plugin,
},
Expand Down
7 changes: 1 addition & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,5 @@ export const configs = {

Object.assign(plugin.configs, configs);

// Export the plugin as default
export default plugin as ESLint.Plugin & {
configs: typeof configs,
};

// Re-export rules and configs for convenience
export {rules};
export {plugin, rules};
2 changes: 1 addition & 1 deletion src/rules/argument-spacing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const argumentSpacing = createRule({
defaultOptions: [],
create: context => {
function check(node: TSESTree.NewExpression | TSESTree.CallExpression): void {
const sourceCode = context.getSourceCode();
const {sourceCode} = context;

if (node.arguments.length === 0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/complex-expression-spacing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const complexExpressionSpacing = createRule({
},
defaultOptions: [],
create: context => {
const sourceCode = context.getSourceCode();
const {sourceCode} = context;

function check(node: TSESTree.Expression): void {
const parentPreviousToken = sourceCode.getTokenBefore(node, {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/jsx-attribute-spacing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const jsxAttributeSpacing = createRule({
},
defaultOptions: [],
create: context => {
const sourceCode = context.getSourceCode();
const {sourceCode} = context;

function check(node: TSESTree.JSXAttribute): void {
const {value} = node;
Expand Down
12 changes: 9 additions & 3 deletions src/rules/min-chained-call-depth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ export const minChainedCallDepth = createRule({
maxLineLength: {
type: 'integer',
minimum: 1,
default: 100,
description: 'The maximum line length allowed for inlining chained calls.',
},
ignoreChainDeeperThan: {
type: 'integer',
minimum: 1,
maximum: 10,
default: 2,
description: 'The minimum chain depth at which to ignore the rule.',
},
},
additionalProperties: false,
},
],
defaultOptions: [
{
maxLineLength: 100,
ignoreChainDeeperThan: 2,
},
],
messages: {
unexpectedLineBreak: 'Unexpected line break.',
},
Expand All @@ -41,7 +47,7 @@ export const minChainedCallDepth = createRule({
},
],
create: context => {
const sourceCode = context.getSourceCode();
const {sourceCode} = context;
let maxDepth = 0;

function getDepth(node: TSESTree.MemberExpression | TSESTree.CallExpression): number {
Expand Down
9 changes: 7 additions & 2 deletions src/rules/newline-per-chained-call/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ export const newlinePerChainedCall = createRule({
type: 'integer',
minimum: 1,
maximum: 10,
default: 2,
description: 'The minimum chain depth at which to ignore the rule.',
},
},
additionalProperties: false,
},
],
defaultOptions: [
{
ignoreChainDeeperThan: 2,
},
],
messages: {
expectedLineBreak: 'Expected line break before `{{propertyName}}`.',
},
Expand All @@ -38,7 +43,7 @@ export const newlinePerChainedCall = createRule({
const options = context.options[0] ?? {};
const ignoreChainWithDepth = options.ignoreChainDeeperThan ?? 2;

const sourceCode = context.getSourceCode();
const {sourceCode} = context;

function getPropertyText(node: TSESTree.MemberExpression): string {
const prefix = '.';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/parameter-destructuring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const parameterDestructuring = createRule({
},
defaultOptions: [],
create: context => {
const sourceCode = context.getSourceCode();
const {sourceCode} = context;

return {
ObjectPattern: function checkObjectPattern(node): void {
Expand Down
Loading
Loading