Commit Graph

82 Commits

Author SHA1 Message Date
Angela Gomba 82e4724c1f upgrade jquery-ui position to unpatched 1.9.0-beta.1
Part of unblcoking the jQuery 2.x upgrade.

refs FOO-4258
flag=none

Test Plan:
- Jenkins passes

Change-Id: I6560518f7d84faf67b7a7a76037ea3948c9229a4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339894
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Jen Smith <jen.smith@instructure.com>
Product-Review: Jen Smith <jen.smith@instructure.com>
2024-02-08 02:47:04 +00:00
Aaron Shafovaloff e4af406748 remove no-extraneous-dependencies eslint rule
Change-Id: I73e2b11dd78eacbdb6cb506fcd1005e05dd9e14d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339879
Reviewed-by: Michael Hulse <michael.hulse@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Build-Review: James Butters <jbutters@instructure.com>
2024-02-07 02:46:52 +00:00
Aaron Shafovaloff e1358db735 support multiple entry bundles
this will enable loading of initial entry chunks
in addition to the main entry

this is needed for loading shared vendor chunks

test plan:
  - build passes

Change-Id: I1b170c1df559a7344dd4cd1ea2c915ff41e0f409
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/338722
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Drake Harper <drake.harper@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Build-Review: James Butters <jbutters@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2024-01-25 21:10:01 +00:00
Aaron Shafovaloff 3ad70d4f25 remove use of CommonJS from ui/
refs CFA-37

Change-Id: Ie729c752be3782b004f557abe4d83bc6d87fcb01
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/338259
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
2024-01-22 14:24:17 +00:00
Isaac Moore b0d93542b5 Don't allow jsx in ts files
Change-Id: Ia5f199d46cdfc1b8daf094c23681aaea951e33b6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/337145
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Shafovaloff <ashafovaloff@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
2024-01-09 21:55:23 +00:00
Aaron Shafovaloff 2193317c01 reduce JS linting noise
flag=none

flag=none

Change-Id: I54e0c3e4403b14ead4476937aba2a0db24c40f37
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/336817
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2024-01-05 21:14:49 +00:00
Aaron Shafovaloff d3fbcd6768 misc eslint fixes
test plan:
  - build passes

flag=none

Change-Id: Iaf2956431f1b32d8e3ec63ef04ba952328ed2e35
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/323430
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Reviewed-by: Christopher Soto <christopher.soto@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2023-07-24 17:25:01 +00:00
Aaron Shafovaloff 3e4a278969 support .jsx
Change-Id: I131bf00133a5a14df1ce050540503f4241776a09
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/323390
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Build-Review: Andrea Cirulli <andrea.cirulli@instructure.com>
Reviewed-by: Andrea Cirulli <andrea.cirulli@instructure.com>
2023-07-21 22:56:34 +00:00
Yona Appletree d136523768 Upgrade eslint packages, clean up ignores
Update some eslint packages removing the need for
some eslint-disable directives.

Changed react/no-unknown-property to warning since
we have several instances of it already in the
codebase.

Refs CFA-5
flag=none

Test plan:
- Automated tests pass

Change-Id: I4967d53477de7c4effe8861ee71e735be33f6b14
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/317894
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Shafovaloff <ashafovaloff@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
2023-05-10 23:22:15 +00:00
Aaron Shafovaloff cf44858dc1 turn variables off in no-use-before-define rule
When set to false, "the rule ignores a reference if the declaration
is in an upper scope, while still reporting the reference if it's
in the same scope as the declaration."
https://eslint.org/docs/latest/rules/no-use-before-define

test plan:
  - existing tests pass

flag=none

Change-Id: I3b4d071d97e713f4f02842ac9a684080340e71f8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/316676
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Cameron Ray <cameron.ray@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2023-04-21 20:12:05 +00:00
Aaron Shafovaloff 58420b0985 turn classes off in no-use-before-define rule
test plan:
  - existing tests pass

flag=none

Change-Id: Id9f7f8d074e07a97b8faa4349005b9910f51af50
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/316594
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Christopher Soto <christopher.soto@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
2023-04-20 21:43:53 +00:00
Aaron Shafovaloff 7ba6ceea12 remove coffeescript from webpack config
also: remove vestiges of CoffeeScript

test plan:
  - existing tests pass

