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

Prepare for new release #68

Merged
merged 2 commits into from
Nov 12, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 4.0.0
* Big dependency update, ESLint 9, typescript-eslint 8, +++
* Drop XO as we do not want the Stylistic rules (we use Prettier for that)
* New rules include: alphabetical sorting of switch cases

## 3.2.0
* Update dependencies

Expand Down
18 changes: 0 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import path from 'path';
import { fileURLToPath } from 'url';

import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import xoBrowser from 'eslint-config-xo/browser';
import perfectionist from 'eslint-plugin-perfectionist';

import { baseRuleSet } from './rule-sets/base.js';
import { cypressRuleSet } from './rule-sets/cypress.js';
Expand All @@ -14,23 +8,11 @@ import { nodeRuleSet } from './rule-sets/node.js';
import { storybookRuleSet } from './rule-sets/storybook.js';
import { unitTestRuleSet } from './rule-sets/unit-test.js';

// mimic CommonJS variables (in ESM)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

/** @type { import("eslint").Linter.Config[] } */
// eslint-disable-next-line import/no-default-export
export default [
js.configs.recommended,
...xoBrowser,
compat.extends('eslint-config-xo-react')[0],
eslintConfigPrettier,
// @ts-expect-error types are missing
perfectionist.configs['recommended-natural'],
// Base Tidal rule set:
baseRuleSet,
// Following are some file type specific overrides:
Expand Down
149 changes: 1 addition & 148 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"main": "index.js",
"scripts": {
"test": "ava test/test.js",
"type-check": "tsc",
"lint": "eslint --report-unused-disable-directives ."
},
"repository": {
Expand Down Expand Up @@ -71,8 +72,6 @@
"confusing-browser-globals": "1.0.11",
"eslint": "9.14.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-xo": "0.46.0",
"eslint-config-xo-react": "0.27.0",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-cypress": "4.1.0",
"eslint-plugin-import": "2.31.0",
Expand Down
44 changes: 35 additions & 9 deletions rule-sets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import confusingBrowserGlobals from 'confusing-browser-globals';
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests';
import perfectionist from 'eslint-plugin-perfectionist';
import prettier from 'eslint-plugin-prettier';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';

import { internalRules } from '../internal-rules/index.js';
Expand All @@ -21,7 +24,7 @@ export const baseRuleSet = {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
project: true,
projectService: true,
sourceType: 'module',
},
},
Expand All @@ -33,24 +36,20 @@ export const baseRuleSet = {
'internal-rules': internalRules,
'jsx-a11y': jsxA11yPlugin,
'no-only-tests': noOnlyTestsPlugin,
perfectionist,
prettier,
react,
'react-hooks': reactHooks,
},
rules: {
...tsPlugin.configs['recommended-type-checked'].rules,
...tsPlugin.configs['stylistic-type-checked'].rules,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...importPlugin.configs.typescript.rules,
...jsxA11yPlugin.configs.recommended.rules,
...perfectionist.configs['recommended-natural'].rules,
'@jambit/typed-redux-saga/delegate-effects': 'error',
'@jambit/typed-redux-saga/use-typed-effects': ['error', 'macro'],
'@stylistic/comma-dangle': 'off',
'@stylistic/function-paren-newline': 'off',
'@stylistic/indent': 'off',
'@stylistic/jsx-quotes': 'off',
'@stylistic/object-curly-spacing': 'off',
'@stylistic/padding-line-between-statements': 'off',
'@stylistic/semi': 'off',
'@stylistic/space-before-blocks': 'off',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
Expand Down Expand Up @@ -206,9 +205,32 @@ export const baseRuleSet = {
'no-shadow': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-var': 'error',
'no-warning-comments': 'off',
'object-shorthand': 'error',
// TODO: consider switching from 'import/order' to this one?
'perfectionist/sort-imports': 'off',
'perfectionist/sort-intersection-types': [
'error',
{
groups: [
[
'conditional',
'function',
'import',
'intersection',
'keyword',
'literal',
'named',
'operator',
'tuple',
'union',
],
['object'],
['nullish'],
],
},
],
'prettier/prettier': [
'error',
{
Expand Down Expand Up @@ -245,6 +267,10 @@ export const baseRuleSet = {
'import/resolver': {
typescript: {},
},
perfectionist: {
ignoreCase: false,
type: 'natural',
},
react: {
version: '18.2.0',
},
Expand Down
22 changes: 22 additions & 0 deletions test/cases/nice-sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export function ProfileImageRepresentation({
desiredWidth,
resourceId,
width,
}: {
className: string;
desiredWidth: number;
resourceId: string;
width: number;
}) {
const style = {
height: (() => {})(),
Expand All @@ -53,3 +58,20 @@ export function ProfileImageRepresentation({
/>
);
}

export type SortDirection = 'ASC' | 'DESC';

export type SortOrderAndDirection = [
OnboardingStepName | null | undefined,
SortDirection | null | undefined,
];

export type Playlist = ClientApplication &
SortOrderAndDirection & {
readonly contentType: 'folderPlaylist' | 'playlist';
readonly parent?: {
readonly id: string;
readonly name: string;
};
readonly trn?: string;
};
5 changes: 5 additions & 0 deletions test/cases/ugly-sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export function ProfileImageRepresentation({
className,
desiredWidth,
resourceId,
}: {
width: number;
className: string;
desiredWidth: number;
resourceId: string;
}) {
const style = {
height: (() => {})(),
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test('Fails on unsorted file', async t => {
t.is(unexpectedErrorsFound.length, 0);

// Total number of seen errors:
t.is(errors.length, 10);
t.is(errors.length, 11);
});

test('Success on sorted file', async t => {
Expand Down