Skip to content

Commit

Permalink
Prettier and backend fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Aug 11, 2022
1 parent 0ae14c0 commit cf49ddb
Show file tree
Hide file tree
Showing 1,307 changed files with 6,273 additions and 6,984 deletions.
33 changes: 26 additions & 7 deletions .eslintrc.back.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@ module.exports = {
strapi: false,
},
rules: {
'node/no-unpublished-require': 'off',
'no-process-exit': 'off',
'node/exports-style': ['error', 'module.exports'],
'node/no-new-require': 'error',
'node/no-path-concat': 'error',
'node/no-callback-literal': 'error',
'node/handle-callback-err': 'error',
'import/no-dynamic-require': 'off',
'global-require': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'packages/admin-test-utils/**/*.js',
'packages/generators/admin/**/*.js',
'scripts/**/*.js',
'**/test/**/*.js',
'**/tests/**/*.js',
'**/__tests__/**/*.js',
'**/__mocks__/**/*.js',
],
},
],
'prefer-destructuring': ['error', { AssignmentExpression: { array: false } }],
eqeqeq: 'warn',
'no-underscore-dangle': 'warn',
'no-use-before-define': 'warn',
'no-param-reassign': 'warn',
'no-continue': 'warn',
'no-process-exit': 'warn',
'no-plusplus': 'warn',
'no-loop-func': 'warn',
'guard-for-in': 'warn',
},
};
99 changes: 6 additions & 93 deletions .eslintrc.front.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
module.exports = {
parser: 'babel-eslint',
extends: [
'airbnb',
'eslint:recommended',
'plugin:react/recommended',
'plugin:redux-saga/recommended',
'prettier',
],
plugins: ['react', 'redux-saga', 'react-hooks', 'import', 'jsx-a11y'],
parser: '@babel/eslint-parser',
extends: ['@strapi/eslint-config/front'],
env: {
browser: true,
commonjs: true,
Expand All @@ -16,11 +9,10 @@ module.exports = {
mocha: true,
},
parserOptions: {
ecmaVersion: 2018,
ecmaFeatures: {
jsx: true,
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
sourceType: 'module',
},
globals: {
strapi: false,
Expand All @@ -39,86 +31,7 @@ module.exports = {
},
settings: {
react: {
version: '16.5.2',
version: 'detect',
},
},
rules: {
'import/no-unresolved': 0,
'generator-star-spacing': 0,
'no-console': 0,
'require-atomic-updates': 0,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'arrow-body-style': 0,
'arrow-parens': 0,
camelcase: 0,
'comma-dangle': 0,
'consistent-return': [
2,
{
treatUndefinedAsUnspecified: true,
},
],
'template-curly-spacing': 0,
'func-names': ['error', 'never'],
'function-paren-newline': 0,
'implicit-arrow-linebreak': 0,
'import/no-extraneous-dependencies': 0,
'import/no-named-as-default': 0,
'import/order': 2,
'import/prefer-default-export': 'off',
'jsx-a11y/click-events-have-key-events': 1,
'max-len': [
2,
{
code: 120,
ignoreComments: true,
ignoreUrls: true,
ignoreTrailingComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
'newline-before-return': 2,
'no-confusing-arrow': 0,
'no-else-return': 1,
'no-nested-ternary': ['error'],
'no-return-assign': 0,
'no-param-reassign': 0,
'no-plusplus': 0,
'no-shadow': 0,
'no-underscore-dangle': 0,
'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
'object-curly-newline': [2, { multiline: true, consistent: true }],
'one-var': ['error', 'never'],
'operator-linebreak': 0,
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'if' },
{ blankLine: 'any', prev: 'block-like', next: 'if' },
],
'prefer-arrow-callback': 0,
'prefer-const': 0,
'prefer-destructuring': 0,
'prefer-object-spread': 0,
'prefer-spread': 0,
'space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
'react/destructuring-assignment': 0,
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/forbid-prop-types': 0,
'react/no-unused-prop-types': 2,
'react/jsx-props-no-spreading': 0,
'react/jsx-one-expression-per-line': 0,
'react/state-in-constructor': 0,
'react/static-property-placement': 0,
'react/display-name': 0,
'react/jsx-wrap-multilines': 0,
},
};
2 changes: 1 addition & 1 deletion .github/actions/check-pr-status/__tests__/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock('@actions/core');
const github = require('@actions/github');
const core = require('@actions/core');

test.each(action.BLOCKING_LABELS)('Test blocking labels %s', async label => {
test.each(action.BLOCKING_LABELS)('Test blocking labels %s', async (label) => {
github.context = {
payload: {
pull_request: {
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/check-pr-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ async function main() {
try {
const labels = github.context.payload.pull_request?.labels ?? [];

const blockingLabels = labels.filter(label => BLOCKING_LABELS.includes(label.name));
const blockingLabels = labels.filter((label) => BLOCKING_LABELS.includes(label.name));

if (blockingLabels.length > 0) {
core.setFailed(
`The PR has been labelled with a blocking label (${blockingLabels
.map(label => label.name)
.map((label) => label.name)
.join(', ')}).`
);

return;
}

const sourceLabelCount = labels.filter(label => label.name.startsWith('source: ')).length;
const issueLabelCount = labels.filter(label => label.name.startsWith('pr: ')).length;
const sourceLabelCount = labels.filter((label) => label.name.startsWith('source: ')).length;
const issueLabelCount = labels.filter((label) => label.name.startsWith('pr: ')).length;

if (sourceLabelCount !== 1) {
core.setFailed(`The PR must have one and only one 'source:' label.`);
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
tabWidth: 2,
trailingComma: 'es5',
printWidth: 100,
arrowParens: 'always',
};
2 changes: 1 addition & 1 deletion examples/getstarted/config/src/response-handlers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = {
'404': async (/* ctx */) => {
404: async (/* ctx */) => {
// return ctx.notFound('My custom message 404');
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = options => {
module.exports = (options) => {
return (ctx, next) => {
ctx.set('X-Strapi-Test', 'Address Middleware');
return next();
Expand Down
2 changes: 1 addition & 1 deletion examples/getstarted/src/api/address/services/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = createCoreService('api::address.address', {
async find(...args) {
const { results, pagination } = await super.find(...args);

results.forEach(result => {
results.forEach((result) => {
result.counter = 1;
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = plugin => {
module.exports = (plugin) => {
return plugin;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
bootstrap() {},
async registerTrads({ locales }) {
const importedTrads = await Promise.all(
locales.map(locale => {
locales.map((locale) => {
return import(
/* webpackChunkName: "[pluginId]-[request]" */ `./translations/${locale}.json`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pluginId from '../pluginId';

const getTrad = id => `${pluginId}.${id}`;
const getTrad = (id) => `${pluginId}.${id}`;

export default getTrad;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
default: {
testConf: 1,
},
validator: config => {
validator: (config) => {
if (typeof config.testConf !== 'number') {
throw new Error('testConfig has to be a number');
}
Expand Down
8 changes: 3 additions & 5 deletions examples/kitchensink/src/admin/app.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import theme from './extensions/theme';

const config = {
auth: {
logo:
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
logo: 'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
},
head: {
favicon:
Expand All @@ -12,8 +11,7 @@ const config = {
},
locales: ['fr', 'de'],
menu: {
logo:
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
logo: 'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
},
theme,
translations: {
Expand All @@ -29,7 +27,7 @@ const config = {
notifications: { release: false },
};

const bootstrap = app => {
const bootstrap = (app) => {
console.log(app);
};

Expand Down
8 changes: 3 additions & 5 deletions examples/kitchensink/src/admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import theme from './extensions/theme';

const config = {
auth: {
logo:
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
logo: 'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
},
head: {
favicon:
Expand All @@ -12,8 +11,7 @@ const config = {
},
locales: ['fr', 'de'],
menu: {
logo:
'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
logo: 'https://images.unsplash.com/photo-1593642634367-d91a135587b5?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80',
},
theme,
translations: {
Expand All @@ -29,7 +27,7 @@ const config = {
notifications: { release: false },
};

const bootstrap = app => {
const bootstrap = (app) => {
console.log(app);
};

Expand Down
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
"@babel/polyfill": "7.12.1"
},
"devDependencies": {
"@babel/core": "7.18.10",
"@babel/eslint-parser": "7.18.9",
"@babel/preset-react": "7.18.6",
"@strapi/eslint-config": "0.1.0",
"@swc/core": "1.2.224",
"@swc/jest": "0.2.22",
Expand All @@ -84,20 +87,12 @@
"cross-env": "7.0.3",
"dotenv": "14.2.0",
"eslint": "8.21.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsdoc": "36.1.1",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-react": "7.30.1",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-redux-saga": "1.3.2",
"execa": "1.0.0",
"fs-extra": "10.1.0",
"get-port": "5.1.1",
"glob": "7.2.3",
"husky": "3.1.0",
"inquirer": "8.2.4",
"istanbul": "~0.4.2",
"jest": "26.6.3",
"jest-circus": "26.6.3",
Expand All @@ -110,7 +105,7 @@
"npm-run-all": "4.1.5",
"nx": "14.4.2",
"plop": "2.7.6",
"prettier": "1.19.1",
"prettier": "2.7.1",
"qs": "6.11.0",
"react-test-renderer": "17.0.2",
"request": "2.88.2",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-test-utils/lib/fixtures/store/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

// eslint-disable-next-line node/no-extraneous-require
const { combineReducers, createStore } = require('redux');

const reducers = {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-test-utils/lib/setup/strapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ global.strapi = {

global.prompt = jest.fn();

global.URL.createObjectURL = file => `http://localhost:4000/assets/${file.name}`;
global.URL.createObjectURL = (file) => `http://localhost:4000/assets/${file.name}`;
1 change: 0 additions & 1 deletion packages/admin-test-utils/lib/setup/test-bundler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

// needed for regenerator-runtime
// (ES7 generator support is required by redux-saga)
require('@babel/polyfill');

const noop = () => {};
Expand Down
3 changes: 3 additions & 0 deletions packages/admin-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"@testing-library/jest-dom": "5.16.5",
"jest-styled-components": "7.0.2"
},
"peerDependencies": {
"redux": "^4.0.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/create-strapi-app/create-strapi-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ program
.option('--template <templateurl>', 'Specify a Strapi template')
.option('--ts, --typescript', 'Use TypeScript to generate the project')
.description('create a new application')
.action(directory => {
.action((directory) => {
initProject(directory, program);
})
.parse(process.argv);
Expand All @@ -62,7 +62,7 @@ async function initProject(projectName, program) {
await checkInstallPath(resolve(projectName));
}

const hasDatabaseOptions = databaseOptions.some(opt => program[opt]);
const hasDatabaseOptions = databaseOptions.some((opt) => program[opt]);

if (program.quickstart && hasDatabaseOptions) {
console.error(
Expand Down
Loading

0 comments on commit cf49ddb

Please sign in to comment.