closes EVAL-3071

flag=none

Change-Id: Ic52024efd7d16e9a5ee550d7ad9a406950ec4b51
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/316570
Reviewed-by: Cameron Ray <cameron.ray@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Build-Review: Andrea Cirulli <andrea.cirulli@instructure.com>
2023-04-20 19:49:42 +00:00
Aaron Shafovaloff 9ee95c1c97 turn on @typescript-eslint/no-use-before-define
test plan:
  - existing tests pass

flag=none

Change-Id: I492c8e0fcf9f90fc6c43a87bf090e414b58a1477
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/316580
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Christopher Soto <christopher.soto@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
2023-04-20 19:47:23 +00:00
Aaron Shafovaloff 51349dfa05 remove .coffee extension from coffeescript imports
this removes annoyances when decaffeinating files

test plan:
  - all tests pass

flag=none

Change-Id: Ie3af0faf13d64a4701bb917fbcae29cb10474df1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315484
Reviewed-by: Derek Williams <derek.williams@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
Build-Review: Aaron Ogata <aogata@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2023-04-10 17:01:42 +00:00
Aaron Shafovaloff d8bb45511d Extract custom column data DataLoader
Test plan:
  - Enable the Notes column
  - Add a note to a student
    - Verify that the note is displayed after saving it
    - Edit the note
    - Verify that the note is updated after saving it
  - Clear the note
    - Verify that the note is cleared after saving it
  - Disable the Notes column
    - Verify that the notes column is removed from the UI
  - Re-enable the Notes column
    - Make a change to a note
    - Verify that the note is displayed after refreshing the page
  - Verify that notes column loads properly in a course with many
    students

Closes EVAL-1934

flag=none

Change-Id: I2245c08e1f4b766156febbbc791acdd7c4e4c73f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/306852
Reviewed-by: Cameron Ray <cameron.ray@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-01-21 21:14:09 +00:00
Aaron Shafovaloff ca7d2f4d7b Resolve ESLint warnings
Test plan:
  - All existing tests pass

Refs DE-1426

flag=none

Change-Id: I75f6c81dc4b9b91367ffd774695cfd3249fc7bec
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/304328
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Christopher Soto <christopher.soto@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2022-10-28 20:24:33 +00:00
Aaron Shafovaloff 65d2e79a08 Use warnings for some react eslint rules
Test plan:
    - All existing tests pass

flag=none

Refs DE-1426

Change-Id: I71482f85e89eeb62db45337cfb4b84c6ce9186d5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/303812
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
Reviewed-by: Jeffrey Johnson <jeffrey.johnson@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Jeffrey Johnson <jeffrey.johnson@instructure.com>
2022-10-21 17:33:46 +00:00
Ed Schiebel 18666d030b de-jqueryify enhanceUserContent: v2
reimplement enhanceUserContent without
jquery in preparation for moving out of the
canvas monolith.  Some transformations to the DOM
aren't necessary, but are there for backward compatibility
(as I discovered getting all existing specs to pass) pass

This is not going to be an easy review, since the new implementation
is completely new and it will be difficult to ensure the
previous functionality is all implemented correctly.
What can I say?

closes MAT-1011
flag=none

test plan:
  - using the rce, create content with
    - external link
    - course link
    - canvas file link, default overlay preview
    - canvas file link, inline preview
    - canvas file link, inline preview, automatially expand
    - link to youtube content, end edit html and remove
      "inline_disabled" class name
  - save
  > expect
    > external link to have the external link icon
      w/in the link so you can click it and open
      the link in a new tab
    > nothing happens to the course link
    > clicking canvas file link 1, preview opens in the overlay
    > clicking canvas file link 2, preview opens inline
      > clicking again closes preview
    > canvas file link 3 inline preview opens automatically
      > clicking link closes preview
    > the youtube link gets a preview thumbnail next to it
      > click the thumbnail and it's replaced with a playable
        youtube video

  - have a student submit an assignment
  - create a media comment on the assignment
  > expect the media comment link to be replaced with a thumbnail
    that plays when clicked (I think)

  - PS29 and beyone
    - look at the DOM tree for external images
    > expect the text and icon each to be in their own span
    - have a link containing just an image.
    - tab through the saved content
    > expect the linked image's focus ring to be in your theme color

