Skip to content

Commit

Permalink
Merge pull request #42 from matrix-org/t3chguy/stylistic
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 16, 2024
2 parents ed95b4f + 022f986 commit 4ce550d
Show file tree
Hide file tree
Showing 4 changed files with 2,521 additions and 26 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@babel/core": "*",
"@babel/eslint-parser": "*",
"@babel/eslint-plugin": "*",
"@typescript-eslint/eslint-plugin": "*",
"@stylistic/eslint-plugin": "*",
"@typescript-eslint/parser": "*",
"eslint": "*",
"eslint-config-google": "*",
Expand All @@ -28,7 +28,6 @@
"eslint-plugin-import": "*",
"eslint-plugin-jest": "*",
"eslint-plugin-jsx-a11y": "*",
"eslint-plugin-react": "*",
"eslint-plugin-react-hooks": "*",
"eslint-plugin-unicorn": "*",
"prettier": "*",
Expand Down
27 changes: 14 additions & 13 deletions react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module.exports = {
plugins: [
"deprecate",
"matrix-org",
"react",
"@stylistic",
"react-hooks",
],
extends: [
"prettier",
"plugin:@stylistic/disable-legacy",
],
parserOptions: {
ecmaFeatures: {
Expand All @@ -19,35 +20,35 @@ module.exports = {

// This just uses the React plugin to help ESLint known when
// variables have been used in JSX
"react/jsx-uses-vars": ["error"],
"@stylistic/jsx-uses-vars": ["error"],
// Don't mark React as unused if we're using JSX
"react/jsx-uses-react": ["error"],
"@stylistic/jsx-uses-react": ["error"],

// Components in JSX should always be defined
"react/jsx-no-undef": ["error"],
"@stylistic/jsx-no-undef": ["error"],

// Assert spacing before self-closing JSX tags, and no spacing before
// or after the closing slash, and no spacing after the opening
// bracket of the opening tag or closing tag.
// https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/jsx-tag-spacing.md
"react/jsx-tag-spacing": ["error", {
"@stylistic/jsx-tag-spacing": ["error", {
beforeClosing: "never",
}],

"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
"@stylistic/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],

"react/jsx-curly-brace-presence": ["error", "never"],
"@stylistic/jsx-curly-brace-presence": ["error", "never"],

"react/jsx-equals-spacing": ["error", "never"],
"@stylistic/jsx-equals-spacing": ["error", "never"],

"react/no-direct-mutation-state": ["error"],
"react/no-this-in-sfc": ["error"],
"react/self-closing-comp": ["error"],
"react/jsx-max-props-per-line": ["error", { "when": "multiline" }],
"@stylistic/no-direct-mutation-state": ["error"],
"@stylistic/no-this-in-sfc": ["error"],
"@stylistic/self-closing-comp": ["error"],
"@stylistic/jsx-max-props-per-line": ["error", { "when": "multiline" }],

"react-hooks/rules-of-hooks": ["error"],
"react-hooks/exhaustive-deps": ["error"],
"react/no-unknown-property": ["error"],
"@stylistic/no-unknown-property": ["error"],

"deprecate/import": [
"error",
Expand Down
23 changes: 12 additions & 11 deletions typescript.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
module.exports = {
plugins: [
"@typescript-eslint",
"@stylistic",
"matrix-org",
],
extends: [
"plugin:matrix-org/javascript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@stylistic/disable-legacy",
],
parser: "@typescript-eslint/parser",
rules: {
// Allow the use of underscore to show args are not used.
// This is helpful for seeing that a function implements
// an interface but won't be using one of it's arguments.
"@typescript-eslint/no-unused-vars": ["error", { "args": "none", "ignoreRestSiblings": true }],
"@typescript-eslint/no-empty-function": ["off"],
"@stylistic/no-empty-function": ["off"],

"@typescript-eslint/explicit-module-boundary-types": ["off"],
"@typescript-eslint/ban-types": ["off"],
"@stylistic/explicit-module-boundary-types": ["off"],
"@stylistic/ban-types": ["off"],

// We use IProps and IState
"@typescript-eslint/interface-name-prefix": ["off"],
"@stylistic/interface-name-prefix": ["off"],

// We rely on prettier for this
"@stylistic/func-call-spacing": ["off"],

// Require spaces after colons and around arrows
"@typescript-eslint/type-annotation-spacing": ["error"],
"@stylistic/type-annotation-spacing": ["error"],

// `typescript-eslint` has a rule for semis which conflicts with the
// original ESLint core rule.
"semi": ["off"],
"@typescript-eslint/semi": ["error"],
"@stylistic/semi": ["error"],

// Similarly, enforce semicolons between members (ie. in types / interfaces)
"@typescript-eslint/member-delimiter-style": ["error", {
"@stylistic/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "semi",
"requireLast": true,
Expand Down
Loading

0 comments on commit 4ce550d

Please sign in to comment.