Skip to content

Commit

Permalink
fix: re-add compat rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed May 17, 2024
1 parent 46305d3 commit 0ccbb1d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 38 deletions.
2 changes: 1 addition & 1 deletion configurations/auto.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = [
require('./canonical').recommended,
require('./typescript').recommended,
require('./canonical').recommended,
require('./typescript-compatibility').recommended,
require('./regexp').recommended,
require('./jsdoc').recommended,
Expand Down
17 changes: 1 addition & 16 deletions configurations/canonical.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,7 @@ const unicornRules = {
};

module.exports.recommended = {
languageOptions: {
parser: require('@babel/eslint-parser'),
parserOptions: {
babelOptions: {
plugins: ['@babel/plugin-syntax-import-assertions'],
},
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
jsx: true,
},
ecmaVersion: 2_021,
requireConfigFile: false,
sourceType: 'module',
},
},
files: ['**/*.{js,jsx,cjs,mjs,ts,tsx}'],
plugins: {
'@babel': require('@babel/eslint-plugin'),
canonical: require('eslint-plugin-canonical'),
Expand Down
2 changes: 1 addition & 1 deletion configurations/graphql.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.recommended = {
files: ['*.graphql'],
files: ['**/*.graphql'],
languageOptions: {
parser: require('@graphql-eslint/eslint-plugin'),
},
Expand Down
1 change: 1 addition & 0 deletions configurations/jsdoc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports.recommended = {
files: ['**/*.{js,jsx,cjs,mjs,ts,tsx}'],
plugins: {
jsdoc: require('eslint-plugin-jsdoc'),
},
Expand Down
2 changes: 1 addition & 1 deletion configurations/json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.recommended = {
files: ['*.json'],
files: ['**/*.json'],
languageOptions: {
parser: require('eslint-plugin-jsonc'),
},
Expand Down
2 changes: 2 additions & 0 deletions configurations/prettier.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module.exports.recommended = {
files: ['**/*.{js,jsx,cjs,mjs,ts,tsx}'],
plugins: {
prettier: require('eslint-plugin-prettier'),
},
rules: {
...require('eslint-config-prettier').rules,
'@babel/object-curly-spacing': 0,
'@typescript-eslint/indent': 0,
'array-bracket-newline': 0,
Expand Down
17 changes: 9 additions & 8 deletions configurations/react.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports.recommended = {
files: ['**/*.tsx'],
plugins: {
canonical: require('eslint-plugin-canonical'),
react: require('eslint-plugin-react'),
Expand Down Expand Up @@ -50,7 +51,7 @@ module.exports.recommended = {
'react/jsx-equals-spacing': [2, 'never'],
'react/jsx-filename-extension': 0,
'react/jsx-first-prop-new-line': [2, 'multiline-multiprop'],
'react/jsx-fragments': [2, 'syntax'],
// 'react/jsx-fragments': [2, 'syntax'],
'react/jsx-handler-names': [
2,
{
Expand Down Expand Up @@ -99,7 +100,7 @@ module.exports.recommended = {
'react/jsx-no-literals': 0,
'react/jsx-no-script-url': 2,
'react/jsx-no-target-blank': 2,
'react/jsx-no-undef': 2,
// 'react/jsx-no-undef': 2,
'react/jsx-no-useless-fragment': [
2,
{
Expand Down Expand Up @@ -142,8 +143,8 @@ module.exports.recommended = {
closingSlash: 'never',
},
],
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
// 'react/jsx-uses-react': 2,
// 'react/jsx-uses-vars': 2,
'react/jsx-wrap-multilines': 0,
// TODO broke after upgrading to ESLint v9
// 'react/no-access-state-in-setstate': 2,
Expand All @@ -153,7 +154,7 @@ module.exports.recommended = {
// 'react/no-arrow-function-lifecycle': 2,
// 'react/no-children-prop': 2,
'react/no-danger': 2,
'react/no-danger-with-children': 2,
// 'react/no-danger-with-children': 2,
'react/no-deprecated': 2,
'react/no-did-mount-set-state': 2,
'react/no-did-update-set-state': 2,
Expand All @@ -163,7 +164,7 @@ module.exports.recommended = {
'react/no-invalid-html-attribute': 2,
'react/no-is-mounted': 2,
'react/no-multi-comp': 0,
'react/no-namespace': 2,
// 'react/no-namespace': 2,
'react/no-redundant-should-component-update': 2,
'react/no-render-return-value': 2,
// TODO broke after upgrading to ESLint v9
Expand Down Expand Up @@ -205,8 +206,8 @@ module.exports.recommended = {
'react/state-in-constructor': [2, 'always'],
// TODO broke after upgrading to ESLint v9
// 'react/static-property-placement': 2,
'react/style-prop-object': 2,
'react/void-dom-elements-no-children': 2,
// 'react/style-prop-object': 2,
// 'react/void-dom-elements-no-children': 2,
'react-hooks/exhaustive-deps': 2,
'react-hooks/rules-of-hooks': 2,
},
Expand Down
1 change: 1 addition & 0 deletions configurations/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts
*/
module.exports.recommended = {
files: ['**/*.{js,jsx,cjs,mjs,ts,tsx}'],
plugins: {
regexp: require('eslint-plugin-regexp'),
},
Expand Down
2 changes: 1 addition & 1 deletion configurations/typescript-compatibility.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.recommended = {
files: ['*.ts', '*.tsx'],
files: ['*.{ts,tsx}'],
rules: {
'@babel/no-unused-expressions': 0,
'@typescript-eslint/brace-style': [
Expand Down
16 changes: 7 additions & 9 deletions configurations/typescript.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Omit `.d.ts` because 1) TypeScript compilation already confirms that
// types are resolved, and 2) it would mask an unresolved

// `.ts`/`.tsx`/`.js`/`.jsx` implementation.
const typescriptExtensions = ['.ts', '.tsx', '.js', '.jsx'];

// TODO add .d.ts files
// {
// files: ['*.d.ts'],
Expand All @@ -17,12 +11,16 @@ const typescriptExtensions = ['.ts', '.tsx', '.js', '.jsx'];
// }

module.exports.recommended = {
files: ['*.ts', '*.tsx'],
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
project: true,
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
canonical: require('eslint-plugin-canonical'),
'typescript-sort-keys': require('eslint-plugin-typescript-sort-keys'),
},
rules: {
Expand Down Expand Up @@ -202,14 +200,14 @@ module.exports.recommended = {
'typescript-sort-keys/string-enum': 2,
},
settings: {
'import/extensions': typescriptExtensions,
'import/extensions': ['.ts', '.tsx'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
extensions: typescriptExtensions,
extensions: ['.ts', '.tsx'],
},
},
jsdoc: {
Expand Down
2 changes: 1 addition & 1 deletion configurations/yaml.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.recommended = {
files: ['*.yaml'],
files: ['**/*.yaml'],
languageOptions: {
parser: require('yaml-eslint-parser'),
},
Expand Down

0 comments on commit 0ccbb1d

Please sign in to comment.