TESTING JQUERY WIDGETS: this only works in canvas, probably not new quizzes
  - put something like the following in your content using the rce's html editor
<div class="enhanceable_content draggable" style="width: 100px; height: 100px; border: 1px solid black; background-color: cyan;">drag me?</div>
<div class="enhanceable_content resizable" style="width: 100px; height: 100px; border: 1px solid black; background-color: grey;">resize me?</div>
<div class="enhanceable_content tabs">
    <ul>
        <li><a href="#tabs-1">Nunc tincidunt</a></li>
        <li><a href="#tabs-2">Proin dolor</a></li>
        <li><a href="#tabs-3">Aenean lacinia</a></li>
    </ul>
    <div id="tabs-1">
        <p>I am tab 1 content</p>
    </div>
    <div id="tabs-2">
        <p>This is tab 2 content</p>
    </div>
    <div id="tabs-3">
        <p>tab 3 content has 2 paragraphs</p>
        <p>and this is that 2nd paragraph</p>
    </div>
</div>
<p><a href="#jquery_dialog">open the dialog</a></p>
<div id="jquery_dialog" class="enhanceable_content dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<div>Drag items around to sort</div>
<ul class="enhanceable_content sortable">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ul>
  > expect to be able to drag "drag me" around the page
  > expect "resize me" to be resizeaable
  > expect tabs to work
  - click "open the doalog"
  > expect the dialog to open
  > expect to be able to close and reopen the dialog
  > expect to be able to drag list items around to reorder them

Change-Id: I34418970870a1d34f8dabd9dd435ba058576b52a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/300806
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
QA-Review: Mysti Lilla <mysti@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
2022-10-20 13:01:09 +00:00
Charley Kline 17ca2f7479 Make linter demand explicit React Boolean prop values
Refs FOO-3064
flag=none

React recommends always passing a value to a Boolean prop
even if it is true, ie  `isSelected={true}` instead of just
`isSelected`

The reason given in the React guides is to improve JSX readability.

Test plan:
* none

Change-Id: I7159638ac8deec86752f6d8c38ecaee4743c3302
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/299260
Reviewed-by: Sean Scally <sean.scally@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-08-22 21:04:25 +00:00
Charley Kline 057369517f Fix eslint config in ui/engine
Refs FOO-2801
flag=none

The various builds look at various filesystem trees so
the ESlint config isn't consistent. A previous commit
passed the pre-merge build fine but failed the post-merge
job. This should fix that.

Test plan:
* Pre-merge build is still happy
* Post-merge build is happier still

Change-Id: Ic06225fcd8a82deb8f819acd27f557512bc15776
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/298424
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Andrea Cirulli <andrea.cirulli@instructure.com>
2022-08-11 22:00:35 +00:00
Ahmad Amireh 6059f00fad babel independence: k5uploader & js-utils
refs FOO-2697
flag = none

those two packages were relying on canvas's babel.config.js but no more

test plan: the build phase of the CI is enough as there were no logical
changes

Change-Id: I7814796f36f1e30b4dd494a12f768f9dbafb4f1f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286759
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: August Thornton <august@instructure.com>
Product-Review: August Thornton <august@instructure.com>
QA-Review: Ahmad Amireh <ahmad@instructure.com>
2022-03-11 21:00:09 +00:00
Davis Hyer c8d8efe784 ignore package translations in jest
refs LS-3017
flag=none

test plan:
  - tests pass

qa risk: low

Change-Id: I8da0db910b0647405f27b04c1f9c143b35126f70
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286184
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com>
QA-Review: Omar Soto-Fortuño <omar.soto@instructure.com>
Product-Review: Omar Soto-Fortuño <omar.soto@instructure.com>
2022-03-04 15:39:06 +00:00
Dustin Cowles 23a2813af5 fix video url when uploading subs on media comment
fixes EVAL-2128
flag=none

Test plan:
- Tests Pass
- PreReqs:
  - Notorious/Kaltura configured
- As a teacher, leave a media comment in SpeedGrader
- View the media comment and click [CC] -> Upload Subtitles
- Confirm the URL and Copy button are visible

