Skip to content

Commit

Permalink
eslint updates (#2001)
Browse files Browse the repository at this point in the history
* adds eslint web,native,node

* adds updates

* adds core

* test

* adds tsconifg

* update yarn

* adds root:true
  • Loading branch information
peterpme authored Jan 3, 2023
1 parent 27f7f56 commit ff66919
Show file tree
Hide file tree
Showing 21 changed files with 1,476 additions and 1,834 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/node_modules/**
**/dist/**
**/build/**
**/dev/**

**/.expo/**
**/.next/**
**/__generated__/**
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
ignorePatterns: ["**/*.js"],
project: ["./tsconfig.eslint.json", "./packages/*/tsconfig.json"],
};
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@
"build:ext": "env-cmd turbo run build --filter=@coral-xyz/app-extension...",
"start:mobile": "env-cmd --silent turbo run start --filter=@coral-xyz/app-mobile... --filter=@coral-xyz/background...",
"build:mobile": "env-cmd --silent turbo run build --filter=@coral-xyz/app-mobile... --filter=@coral-xyz/background...",
"postinstall": "yarn-deduplicate --scopes @babel @mui @typescript-eslint @types @react-native-community @react-navigation"
"postinstall": "yarn-deduplicate --scopes @babel @mui @typescript-eslint @types @react-native-community @react-navigation @emotion"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"env-cmd": "^10.1.0",
"eslint": "^8.20.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-react": "^7.30.1",
"eslint": "^8.31.0",
"husky": "^8.0.1",
"lint-staged": "^12.4.1",
"prettier": "^2.8.1",
Expand Down
6 changes: 1 addition & 5 deletions packages/app-mobile/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
module.exports = {
root: true,
extends: ["custom"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
extends: ["custom/native"],
};
2 changes: 1 addition & 1 deletion packages/app-mobile/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "expo/tsconfig.base",
"include": ["src", "./.eslintrc.js"],
"include": ["src"],
"exclude": ["**/node_modules", "**/.*/"],
"compilerOptions": {
"strict": true,
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-custom/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/__tests__/fixtures/*
5 changes: 5 additions & 0 deletions packages/eslint-config-custom/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
root: true,
extends: "./node.js",
settings: { react: { version: "1000.0.0" } },
};
2 changes: 0 additions & 2 deletions packages/eslint-config-custom/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const [IGNORE, WARNING, ERROR] = [0, 1, 2];

module.exports = {
root: true,
extends: [
Expand Down
55 changes: 55 additions & 0 deletions packages/eslint-config-custom/native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const {
jsExtensions,
tsExtensions,
platformSubextensions,
computeExpoExtensions,
} = require("./shared/extensions");

const allExtensions = computeExpoExtensions(
[...jsExtensions, ...tsExtensions],
platformSubextensions
);

module.exports = {
extends: [
"./index.js",
// './shared/core.js',
"./shared/typescript.js",
"./shared/react.js",
],
globals: {
__DEV__: false,
Atomics: false,
ErrorUtils: false,
FormData: false,
SharedArrayBuffer: false,
XMLHttpRequest: false,
alert: false,
cancelAnimationFrame: false,
cancelIdleCallback: false,
clearImmediate: false,
clearInterval: false,
clearTimeout: false,
fetch: false,
navigator: false,
process: false,
requestAnimationFrame: false,
requestIdleCallback: false,
setImmediate: false,
setInterval: false,
setTimeout: false,
window: false,
},
settings: {
"import/extensions": allExtensions,
"import/resolver": {
node: { extensions: allExtensions },
},
},
overrides: [
{
files: ["*.web.*"],
env: { browser: true },
},
],
};
9 changes: 9 additions & 0 deletions packages/eslint-config-custom/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
extends: ["./shared/core.js", "./shared/typescript.js"],
plugins: ["node"],
env: { node: true },
rules: {
"no-buffer-constructor": "warn",
"node/no-path-concat": "warn",
},
};
44 changes: 36 additions & 8 deletions packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
{
"name": "eslint-config-custom",
"version": "0.0.1",
"description": "Shared ESLINT config for universl Backpack projects across web, native and node",
"version": "1.0.0",
"main": "index.js",
"private": true,
"scripts": {
"lint": "eslint .",
"test": "jest"
},
"jest": {
"testMatch": [
"**/__tests__/*-test.js"
]
},
"eslintIgnore": [
"/__tests__/fixtures/*"
],
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"eslint": "latest",
"eslint-config-next": "latest",
"eslint-config-prettier": "latest",
"eslint-config-turbo": "latest",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"eslint-config-next": "^13.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-config-turbo": "^0.0.7",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mui-unused-classes": "^1.0.3",
"eslint-plugin-react": "latest",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-workspaces": "^0.7.0"
},
"peerDependencies": {
"eslint": ">=8.18",
"prettier": ">=2.7"
},
"peerDependenciesMeta": {
"prettier": {
"optional": true
}
},
"devDependencies": {
"eslint": "^8.31.0",
"jest": "^27.5.1",
"prettier": "^2.8.1"
}
}
30 changes: 30 additions & 0 deletions packages/eslint-config-custom/shared/__tests__/extensions-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// https://github.com/expo/expo/blob/main/packages/eslint-config-universe/shared/__tests__/extensions-test.js
const {
jsExtensions,
platformSubextensions,
computeExpoExtensions,
} = require("../extensions");

it(`orders more specific platform subextensions first`, () => {
const androidIndex = platformSubextensions.indexOf(".android");
const iosIndex = platformSubextensions.indexOf(".ios");
const nativeIndex = platformSubextensions.indexOf(".native");

expect(androidIndex).toBeGreaterThanOrEqual(0);
expect(iosIndex).toBeGreaterThanOrEqual(0);
expect(nativeIndex).toBeGreaterThanOrEqual(0);

expect(androidIndex).toBeLessThan(nativeIndex);
expect(iosIndex).toBeLessThan(nativeIndex);
});

it(`orders Expo-specific extensions first`, () => {
const extensions = computeExpoExtensions(jsExtensions, platformSubextensions);
const jsIndex = extensions.indexOf(".js");
const expoJsIndex = extensions.indexOf(".expo.js");

expect(jsIndex).toBeGreaterThanOrEqual(0);
expect(expoJsIndex).toBeGreaterThanOrEqual(0);

expect(expoJsIndex).toBeLessThan(jsIndex);
});
Loading

1 comment on commit ff66919

@vercel
Copy link

@vercel vercel bot commented on ff66919 Jan 3, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.