Skip to content

Commit

Permalink
chore(eslint): Enable eslint rules that overlap with biome (#83694)
Browse files Browse the repository at this point in the history
A little followup to #83693

This enables 3 rules from biome that are implemented in eslint as part
of this plugin.

This plugin has a lot of rules, the recommended set is too opinionated,
but a handful would be nice to enable inside sentry. I'll make a list
with TODO comments as a followup, and then work against that list rule
by rule in followup PRs. For now we just need to pluck these three rules
to match what's already happening.
  • Loading branch information
ryan953 authored Jan 21, 2025
1 parent 1c1c7c9 commit 0b216d7
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 22 deletions.
22 changes: 17 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import simpleImportSort from 'eslint-plugin-simple-import-sort';
import testingLibrary from 'eslint-plugin-testing-library';
// @ts-expect-error TS (7016): Could not find a declaration file
import typescriptSortKeys from 'eslint-plugin-typescript-sort-keys';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import invariant from 'invariant';
// biome-ignore lint/correctness/noNodejsModules: Need to get the list of things!
Expand Down Expand Up @@ -497,13 +498,13 @@ export default typescript.config([
{
groups: [
// Side effect imports.
['^\\u0000'],
[String.raw`^\u0000`],

// Node.js builtins.
[`^(${builtinModules.join('|')})(/|$)`],

// Packages. `react` related packages come first.
['^react', '^@?\\w'],
['^react', String.raw`^@?\w`],

// Test should be separate from the app
['^(sentry-test|getsentry-test)(/.*|$)'],
Expand All @@ -519,13 +520,13 @@ export default typescript.config([
['^(admin|getsentry)(/.*|$)'],

// Style imports.
['^.+\\.less$'],
[String.raw`^.+\.less$`],

// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
[String.raw`^\.\.(?!/?$)`, String.raw`^\.\./?$`],

// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
[String.raw`^\./(?=.*/)(?!/?$)`, String.raw`^\.(?!/?$)`, String.raw`^\./?$`],
],
},
],
Expand Down Expand Up @@ -554,6 +555,17 @@ export default typescript.config([
'@emotion/syntax-preference': ['error', 'string'],
},
},
{
name: 'plugin/unicorn',
plugins: {unicorn},
rules: {
// The recommended rules are very opinionated. We don't need to enable them.

'unicorn/no-instanceof-array': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-node-protocol': 'error',
},
},
{
name: 'plugin/jest',
files: ['**/*.spec.{ts,js,tsx,jsx}', 'tests/js/**/*.{ts,js,tsx,jsx}'],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-testing-library": "^7.1.1",
"eslint-plugin-typescript-sort-keys": "^3.3.0",
"eslint-plugin-unicorn": "^56.0.1",
"globals": "^15.14.0",
"html-webpack-plugin": "^5.6.0",
"jest": "29.7.0",
Expand Down
Loading

0 comments on commit 0b216d7

Please sign in to comment.