Change-Id: I525ea12f28302734cef58acad36032a71d3996af
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/285090
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Jody Sailor
Reviewed-by: Eduardo Escobar <eduardo.escobar@instructure.com>
Reviewed-by: Syed Hussain <shussain@instructure.com>
2022-02-22 18:18:15 +00:00
Ahmad Amireh 5f976f9989 rename frontend_build -> ui-build
minor QOL mainly for me; put webpack-specific configuration in its own
folder, make it portable, and make room for esbuild

the __webpack_public_path__ initializer no longer sources the value from
the build module, instead it uses a pre-defined global that webpack
injects

~ test plan ~

build is OK

Change-Id: I4ba4a3c0cb9175f96096f2b78022e152c04fc75d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276183
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
2021-10-21 19:13:02 +00:00
Davis Hyer bae1f0f286 disable jest/no-disabled-tests eslint rule
flag=none

With this linter, we will be unable to skip any tests for any reason
(ex flakiness). Since an eslint warn is still considered a -2, we will
disable this rule for now.

test plan:
  - Run `node_modules/.bin/eslint` on a test file with a test skipped
    - the linter should not flag the skipped test

qa risk: low

Change-Id: I5dbeef818ee550f10b4fa8352bbca20b47b1f7f0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274670
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kyle Rosenbaum <krosenbaum@instructure.com>
QA-Review: Davis Hyer <dhyer@instructure.com>
Product-Review: Davis Hyer <dhyer@instructure.com>
2021-09-28 18:00:43 +00:00
Jeff Largent c01113638b 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-09-01 19:58:33 +00:00
Jeff Largent 4fe9f01972 Add typescript support
This change adds support for typescript transpilation to our frontend
build via babel, and also updates eslint and canvas_i18nliner to be
able to understand typescript as well. The main goal of this PS is to
enable developers to add typescript code to the Canvas codebase but to
be unopinionated about how type-checking is done; at this stage types
will only be checked by running the new `check:ts` or `check:js`
scripts (which run the typescript compiler directly), or via
integration with an IDE like RubyMine or VS Code.

closes LS-2430
flag = none

Test plan:
  BUILD STEPS:
  - FE build, i18n build, and tests pass Jenkins
  - `bin/rails canvas:compile_assets` still works
  - `RAILS_ENV=production bin/rails convas:compile_assets` still works

  SPOT CHECKING:
  - Starting up rails and run `yarn build:js:watch`
  - Click around Canvas and make sure the frontend still loads as
    normal

Change-Id: I8bb1a0f065e09496a924708dead6fa4518b59496
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/270401
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
Reviewed-by: Nate Armstrong <narmstrong@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Jeff Largent <jeff.largent@instructure.com>
2021-08-18 18:21:17 +00:00
Ed Schiebel 0cf3bea009 Update eslint to v7
so it stops complaining about the ?. operator, among other things

closes MAT-45
flag=none

test plan:
  - npx eslint ./path/to/a.js
    on a file with ?. in it doesn't complain

Change-Id: I6056e25ce9c53a8e652d6e4eec1280057369cf26
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/265387
Reviewed-by: Guilherme Baron <gbaron@instructure.com>
QA-Review: Guilherme Baron <gbaron@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-05-20 18:28:51 +00:00
Ahmad Amireh 4243097b21 rename some things
fixes FOO-1265

[skip-eslint=true]
[pin-commit-analytics=7e49eefd7f59cbf43fd03bf8957bbbfa76f8d9d5]
[pin-commit-demo_site=adade2e38e46a358a4643cd3db2fe5ccffe39ec5]
[pin-commit-instructure_misc_plugin=47a3161102b0611af56d134fbd0c828ddc1b8abf]
[pin-commit-migration_tool=0dbac2f5b421d894395605ce4b583ef0f7d60b22]
[pin-commit-multiple_root_accounts=cc96d28c0d59bbe47acc64de4fdd8e1d2b029805]

Change-Id: I14c07f20bd260cf0de1f48ceb70b3c2313edf2d2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/258807
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Michael Ziwisky <mziwisky@instructure.com>
QA-Review: Michael Ziwisky <mziwisky@instructure.com>
Product-Review: Michael Ziwisky <mziwisky@instructure.com>
2021-04-06 01:12:49 +00:00
Aaron Shafovaloff 40ec245b8c no longer require trailing comma
test plan:
 - no more linting failures when file committed
   without trailing commas
 - yet prettier implements new default behavior

flag=none

