2021-05-21 00:54:30 +08:00
/ *
* Copyright ( C ) 2017 - present Instructure , Inc .
*
* This file is part of Canvas .
*
* Canvas is free software : you can redistribute it and / or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation , version 3 of the License .
*
* Canvas is distributed in the hope that it will be useful , but WITHOUT ANY
* WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE . See the GNU Affero General Public License for more
* details .
*
* You should have received a copy of the GNU Affero General Public License along
* with this program . If not , see < http : //www.gnu.org/licenses/>.
* /
2019-06-26 05:49:37 +08:00
const path = require ( 'path' )
2017-05-18 04:51:43 +08:00
module . exports = {
env : {
es6 : true ,
amd : true ,
2021-05-21 00:54:30 +08:00
browser : true
2016-12-17 07:08:07 +08:00
} ,
2017-08-19 01:09:04 +08:00
extends : [
2018-11-03 01:48:59 +08:00
'airbnb' ,
'prettier/react' ,
'plugin:jest/recommended' ,
'plugin:prettier/recommended' ,
'plugin:eslint-comments/recommended' ,
2021-05-21 00:54:30 +08:00
'plugin:promise/recommended'
2017-08-19 01:09:04 +08:00
] ,
2017-05-18 04:51:43 +08:00
parserOptions : {
2021-05-21 00:54:30 +08:00
ecmaVersion : 2020 ,
2017-05-18 04:51:43 +08:00
ecmaFeatures : {
2021-05-21 00:54:30 +08:00
jsx : true
2016-12-17 07:08:07 +08:00
} ,
2021-05-21 00:54:30 +08:00
sourceType : 'module'
2016-12-17 07:08:07 +08:00
} ,
2021-07-30 11:29:31 +08:00
parser : '@typescript-eslint/parser' ,
2017-05-18 04:51:43 +08:00
globals : {
ENV : true ,
2021-07-30 11:29:31 +08:00
JSX : true ,
2017-05-18 04:51:43 +08:00
INST : true ,
2018-11-03 01:48:59 +08:00
tinyMCE : true ,
2021-05-21 00:54:30 +08:00
tinymce : true
2017-05-18 04:51:43 +08:00
} ,
2019-06-26 05:24:47 +08:00
plugins : [
'promise' ,
'import' ,
'notice' ,
'jest' ,
'prettier' ,
'jsx-a11y' ,
'lodash' ,
'react' ,
2020-05-01 21:34:22 +08:00
'react-hooks' ,
2021-07-30 11:29:31 +08:00
'babel' ,
'@typescript-eslint'
2019-06-26 05:24:47 +08:00
] ,
2017-05-18 04:51:43 +08:00
rules : {
2018-11-03 01:48:59 +08:00
'no-cond-assign' : [ 'error' , 'except-parens' ] ,
2019-06-26 05:24:47 +08:00
// enable the react-hooks rules
'react-hooks/rules-of-hooks' : 'error' ,
'react-hooks/exhaustive-deps' : 'warn' ,
2018-11-03 01:48:59 +08:00
// These come from our extended configurations, but we don't care about them
camelcase : 'off' , // because we have a ton of `const $user_name = $('#user_name')`
2021-02-05 05:01:38 +08:00
'comma-dangle' : 'off' ,
2018-11-03 01:48:59 +08:00
'class-methods-use-this' : 'off' ,
'consistent-return' : 'off' ,
'default-case' : 'off' ,
eqeqeq : 'warn' , // great goal! but since we do it 1061 times, downgrade AirBnB's 'error' to 'warn' :(
'func-names' : 'off' ,
'global-require' : 'off' , // every time we did this, we meant to
2018-10-12 00:57:01 +08:00
'guard-for-in' : 'off' ,
2019-08-29 12:15:45 +08:00
'max-classes-per-file' : 'off' ,
2018-11-03 01:48:59 +08:00
'no-continue' : 'off' ,
'no-else-return' : 'off' ,
'no-multi-assign' : 'off' ,
'no-nested-ternary' : 'off' ,
'no-new' : 'off' , // because we do `new SomeView()` all the time in Backbone just for the sideffects
2018-10-12 00:27:11 +08:00
'no-param-reassign' : 'off' ,
2018-11-03 01:48:59 +08:00
'no-plusplus' : 'off' ,
2018-10-12 01:05:00 +08:00
'no-prototype-builtins' : 'off' ,
2018-11-03 01:48:59 +08:00
'no-return-assign' : 'off' ,
'no-underscore-dangle' : 'off' ,
'no-use-before-define' : 'off' ,
'no-useless-escape' : 'off' ,
'one-var' : 'off' ,
'prefer-destructuring' : 'off' ,
'prefer-rest-params' : 'off' ,
2019-08-15 23:42:29 +08:00
'prefer-template' : 'off' , // AirBnB says 'error', we don't care
2018-11-03 01:48:59 +08:00
'eslint-comments/disable-enable-pair' : [ 'error' , { allowWholeFile : true } ] , // We are okay with turning rules off for the entirety of a file (though use it sparingly)
'import/prefer-default-export' : 'off' ,
'jsx-a11y/label-has-for' : 'off' ,
'jsx-a11y/anchor-is-valid' : [ 'error' , { components : [ ] } ] , // InstUI has special behavior around this
'promise/always-return' : 'off' ,
'promise/catch-or-return' : 'warn' , // The recommendation is to error on this, but we downgrade it to a warning
'promise/avoid-new' : 'off' ,
'promise/no-nesting' : 'off' ,
'react/destructuring-assignment' : 'off' ,
2019-09-14 00:44:32 +08:00
'react/forbid-prop-types' : 'off' , // AirBnB doesn't want you to use PropTypes.object, and we agree normally. But there are times where you just want to pass on an opaque object to something else and forcing people to make a PropTypes.shape for it doesn't add any value. People should still encourage each other to use PropTypes.shape normally, when it makes sense, in code-review but we're not going to -2 because of it.
2018-11-03 01:48:59 +08:00
'react/no-typos' : 'off' ,
'react/sort-comp' : 'off' ,
'react/require-default-props' : 'off' ,
2020-05-01 21:34:22 +08:00
'react/prop-types' : [ 'error' , { skipUndeclared : true } ] ,
2018-11-03 01:48:59 +08:00
'react/default-props-match-prop-types' : [ 'error' , { allowRequiredDefaults : true } ] , // add the `allowRequiredDefaults: true` option to allow specifying something as a required prop (so you get propType error messages), but in case it's not present at runtime, I'll use `[]` as the default (so it is resilient)".
'react/forbid-foreign-prop-types' : 'off' , // You can refer to proptypes within proptypes, but you shouldn't use proptypes in actual app code of the component
2019-08-14 09:31:44 +08:00
'react/jsx-no-bind' : 'off' ,
'react/jsx-props-no-spreading' : 'off' ,
2018-11-03 01:48:59 +08:00
'react/no-danger' : 'off' , // dangerouslySetInnerHTML is already pretty explicit on making you aware of its danger
'react/no-render-return-value' : 'warn' , // In future versions of react this will fail
2019-08-14 09:31:44 +08:00
'react/state-in-constructor' : 'off' ,
'react/static-property-placement' : 'off' ,
2021-01-02 07:58:12 +08:00
// don't restrict Math.pow for ** operator
// ref: https://github.com/airbnb/javascript/blob/1f786e154f6c32385607e1688370d7f2d053f88f/packages/eslint-config-airbnb-base/rules/best-practices.js#L225
2021-02-05 05:01:38 +08:00
'no-restricted-properties' : [
'error' ,
2021-01-02 07:58:12 +08:00
{
object : 'arguments' ,
property : 'callee' ,
2021-05-21 00:54:30 +08:00
message : 'arguments.callee is deprecated'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'global' ,
property : 'isFinite' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isFinite instead'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'self' ,
property : 'isFinite' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isFinite instead'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'window' ,
property : 'isFinite' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isFinite instead'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'global' ,
property : 'isNaN' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isNaN instead'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'self' ,
property : 'isNaN' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isNaN instead'
2021-01-02 07:58:12 +08:00
} ,
{
object : 'window' ,
property : 'isNaN' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Number.isNaN instead'
2021-01-02 07:58:12 +08:00
} ,
{
property : '__defineGetter__' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Object.defineProperty instead.'
2021-01-02 07:58:12 +08:00
} ,
{
property : '__defineSetter__' ,
2021-05-21 00:54:30 +08:00
message : 'Please use Object.defineProperty instead.'
}
2021-01-02 07:58:12 +08:00
] ,
2018-11-03 01:48:59 +08:00
'no-restricted-syntax' : [
// This is here because we are turning off 2 items from what AirBnB cares about.
'error' ,
2018-10-12 00:57:01 +08:00
{
2018-11-03 01:48:59 +08:00
selector : 'LabeledStatement' ,
message :
2021-05-21 00:54:30 +08:00
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
2018-10-12 00:57:01 +08:00
} ,
{
2018-11-03 01:48:59 +08:00
selector : 'WithStatement' ,
message :
2021-05-21 00:54:30 +08:00
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
}
2018-10-12 00:57:01 +08:00
] ,
2018-11-03 01:48:59 +08:00
// These are discouraged, but allowed
'no-console' : 'warn' ,
'jest/no-large-snapshots' : 'warn' ,
// These are things we care about
2021-07-30 11:29:31 +08:00
'react/jsx-filename-extension' : [ 'error' , { extensions : [ '.js' , 'ts' , 'tsx' ] } ] ,
2018-11-03 01:48:59 +08:00
'eslint-comments/no-unused-disable' : 'error' ,
2021-07-30 11:29:31 +08:00
'import/extensions' : [ 'error' , 'ignorePackages' , { js : 'never' , ts : 'never' , tsx : 'never' } ] ,
2018-11-03 01:48:59 +08:00
'import/no-commonjs' : 'off' , // This is overridden where it counts
'import/no-extraneous-dependencies' : [ 'error' , { devDependencies : true } ] ,
'lodash/callback-binding' : 'error' ,
'lodash/collection-method-value' : 'error' ,
'lodash/collection-return' : 'error' ,
'lodash/no-extra-args' : 'error' ,
'lodash/no-unbound-this' : 'error' ,
'notice/notice' : [
'error' ,
{
2019-06-26 05:49:37 +08:00
templateFile : path . join ( _ _dirname , 'config' , 'copyright-template.js' ) ,
2018-11-03 01:48:59 +08:00
// purposely lenient so we don't automatically put our copyright notice on
// top of something already copyrighted by someone else.
2021-05-21 00:54:30 +08:00
mustMatch : 'Copyright '
}
2019-08-21 04:47:00 +08:00
] ,
2020-05-01 21:34:22 +08:00
'no-unused-expressions' : 'off' , // the babel version allows optional chaining a?.b
2021-07-30 11:29:31 +08:00
'babel/no-unused-expressions' : [ 'error' , { allowShortCircuit : true , allowTernary : true } ] ,
Initial pace plans import
This change brings in the basic pace plans frontend with
styled-components and several other smaller libraries replaced with
InstUI 7 components. It also adds the 'reselect' library as a direct
dependency (which we already had through @instructure/outcomes-ui) and
'tsc-files' for type-checking of staged TS files on commit. There were
also some tweaks to typescript and eslint configs, mostly to get both
up to speed with the typescript code.
Finally, this also adds a `pace_plans` endpoint to
`courses_controller` to bootstrap the frontend-- this will get moved
to `pace_plans_controller` once it has been merged.
It's also worth noting that no frontend tests are included with this
change-- the existing tests were written with enzyme and are heavily
snapshot-based, so we will be replacing those with
@testing-library/react tests in later updates (in keeping with current
testing best practices at Instructure).
closes LS-2431, LS-2432, LS-2433, LS-2434, LS-2452
flag = pace_plans
Test plan:
- Set up a course with at least one module and several module items
- Turn on the pace_plans feature flag in the account associated with
that course
- Turn on the "Enable pace plans" setting in course settings
- Create a pace plan for the course via the Rails console:
c = Course.find<id>
pp = c.pace_plans.create! workflow_state: 'active'
c.context_module_tags.each_with_index do |t, i|
pp.pace_plan_module_items.create! module_item: t, duration: i*2
end
- Go to the course as a teacher or admin
- Expect to see a "Pace Plans" link in the course navigation
- Click it, expect the pace plan you created earlier to load and
render
- Expect to be able to pick dates, change durations, and toggle
checkboxes (although saves will fail, since there is no API yet).
- Expect to not see the "Pace Plans" course nav link when the feature
flag or course setting is off
- Expect /courses/<id>/pace_plans to return a 404 when the feature
flag or course setting is off
- Expect to not see the "Pace Plans" course nav link as a student
- Expect /courses/<id>/pace_plans to display an "Unauthorized" page
as a student
Change-Id: If4dc5d17f2c6a2109d4b4cb652c9e9ef00d7cc33
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/271650
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: Jeff Largent <jeff.largent@instructure.com>
2021-08-18 05:14:24 +08:00
// Some rules need to be replaced with typescript versions to work with TS
'no-redeclare' : 'off' ,
'@typescript-eslint/no-redeclare' : 'error' ,
'no-shadow' : 'off' ,
'@typescript-eslint/no-shadow' : 'warn' , // AirBnB says 'error', we downgrade to just 'warn'
'no-unused-vars' : 'off' ,
'@typescript-eslint/no-unused-vars' : [
'error' ,
{
argsIgnorePattern : '^_' ,
// allows `const {propIUse, propIDontUseButDontWantToPassOn, ...propsToPassOn} = this.props`
ignoreRestSiblings : true
}
] ,
2021-07-30 11:29:31 +08:00
semi : 'off' ,
'@typescript-eslint/semi' : [ 'error' , 'never' ]
2018-11-03 01:48:59 +08:00
} ,
settings : {
2021-07-30 11:29:31 +08:00
'import/resolver' : {
node : {
extensions : [ '.js' , '.jsx' , '.json' , '.ts' , '.tsx' , '.d.ts' ] // add Typescript extensions
}
} ,
2018-11-03 01:48:59 +08:00
react : {
2021-05-21 00:54:30 +08:00
version : 'detect'
}
2018-04-24 02:40:57 +08:00
} ,
2018-05-09 03:46:39 +08:00
overrides : [
2018-11-03 01:48:59 +08:00
{
files : require ( './jest.config' ) . testMatch ,
plugins : [ 'jest' ] ,
env : {
2021-05-21 00:54:30 +08:00
'jest/globals' : true
2018-11-03 01:48:59 +08:00
} ,
rules : {
'jest/prefer-to-be-null' : 'error' ,
'jest/prefer-to-be-undefined' : 'error' ,
'jest/prefer-to-contain' : 'error' ,
'jest/no-test-return-statement' : 'error' ,
2021-05-21 00:54:30 +08:00
'jest/no-large-snapshots' : 'warn'
}
2018-11-03 01:48:59 +08:00
} ,
2018-05-09 03:46:39 +08:00
{
2021-04-06 07:44:00 +08:00
files : [ 'ui/**/*' , 'spec/**/*' , 'public/**/*' ] ,
2018-05-09 03:46:39 +08:00
rules : {
2018-05-22 22:48:46 +08:00
// Turn off the "absolute-first" rule. Until we get rid of the `compiled/` and `jsx/`
// stuff and use real realitive paths it will tell you to do the wrong thing
2020-05-28 06:04:02 +08:00
'import/first' : [ 'error' , 'disable-absolute-first' ] ,
2018-05-22 22:48:46 +08:00
2018-11-03 01:48:59 +08:00
'import/no-amd' : 'error' ,
'import/no-commonjs' : 'warn' ,
'import/no-extraneous-dependencies' : 'off' , // allows 'i18n!webzip_exports' and 'compiled/foo/bar'
'import/no-nodejs-modules' : 'error' ,
2018-10-11 07:39:10 +08:00
'import/order' : 'off' , // because it thinks 'jsx/whatever' and 'compiled/baz' should go in their groups. we don't want to encourage people to do that just so they move them back together once those everything is in same dir
2018-11-03 01:48:59 +08:00
'import/no-unresolved' : 'off' ,
2021-05-21 00:54:30 +08:00
'import/no-webpack-loader-syntax' : 'off'
}
2021-01-02 07:58:12 +08:00
} ,
{
2021-04-06 07:44:00 +08:00
files : [
'ui/features/quiz_log_auditing/**/*' ,
'ui/features/quiz_statistics/**/*' ,
'ui/shared/quiz-legacy-client-apps/**/*' ,
2021-05-21 00:54:30 +08:00
'ui/shared/quiz-log-auditing/**/*'
2021-04-06 07:44:00 +08:00
] ,
2021-01-02 07:58:12 +08:00
rules : {
'react/prop-types' : 'off' ,
'prefer-const' : 'warn' ,
'prettier/prettier' : 'off' ,
2021-05-21 00:54:30 +08:00
'react/no-string-refs' : 'warn'
}
}
]
2017-05-18 04:51:43 +08:00
}