1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Opt-in root javascript files to Prettier

This commit is contained in:
Nick Schonning 2024-02-28 17:17:29 -05:00
parent 06f070d86d
commit 5960b552fa
No known key found for this signature in database
GPG key ID: 5DDAAD9C9AAFFD9F
6 changed files with 75 additions and 83 deletions

View file

@ -48,10 +48,7 @@ module.exports = defineConfig({
react: {
version: 'detect',
},
'import/ignore': [
'node_modules',
'\\.(css|scss|json)$',
],
'import/ignore': ['node_modules', '\\.(css|scss|json)$'],
'import/resolver': {
typescript: {},
},
@ -60,22 +57,19 @@ module.exports = defineConfig({
rules: {
'consistent-return': 'error',
'dot-notation': 'error',
eqeqeq: ['error', 'always', { 'null': 'ignore' }],
'indent': ['error', 2],
eqeqeq: ['error', 'always', { null: 'ignore' }],
indent: ['error', 2],
'jsx-quotes': ['error', 'prefer-single'],
'semi': ['error', 'always'],
semi: ['error', 'always'],
'no-case-declarations': 'off',
'no-catch-shadow': 'error',
'no-console': [
'warn',
{
allow: [
'error',
'warn',
],
allow: ['error', 'warn'],
},
],
'no-empty': ['error', { "allowEmptyCatch": true }],
'no-empty': ['error', { allowEmptyCatch: true }],
'no-restricted-properties': [
'error',
{ property: 'substring', message: 'Use .slice instead of .substring.' },
@ -145,9 +139,7 @@ module.exports = defineConfig({
'jsx-a11y/no-static-element-interactions': [
'warn',
{
handlers: [
'onClick',
],
handlers: ['onClick'],
},
],
@ -220,7 +212,8 @@ module.exports = defineConfig({
},
// Immutable / Redux / data store
{
pattern: '{immutable,@reduxjs/toolkit,react-redux,react-immutable-proptypes,react-immutable-pure-component}',
pattern:
'{immutable,@reduxjs/toolkit,react-redux,react-immutable-proptypes,react-immutable-pure-component}',
group: 'external',
position: 'before',
},
@ -297,10 +290,7 @@ module.exports = defineConfig({
},
},
{
files: [
'**/*.ts',
'**/*.tsx',
],
files: ['**/*.ts', '**/*.tsx'],
extends: [
'eslint:recommended',
@ -322,7 +312,7 @@ module.exports = defineConfig({
rules: {
// Disable formatting rules that have been enabled in the base config
'indent': 'off',
indent: 'off',
// This is not needed as we use noImplicitReturns, which handles this in addition to understanding types
'consistent-return': 'off',
@ -332,37 +322,44 @@ module.exports = defineConfig({
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
"@typescript-eslint/prefer-nullish-coalescing": ['error', { ignorePrimitives: { boolean: true } }],
"@typescript-eslint/no-restricted-imports": [
"warn",
{
"name": "react-redux",
"importNames": ["useSelector", "useDispatch"],
"message": "Use typed hooks `useAppDispatch` and `useAppSelector` instead."
}
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{ ignorePrimitives: { boolean: true } },
],
'@typescript-eslint/no-restricted-imports': [
'warn',
{
name: 'react-redux',
importNames: ['useSelector', 'useDispatch'],
message:
'Use typed hooks `useAppDispatch` and `useAppSelector` instead.',
},
],
'@typescript-eslint/restrict-template-expressions': [
'warn',
{ allowNumber: true },
],
"@typescript-eslint/restrict-template-expressions": ['warn', { allowNumber: true }],
'jsdoc/require-jsdoc': 'off',
// Those rules set stricter rules for TS files
// to enforce better practices when converting from JS
'import/no-default-export': 'warn',
'react/prefer-stateless-function': 'warn',
'react/function-component-definition': ['error', { namedComponents: 'arrow-function' }],
'react/function-component-definition': [
'error',
{ namedComponents: 'arrow-function' },
],
'react/jsx-uses-react': 'off', // not needed with new JSX transform
'react/react-in-jsx-scope': 'off', // not needed with new JSX transform
'react/prop-types': 'off',
},
},
{
files: [
'**/__tests__/*.js',
'**/__tests__/*.jsx',
],
files: ['**/__tests__/*.js', '**/__tests__/*.jsx'],
env: {
jest: true,
},
}
},
],
});

View file

@ -82,4 +82,4 @@ app/javascript/styles/mastodon/reset.scss
AUTHORS.md
# Process a few selected JS files
!lint-staged.config.js
!/*.js

View file

@ -1,4 +1,4 @@
module.exports = {
singleQuote: true,
jsxSingleQuote: true
}
jsxSingleQuote: true,
};

View file

@ -1,3 +1,4 @@
/* eslint-disable indent */
module.exports = (api) => {
const env = api.env();
@ -7,8 +8,8 @@ module.exports = (api) => {
};
const envOptions = {
useBuiltIns: "usage",
corejs: { version: "3.30" },
useBuiltIns: 'usage',
corejs: { version: '3.30' },
debug: false,
include: [
'transform-numeric-separator',
@ -18,23 +19,19 @@ module.exports = (api) => {
],
};
const plugins = [
['formatjs'],
'preval',
];
const plugins = [['formatjs'], 'preval'];
switch (env) {
case 'production':
plugins.push(...[
plugins.push(
...[
'lodash',
[
'transform-react-remove-prop-types',
{
mode: 'remove',
removeImport: true,
additionalLibraries: [
'react-immutable-proptypes',
],
additionalLibraries: ['react-immutable-proptypes'],
},
],
'@babel/transform-react-inline-elements',
@ -46,7 +43,8 @@ module.exports = (api) => {
useESModules: true,
},
],
]);
],
);
break;
case 'development':
@ -69,9 +67,7 @@ module.exports = (api) => {
overrides: [
{
test: [/tesseract\.js/, /fuzzysort\.js/],
presets: [
['@babel/env', { ...envOptions, modules: 'commonjs' }],
],
presets: [['@babel/env', { ...envOptions, modules: 'commonjs' }]],
},
],
};

View file

@ -6,7 +6,7 @@ jetbrains://WebStorm/settings?name=Languages+%26+Frameworks--JavaScript--Webpack
module.exports = {
resolve: {
alias: {
'mastodon': path.resolve(__dirname, 'app/javascript/mastodon'),
mastodon: path.resolve(__dirname, 'app/javascript/mastodon'),
},
},
};

View file

@ -31,14 +31,13 @@ module.exports = {
},
overrides: [
{
'files': ['app/javascript/styles/mailer.scss'],
files: ['app/javascript/styles/mailer.scss'],
rules: {
'property-no-unknown': [
true,
{
ignoreProperties: [
'/^mso-/',
] },
ignoreProperties: ['/^mso-/'],
},
],
},
},