Change-Id: I3884e5f512f06dea2c08c6fecb8573aed3a7798e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/258196
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Matthew Lemon <mlemon@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-02-04 21:48:38 +00:00
Ahmad Amireh 46f8efd61f modernize canvas_quizzes
fixes FOO-1409
flag  = none

no more client_apps, canvas_quizzes now lives as part of canvas-lms
proper inside app/jsx/, which makes the build leaner and leaves us with
one less thing to reason about

logical changes:

- converted from AMD to ES modules
- upgraded to recent react + react-router
- dropped RSVP in favor of native Promises
- used CanvasModal instead of home-grown Dialog
- removed dead code; notifications in particular were fishy as there had
  no dependents at all and did not even show up in the graph
- ported tests to Jest, added more unit ones and two integration ones
- removed "config.onError" and now throws errors where appropriate
- disabled console statements in non-dev

:: test plan ::

- create a (old-school) quiz containing all types of questions
- as 3 distinct students, take the quiz and try to randomize your
  answers

at this point it's helpful to have a reference to compare the screens; I
replicated the quiz on my production sandbox for this

- go to /courses/:id/quizzes/:id/submissions/:id/log
  - verify it looks OK
  - click on a specific question in the stream and verify the question
    inspector widget works OK
  - go back to stream and push "View table"
  - verify the table and its controls are OK

- go to /courses/:id/quizzes/:id/statistics
  - verify it looks OK
  - click on ? in the discrimination index chart and verify it displays
    a dialog with help content
  - click on "X respondents" in one of the charts and verify it displays
    a dialog with the respondent names
  - verify the interactive charts do interact as expected (no logic
    changed here so just a quick glance)
  - link to "View in SpeedGrader" for essay-like questions works

Change-Id: I79af5ff4f1479503b5e2528b613255dde5bc45d3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256118
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2021-01-14 22:45:10 +00:00
Ed Schiebel 656de86a31 update build to load es modules from subpackages
closes LA-995
flag=none

1. unify the instui ui-babel-preset options across sub-packages
2. include "@instructure" as part of each sub-package name
3. unify the commonjs and es module directory structure
4. use index.js to export anything needed to be imported from
   outside the package. This removes any dependency on the
   package's internal directory structure and makes importing
   independent of commonjs vs es module simple
