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

Eslint9 #5168

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Eslint9 #5168

Show file tree
Hide file tree
Changes from 2 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
98 changes: 0 additions & 98 deletions .eslintrc.js

This file was deleted.

36 changes: 0 additions & 36 deletions docs-site/src/examples/.eslintrc

This file was deleted.

89 changes: 89 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//@ts-check
/**
* ESlint Configuration
* @type {import('eslint').Linter.Config}
*/
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const react = require("eslint-plugin-react");
const reactHooks = require("eslint-plugin-react-hooks");
const jestPlugin = require("eslint-plugin-jest");

module.exports = [
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ["src/**/*.{js,jsx,ts,tsx}"],
ignores: ["src/examples/**"],
plugins: {
"@typescript-eslint": tseslint.plugin,
react,
"react-hooks": reactHooks,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: ["./tsconfig.json"],
},
},
settings: {
react: {
version: "detect",
},
},
rules: {
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": "off",
},
},
{
files: ["src/examples/**/*.{js,jsx,ts,tsx}"],
plugins: {
react,
},

languageOptions: {
globals: {
useState: "readonly",
render: "readonly",
DatePicker: "readonly",
getHours: "readonly",
setHours: "readonly",
setSeconds: "readonly",
setMinutes: "readonly",
getDate: "readonly",
addDays: "readonly",
subDays: "readonly",
addMonths: "readonly",
fi: "readonly",
getDay: "readonly",
isValid: "readonly",
format: "readonly",
range: "readonly",
getYear: "readonly",
getMonth: "readonly",
PropTypes: "readonly",
CalendarContainer: "readonly",
subMonths: "readonly",
forwardRef: "readonly",
},
},
},
// New configuration for test files
{
files: ["src/**/*.test.{js,jsx,ts,tsx}", "src/**/*.spec.{js,jsx,ts,tsx}"],
plugins: {
jest: jestPlugin,
},
rules: {
...jestPlugin.configs.recommended.rules,
"jest/expect-expect": "off",
},
},
];
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@eslint/js": "^9.12.0",
"@react-docgen/cli": "^2.0.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.0",
Expand All @@ -38,7 +39,7 @@
"@rollup/plugin-typescript": "^11.1.6",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.0",
"@types/eslint": "^8.56.10",
"@types/eslint": "^9.6.1",
"@types/jest": "^29.5.12",
"@types/node": "22",
"@types/react": "^18.3.4",
Expand All @@ -49,12 +50,12 @@
"babel-jest": "^29.7.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"core-js": "^3.38.1",
"eslint": "^8.57.0",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.8.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-unused-imports": "^4.1.3",
"husky": "9",
"jest": "^29.7.0",
Expand All @@ -75,7 +76,8 @@
"stylelint-scss": "^6.5.1",
"ts-jest": "^29.2.5",
"tslib": "^2.7.0",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"typescript-eslint": "^8.9.0"
},
"peerDependencies": {
"react": "^16.9.0 || ^17 || ^18",
Expand All @@ -88,7 +90,7 @@
"prop-types": "^15.8.1"
},
"scripts": {
"eslint": "eslint --ext .js,.jsx,.ts,.tsx ./src",
"eslint": "eslint ./src",
"precommit": "lint-staged --allow-empty",
"sass-lint": "stylelint 'src/stylesheets/*.scss'",
"lint": "yarn run eslint && yarn run sass-lint",
Expand Down
1 change: 0 additions & 1 deletion src/month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ export default class Month extends Component<MonthProps> {
? isPreSelected(this.props.preSelection)
: undefined;

// eslint-disable-next-line no-constant-condition
while (true) {
weeks.push(
<Week
Expand Down
4 changes: 0 additions & 4 deletions src/test/calendar_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1504,14 +1504,12 @@ describe("Calendar", () => {
expect(firstHeader?.textContent).toBe(firstWeekDayMin);
}

// eslint-disable-next-line jest/expect-expect
it("should use the 'en' locale by default", () => {
const selected = newDate();
const { calendar } = getCalendar({ selected });
testLocale(calendar, selected);
});

// eslint-disable-next-line jest/expect-expect
it("should use the default locale when set", () => {
const selected = newDate();
setDefaultLocale("fi");
Expand All @@ -1521,7 +1519,6 @@ describe("Calendar", () => {
setDefaultLocale("");
});

// eslint-disable-next-line jest/expect-expect
it("should use the locale specified as a prop", () => {
registerLocale("fi", fi);
const locale = "fi";
Expand All @@ -1530,7 +1527,6 @@ describe("Calendar", () => {
testLocale(calendar, selected, locale);
});

// eslint-disable-next-line jest/expect-expect
it("should override the default locale with the locale prop", () => {
const locale = "en";
const selected = newDate();
Expand Down
1 change: 0 additions & 1 deletion src/test/datepicker_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,6 @@ describe("DatePicker", () => {
expect(getSeconds(date!)).toBe(12);
});

// eslint-disable-next-line jest/expect-expect
it("should mount and unmount properly", () => {
type State = {
mounted: boolean;
Expand Down
Loading
Loading