Skip to content

Commit

Permalink
⬆️ (repo): Bump eslint to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Jun 12, 2024
1 parent d57b00c commit 0caeb92
Show file tree
Hide file tree
Showing 40 changed files with 1,163 additions and 2,345 deletions.
22 changes: 0 additions & 22 deletions apps/sample/.eslintrc.js

This file was deleted.

38 changes: 38 additions & 0 deletions apps/sample/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import baseConfig from "@ledgerhq/eslint-config-dsdk";
import globals from "globals";

export default [
...baseConfig,
{
ignores: [".next"],
},
{
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
},
},
},
{
files: [
"src/app/page.tsx",
"src/app/global-error.tsx",
"src/app/client-layout.tsx",
"src/app/**/page.tsx",
],
rules: {
"no-restricted-syntax": 0,
},
},
{
files: ["next.config.js", "postcss.config.js"],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
"@typescript-eslint/no-var-requires": "off",
},
},
];
14 changes: 7 additions & 7 deletions apps/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:fix": "next lint --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"prettier": "prettier . --check",
"prettier:fix": "prettier . --write",
"typecheck": "tsc --noEmit"
Expand All @@ -16,19 +16,19 @@
"@ledgerhq/device-sdk-core": "workspace:*",
"@ledgerhq/react-ui": "^0.14.16",
"@sentry/nextjs": "^7.109.0",
"next": "14.1.4",
"react": "^18",
"react-dom": "^18",
"next": "14.2.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"styled-components": "^5.3.11"
},
"devDependencies": {
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/prettier-config-dsdk": "workspace:*",
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@types/react": "^18.2.75",
"@types/react": "^18.3.3",
"@types/styled-components": "^5.1.25",
"autoprefixer": "^10.4.19",
"eslint-config-next": "14.1.4",
"globals": "15.4.0",
"postcss": "^8.4.38"
}
}
1 change: 0 additions & 1 deletion apps/sample/src/app/client-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ const ClientRootLayout: React.FC<ClientRootLayoutProps> = ({ children }) => {
);
};

// eslint-disable-next-line no-restricted-syntax
export default ClientRootLayout;
1 change: 0 additions & 1 deletion apps/sample/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ const RootLayout: React.FC<RootLayoutProps> = ({ children }) => {
);
};

// eslint-disable-next-line no-restricted-syntax
export default RootLayout;
1 change: 0 additions & 1 deletion apps/sample/src/components/ApduView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const ApduView: React.FC = () => {
let rawApduResponse;
try {
rawApduResponse = await sdk.sendApdu({
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
sessionId: selectedSessionId ?? "",
apdu: getRawApdu(values),
});
Expand Down
1 change: 0 additions & 1 deletion apps/sample/src/hooks/useDeviceSessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function useDeviceSessionState(sessionId: DeviceSessionId) {
sessionId,
})
.subscribe((state) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
setDeviceSessionState(state);
});

Expand Down
11 changes: 11 additions & 0 deletions apps/sample/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"include": [
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"eslint.config.mjs",
"next.config.js",
"postcss.config.js"
]
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@changesets/cli": "^2.27.5",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"concurrently": "^8.2.2",
"danger": "^11.3.1",
"eslint": "^8.57.0",
"eslint": "9.4.0",
"gitmoji-cli": "^9.2.0",
"hygen": "^6.2.11",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"tsc-alias": "^1.8.8",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.4",
"tsc-alias": "^1.8.10",
"turbo": "^1.13.2",
"typescript": "^5.4.4",
"zx": "^8.0.1"
"typescript": "^5.4.5",
"zx": "^8.1.2"
},
"engines": {
"node": ">=18"
Expand Down
202 changes: 113 additions & 89 deletions packages/config/eslint/index.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,119 @@
const { resolve } = require("node:path");
// @ts-check

const project = resolve(process.cwd(), "tsconfig.json");
import globals from "globals";
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
plugins: ["no-type-assertion", "simple-import-sort"],
globals: {
React: true,
JSX: true,
node: true,
console: true,
export default [
{
ignores: [
".*.js",
"coverage/*",
"_templates/*",
"lib/*",
"dist/*",
"node_modules/*",
],
},
parserOptions: {
ecmaVersion: "latest",
},
env: {
es6: true,
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
"lib/",
],
overrides: [
{
files: ["**/*.{ts,tsx}"],
parser: "@typescript-eslint/parser",
extends: [
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"prettier",
],
rules: {
"import/prefer-default-export": "off",
"no-restricted-syntax": [
"error",
{
selector: "ExportDefaultDeclaration",
message: "Prefer named exports",
},
],
"no-void": "off",
"no-restricted-imports": [
"error",
{
patterns: ["../*"],
},
],
"simple-import-sort/imports": [
"error",
{
groups: [
// Side effect imports.
["^\\u0000"],
// Node.js builtins prefixed with `node:`.
["^node:"],
// Packages. `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@|@api|@internal|@root)(/.*|$)"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"],
],
},
],
"simple-import-sort/exports": "error",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
"no-type-assertion/no-type-assertion": "error",

// Base JS config
js.configs.recommended,

// Base TS config
...tseslint.configs.recommended,

// Prettier recommended
eslintPluginPrettierRecommended,

// MJS files in scripts folder (have access to ZX globals)
{
files: ["**/*.mjs"],
languageOptions: {
globals: {
...globals.node,
log: true,
$: true,
argv: true,
cd: true,
chalk: true,
echo: true,
expBackoff: true,
fs: true,
glob: true,
globby: true,
nothrow: true,
os: true,
path: true,
question: true,
quiet: true,
quote: true,
quotePowerShell: true,
retry: true,
sleep: true,
spinner: true,
ssh: true,
stdin: true,
which: true,
within: true,
},
},
{
files: ["**/*.test.ts", "**/*.stub.ts"],
rules: {
"no-type-assertion/no-type-assertion": "off",
},
},

{
files: ["**/*.ts"],
plugins: {
"simple-import-sort": simpleImportSort,
},
rules: {
"import/prefer-default-export": "off",
"no-restricted-syntax": [
"error",
{
selector: "ExportDefaultDeclaration",
message: "Prefer named exports",
},
],
"no-void": "off",
"no-restricted-imports": [
"error",
{
patterns: ["../*"],
},
],
"simple-import-sort/imports": [
"error",
{
groups: [
// Side effect imports.
["^\\u0000"],
// Node.js builtins prefixed with `node:`.
["^node:"],
// Packages. `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@|@api|@internal|@root)(/.*|$)"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"],
],
},
],
"simple-import-sort/exports": "error",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
},
],
};
},
];
Loading

0 comments on commit 0caeb92

Please sign in to comment.