Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend eslint-rules #986

Merged
merged 2 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@
"react/prop-types": 0,
"react/no-unknown-property": ["error", { "ignore": ["sx"] }],
"no-unused-expressions": "off",
"@babel/no-unused-expressions": "warn"
"@babel/no-unused-expressions": "warn",

"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"block-spacing": ["error", "always"],
"brace-style": "error",
"comma-spacing": ["error", { "before": false, "after": true }],
"eol-last": ["error", "always"],
"func-call-spacing": ["error", "never"],
"indent": ["error", 2, { "SwitchCase": 1, "MemberExpression": "off" }],
"jsx-quotes": ["error", "prefer-single"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and Studio used more double quotes before. Enabling this rule causes 77 errors. Enabling prefer-double only causes 23 errors. Tobira uses double quotes; the editor seems to use double quotes as well. It's also closer to HTML (which JSX wants to mimic). So I'd have preferred to use double quotes.
Should we still change this or just keep it as is now?

"linebreak-style": ["error", "unix"],
"max-len": ["error", { "code": 120, "ignoreUrls": true }],
LukasKalbertodt marked this conversation as resolved.
Show resolved Hide resolved
"no-multi-spaces": ["warn", { "ignoreEOLComments": true }],
"no-trailing-spaces": "error",
"object-curly-spacing": ["error", "always", { "arraysInObjects": false, "objectsInObjects": false }],
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"space-infix-ops": "error"
},
"settings": {
"react": {
Expand Down
10 changes: 5 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ const Routes = ({ settingsManager, userHasWebcam }) => {
<Fragment>
<PreventClose />
<Switch>
<Route path="/settings" exact>
<Route path='/settings' exact>
<SettingsPage settingsManager={settingsManager} />
</Route>

<Route path="/about" exact>
<Route path='/about' exact>
<About />
</Route>

<Route path="/" exact>
<Route path='/' exact>
<Studio
activeStep={activeStep}
updateActiveStep={updateActiveStep}
userHasWebcam={userHasWebcam}
/>
</Route>

<Route path="/*">
<Redirect to={{ pathname: "/", search: location.search }} />
<Route path='/*'>
<Redirect to={{ pathname: '/', search: location.search }} />
</Route>
</Switch>
</Fragment>
Expand Down
32 changes: 16 additions & 16 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import './style/global-style';

const Tooltip = ({ content, ...props }) => (

<Tippy
content = { <span> {content} </span> }
interactive={true}
<Tippy
content = { <span> {content} </span> }
interactive={true}

sx={{
fontSize: '16px',
backgroundColor: theme => theme.colors.tooltip,
color: theme => theme.colors.tooltip_text,
lineHeight: 'normal',
fontFamily: 'Open Sans',
}}
{...props}
>
<span> { props.children} </span>
</Tippy>
sx={{
fontSize: '16px',
backgroundColor: theme => theme.colors.tooltip,
color: theme => theme.colors.tooltip_text,
lineHeight: 'normal',
fontFamily: 'Open Sans',
}}

{...props}
>
<span> {props.children} </span>
</Tippy>
);

export default Tooltip;
export default Tooltip;
46 changes: 23 additions & 23 deletions src/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,32 @@ i18n
escapeValue: false,
format: (value, format, lng) => {
switch (format) {
case 'duration-seconds':
if (value == null) {
return '-:--:--';
}
case 'duration-seconds':
if (value == null) {
return '-:--:--';
}

const seconds = value % 60;
value /= 60;
const minutes = Math.floor(value % 60);
value /= 60;
const hours = Math.floor(value % 60);
const seconds = value % 60;
value /= 60;
const minutes = Math.floor(value % 60);
value /= 60;
const hours = Math.floor(value % 60);

const secondsString = seconds.toLocaleString(lng, {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
let result = [
(minutes < 10 ? '0' : '') + minutes,
(seconds < 10 ? '0' : '') + secondsString,
];
if (hours) {
result.unshift(hours);
}
const secondsString = seconds.toLocaleString(lng, {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
let result = [
(minutes < 10 ? '0' : '') + minutes,
(seconds < 10 ? '0' : '') + secondsString,
];
if (hours) {
result.unshift(hours);
}

return result.join(':');
default:
return value;
return result.join(':');
default:
return value;
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ initialize.then(
</OpencastProvider>
</ThemeProvider>
</React.StrictMode>
);
);
},

// This error case is vey unlikely to occur.
Expand Down
4 changes: 2 additions & 2 deletions src/opencast.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ export const useOpencast = () => React.useContext(Context);
export const Provider = ({ initial, children }) => {
const [, updateDummy] = useState(0);
const [opencast, updateOpencast] = useState(initial);
opencast.updateGlobalOc = (newInstance) => {
opencast.updateGlobalOc = newInstance => {
updateOpencast(newInstance);

// If the object reference didn't change, we use this dummy state to force a
Expand Down Expand Up @@ -662,7 +662,7 @@ const renderTemplate = (template, view) => {
const out = Mustache.render(template, view);
Mustache.escape = originalEscape;
return out;
}
};

const DEFAULT_DCC_TEMPLATE = `<?xml version="1.0" encoding="UTF-8"?>
<dublincore xmlns="http://www.opencastproject.org/xsd/1.0/dublincore/"
Expand Down
8 changes: 4 additions & 4 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class SettingsManager {
// the value at the end.
let obj = rawUrlSettings;
const segments = key.split('.');
segments.slice(0, -1).forEach((segment) => {
segments.slice(0, -1).forEach( segment => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space left of segment doesn't belong here, right?

if (!(segment in obj)) {
obj[segment] = {};
}
Expand Down Expand Up @@ -404,7 +404,7 @@ const metaDataField = v => {
+ `'${FORM_FIELD_REQUIRED}', but is '${v}'`
);
}
}
};

// A validator wrapper that errors of the source of the value is NOT
// `settings.toml`.
Expand All @@ -415,7 +415,7 @@ const onlyFromServer = inner => (v, allowParse, src) => {
}

return inner(v, allowParse, src);
}
};

// Sources that values can come from.
const SRC_SERVER = 'src-server';
Expand Down Expand Up @@ -508,7 +508,7 @@ const SCHEMA = {
let merge = (a, b) => {
return deepmerge(a, b, { arrayMerge });
};
merge.all = array => deepmerge.all(array, { arrayMerge })
merge.all = array => deepmerge.all(array, { arrayMerge });
const arrayMerge = (destinationArray, sourceArray, options) => sourceArray;


Expand Down
2 changes: 1 addition & 1 deletion src/style/global-style.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import css from '@emotion/css/macro'
import css from '@emotion/css/macro';

const GlobalStyle = css`
* {
Expand Down
32 changes: 16 additions & 16 deletions src/ui/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ function LegalNotices() {

<Themed.p>
<FontAwesomeIcon icon={faGlobeEurope} />{' '}
<Themed.a href="https://elan-ev.de">elan-ev.de</Themed.a>
<Themed.a href='https://elan-ev.de'>elan-ev.de</Themed.a>
<br />
<FontAwesomeIcon icon={faEnvelope} />{' '}
<Themed.a href="mailto:kontakt@elan-ev.de">kontakt@elan-ev.de</Themed.a>
<Themed.a href='mailto:kontakt@elan-ev.de'>kontakt@elan-ev.de</Themed.a>
<br />
<FontAwesomeIcon icon={faPhone} />{' '}
<Themed.a href="tel:+4944199866610">+49&thinsp;441 998&thinsp;666&thinsp;10</Themed.a>
<Themed.a href='tel:+4944199866610'>+49&thinsp;441 998&thinsp;666&thinsp;10</Themed.a>
</Themed.p>

<Themed.p>
Expand All @@ -58,7 +58,7 @@ function About(props) {
<Themed.h1>Opencast Studio</Themed.h1>
</header>
<Themed.p>
A web-based recording studio for <Themed.a href="https://opencast.org">Opencast</Themed.a>.
A web-based recording studio for <Themed.a href='https://opencast.org'>Opencast</Themed.a>.
</Themed.p>
<Themed.p>
Opencast Studio allows you to record your camera, your display and your microphoneʼs audio.
Expand All @@ -67,11 +67,11 @@ function About(props) {
</Themed.p>
<Themed.p>
This is free software under the terms of the{' '}
<Themed.a href="https://github.com/elan-ev/opencast-studio/blob/master/LICENSE">
<Themed.a href='https://github.com/elan-ev/opencast-studio/blob/master/LICENSE'>
MIT License
</Themed.a>{' '}
developed by the <Themed.a href="https://elan-ev.de">ELAN e.V.</Themed.a> in cooperation
with the <Themed.a href="https://ethz.ch">ETH Zürich</Themed.a>.
developed by the <Themed.a href='https://elan-ev.de'>ELAN e.V.</Themed.a> in cooperation
with the <Themed.a href='https://ethz.ch'>ETH Zürich</Themed.a>.
</Themed.p>

<Themed.h2>How it works</Themed.h2>
Expand All @@ -87,7 +87,7 @@ function About(props) {
<Themed.p>
If you are experiencing any difficulties or found any bugs,
please take a look at the{' '}
<Themed.a href="https://github.com/elan-ev/opencast-studio/issues">
<Themed.a href='https://github.com/elan-ev/opencast-studio/issues'>
issue tracker on GitHub
</Themed.a>.
Before filing a new issue, please check if one about your topic already exists.
Expand All @@ -96,7 +96,7 @@ function About(props) {
<Themed.p>
If you are interested in additional development
or want to support the development of Opencast Studio, please contact{' '}
<Themed.a href="mailto:opencast-support@elan-ev.de">
<Themed.a href='mailto:opencast-support@elan-ev.de'>
opencast-support@elan-ev.de
</Themed.a>.
</Themed.p>
Expand All @@ -109,19 +109,19 @@ function About(props) {
</Themed.p>
<ul>
<li>
<Themed.a href="https://github.com/slampunk">Duncan Smith</Themed.a> for starting this
<Themed.a href='https://github.com/slampunk'>Duncan Smith</Themed.a> for starting this
project
</li>
<li>
<Themed.a href="https://github.com/cilt-uct">University of Cape Town (CILT)</Themed.a>
<Themed.a href='https://github.com/cilt-uct'>University of Cape Town (CILT)</Themed.a>
{' '}for letting Duncan start the project
</li>
<li>
<Themed.a href="https://ethz.ch">ETH Zürich</Themed.a> for financial support and
<Themed.a href='https://ethz.ch'>ETH Zürich</Themed.a> for financial support and
testing
</li>
<li>
<Themed.a href="https://github.com/elan-ev">ELAN e.V.</Themed.a> for the re-implementation
<Themed.a href='https://github.com/elan-ev'>ELAN e.V.</Themed.a> for the re-implementation
and the ongoing development
</li>
<li>
Expand All @@ -136,10 +136,10 @@ function About(props) {
Build date {process.env.REACT_APP_BUILD_DATE || '?'},
commit{' '}
<Themed.a
aria-label="Git commit on GitHub"
href={"https://github.com/elan-ev/opencast-studio/commit/"
aria-label='Git commit on GitHub'
href={'https://github.com/elan-ev/opencast-studio/commit/'
+ process.env.REACT_APP_GIT_SHA }
>
>
{process.env.REACT_APP_GIT_SHA || '?'}
</Themed.a>.
</Themed.p>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Input = ({
<input
aria-invalid={errors[name] ? 'true' : 'false'}
aria-describedby={`${name}Error`}
autoComplete="off"
autoComplete='off'
name={name}
ref={register({
validate,
Expand Down
Loading