5. move canvas-rce's main entry from async.js to index.js
   (I'm 98% sure index.js was an artifact of the old rce)

test plan:
  - canvas-lms builds locally and in docker. (Jenkins builds
    the docker image, so I presume if it passes jenkins,
    the docker build wasn't broken)
  - sniff test the result, esp. student planner and the new rce.
  - yarn build:watch from canvas-rce, canvas-planner, and
    canvas-media packages should work, and yarn build:watch
    from canvas-lms should pick-up any changes.
    (I've verified this by finding a console.log statement
     and changing the message then use devtools to see it's in
     the new source after refreshing the browser)

Change-Id: I5f242d06ad655597cd416057d4b740d4bd86003b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/238603
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Alex Anderson <raanderson@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
2020-06-03 13:41:38 +00:00
Ed Schiebel 9d779b3d7f Update eslint rules to allow optional chaining
closes LA-973
flag=none

test plan:
  - code with a?.b does not report no-unused-expressions eslint error

Change-Id: If31b5545c31a9a095176cee74a2173ba0eeceab8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/235941
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
Reviewed-by: Augusto Callejas <acallejas@instructure.com>
2020-05-07 12:38:29 +00:00
Clay Diffrient fbf856500e Remove prettier whitelist
This makes it so all staged *.js files are formatted using
prettier as a precommit hook rather than just selected
portions.

Test Plan:
  - Commit a JS file with something not pretty in it.
  - It should be pretty after the commit.

closes COREFE-347
closes COREFE-50

flag = none

Change-Id: Id9ad77e68fd95720752a316e5f2111ab6c9a02bc
Reviewed-on: https://gerrit.instructure.com/212895
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2019-10-11 19:29:31 +00:00
Ryan Shaw 9c024549d9 eslint: turn of react/forbid-prop-types
We agree that people _should_ not use PropTypes.object normally, but
there _are_ times where doing that makes more sense then trying to come
up with a PropTypes.shape to use instead. So this is something we think
should be enforced in code-review rather than -2ing commits because
of it. We’d rather get rid of the rule than see a bunch of 
`eslint-disable-next-line react/forbid-prop-types` scattered around
trying to ignore it where people knew what they were doing.

Test plan:
* you shouldn’t see any more warnings about 
  `PropTypes.object is forbidden` when you eslint

Change-Id: Icc9071604a162260aa9bce3a916f046f2553b66a
Reviewed-on: https://gerrit.instructure.com/209451
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2019-09-13 19:12:07 +00:00
Ryan Shaw 191bcd434d [eslint] turn off max-classes-per-file rule
this disallows things like creating 2 react classes in one file
like we do in app/jsx/shared/TermsOfServiceModal.js

I don’t see how that is going to catch any bugs and I don’t see why
we should tell people they can’t do that so I vote turn this off

test plan:
if you agree +2, if not, that’s fine and I’ll abandon

Change-Id: I0751609a75051e379f958aaed2e1c4dd260c020d
Reviewed-on: https://gerrit.instructure.com/207306
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2019-08-30 21:53:32 +00:00
Ed Schiebel d0146696db Add allowShortCircuit exception for no-unused-expressions
test plan:
  - node ./node_modules/.bin/eslint packages/canvas-rce/src/bridge/Bridge.js
    does not generate a warning or error.

Change-Id: I136f9bce39ea9a85999cbd5b244fd9d021b3a123
Reviewed-on: https://gerrit.instructure.com/205915
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
2019-08-20 21:51:01 +00:00
Ryan Shaw bf446dd05f Now that i18nliner can understand it, turn back on fragments
The previous commit makes it so i18nliner can understand <> instead of
<React.Fragment>, so this turns back on the eslint rule we had to turn
Off

Test plan:
* run bin/rake i18n:generate_js (or let the Jenkins builds run)
* it should pass

Change-Id: Ia3204cd6c3147eb52ca612adbb3b20b2df8c6921
Reviewed-on: https://gerrit.instructure.com/205378
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2019-08-20 14:06:41 +00:00
Cameron Matheson d10d9c26d6 disable eslint fragment rule
I wouldn't mind this rule, but it tries to force you into syntax that
i18nliner can't support.

Change-Id: Id6238223850ec134dd9aea1ddf34e1713f288e39
Reviewed-on: https://gerrit.instructure.com/205307
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
2019-08-15 20:23:35 +00:00
Ryan Shaw 1d199b5e2f upgrade eslint & don’t use unique one in canvas-rce
instead of having our own eslint in canvas-rce, and maintaining all
future rules like react hooks and stuff we can just use the same one
that the rest of the repo uses.

test plan:
* cd packages/canvas-rce
* `yarn lint` should run

Change-Id: Idbe8af533f7a19035d1998538d2d6fd1a711f164
Reviewed-on: https://gerrit.instructure.com/204998
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2019-08-15 17:17:30 +00:00
Ryan Shaw d867bd8eb2 [eslint]: turn off `prefer-template`
AirBnB’s styleguide wants to force you to write
“foo” + bar
as 
`foo${bar}`

see: https://eslint.org/docs/rules/prefer-template

I agree that the former is probably easier to read but I don’t know that
I care that much about to _force_ it. Sometimes I see things that use
“+” that seem nicer to read than the ones that use template literals.
and I just don’t think this is going to catch any bugs either way.


what say ye?
- 1 this if you want to keep caring about it
+2 this if you agree we should stop caring

Change-Id: Ie2fd6267dd0566da73034f7a62bd9dd73ebf4138
Reviewed-on: https://gerrit.instructure.com/205253
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2019-08-15 17:16:54 +00:00
Cameron Matheson c8ceb23e4b be more judicious with proptype errors
this commit increases the error-level on prop types from warning to
error.

it doesn't alert on components that don't have proptypes declared.

Change-Id: I6f74f1f6f3b3e0867002199e5507466038d8e1c3
Reviewed-on: https://gerrit.instructure.com/204773
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2019-08-13 04:25:35 +00:00
Ryan Shaw e88a3aeb26 eslint: add ignoreRestSiblings to no-unused-vars
We frequently have code like:

const {id, children} = props
const otherProps = omitProps(props, null, ['id', 'value', 'onChange'])

you could rewrite that as:
const {id, children, value, onChange, ...otherProps} = this.props

But if you did that right now, without this change, you’d get an eslint
error about `no-unused-vars` because you didn’t use value or onChange
in this function. 

This makes it so eslint doesn’t complain about that.

See: https://eslint.org/docs/rules/no-unused-vars#ignorerestsiblings

Test plan:
* So the question is:
* Do you think that complaining about this rule actually catches any
  real bugs?
* if so, -2 this.
* if not, +2 it 

Change-Id: I2fc9b351f34e80ec74199569f768ccc71dfcd705
Reviewed-on: https://gerrit.instructure.com/202669
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2019-07-25 19:11:27 +00:00
Jon Willesen debef8b978 add react-hooks linting and update react dep
Update the react dependency to 16.8 since we're starting to use react
hooks, which requires that version at minimum.

test plan:
- linting still works
- intentionally create a violation of rules-of-hooks. Linting should
  find and report the error.

Change-Id: I0baccd64397b31118b96eb390462acf56daeca96
Reviewed-on: https://gerrit.instructure.com/199053
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
2019-06-26 16:24:49 +00:00
Ryan Shaw ece2a5cc71 Don’t use special eslint for canvas-planner
…instead, just use the default config for the rest of the repo

Test plan:
* cd packages/canvas-planner
* yarn eslint src/components/BadgeList/index.js
* you should not see an error about not being able to find flowtype

Change-Id: I48c4ab3ac20a60352c20c489addb4d4b4a32e83a
Reviewed-on: https://gerrit.instructure.com/199060
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
2019-06-25 22:22:12 +00:00
Clay Diffrient 93a6d18046 Add precommit hook for auto fixing files
This only affects javascript files and only affects things
from the prettier whitelist

This will run slowly if you don't have node_modules installed
locally (e.g., in Docker), but it will gladly attempt to
run things in Docker for you.

This adds a new githook_installer image that will install
the githook whenever a docker-compose up happens in the
repo.  It will also install the hook whenever a `yarn`
occurs locally (as a postinstall hook).

This commit should also not fail things.  For example
having unused variables is an ESLint error, but it isn't
autofixable.  It will log the error, but will otherwise
continue.  However, it will make this pretty with prettier
as well as fix any other autofixable ESLint errors.

closes CORE-2118

Test Plan:
  - Run `yarn`
  - Add some semicolons to something from the whitelist
  - git add that file
  - git commit and it will strip semicolons
  - In a dockerized Canvas:
     - docker-compose up
     - Add semicolons to a file
     - git add that file
     - git commit, it will take forever (~60s)
     - It should have stripped out semicolons

Change-Id: Id9198aa008808e898f29acb9ed64dd14ff843222
Reviewed-on: https://gerrit.instructure.com/171510
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-11-27 21:07:31 +00:00
Ryan Shaw 2647f5cc44 opt the rest of the stuff Core owns into prettier
AKA:
eslint --fix app/jsx/{theme_editor,help_dialog,editor,dashboard_card,*.js}

Test plan:
* nothing should change

Change-Id: Ie7bbabaf46b0220a6c42449388f734a7a6cc09c5
Reviewed-on: https://gerrit.instructure.com/171498
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2018-11-08 23:00:28 +00:00
Ryan Shaw d86d69015c Opt our js build tooling dirs into prettier
I guess since our team owns these we can opt them in now


Test plan:
* nothing should change

Change-Id: Ic7207e1033869ef60644c41bd5c80a3e8532a6dd
Reviewed-on: https://gerrit.instructure.com/171471
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2018-11-07 22:46:16 +00:00
Clay Diffrient 58ab36e5d8 ESLint standardization
This commit introduces a better more reasonable ESLint configuration.
It removes all concerns with styling in favor of using prettier to handle
those things.

closes CORE-2096

Test Plan:
  - ESLint works

Change-Id: I50b90b7191b576bce4817d885d14f18c4c72d208
Reviewed-on: https://gerrit.instructure.com/170874
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2018-11-06 17:46:21 +00:00
Clay Diffrient 0c3a7c59af Modify polyfills and eslint to permit for-of loops more generally
Change-Id: Ie99aeec6c6379542e3f43398dbb8e97c3882d252
Reviewed-on: https://gerrit.instructure.com/170651
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2018-11-05 17:00:10 +00:00