Skip to content

Commit

Permalink
Added icons package to eslint-ts config and fixed some eslint errors (#…
Browse files Browse the repository at this point in the history
…11501)

<!--
  ☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
  - Start with a verb, for example: Add, Delete, Improve, Fix…
  - Give as much context as necessary and as little as possible
  - Open it as a draft if it’s a work in progress
-->

### WHY are these changes introduced?

We noticed that the `polaris-icons` package did not have a tsconfig and
was not getting linted as expected. Updated configs and fixed up some of
the linting errors that were missed.


<!--
  Context about the problem that’s being addressed.
-->

### WHAT is this pull request doing?

<!--
  Summary of the changes committed.

Before / after screenshots are appreciated for UI changes. Make sure to
include alt text that describes the screenshot.

  Include a video if your changes include interactive content.

If you include an animated gif showing your change, wrapping it in a
details tag is recommended. Gifs usually autoplay, which can cause
accessibility issues for people reviewing your PR:

  <details>
    <summary>Summary of your gif(s)</summary>
    <img src="..." alt="Description of what the gif shows">
  </details>
-->

### How to 🎩

🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)

### 🎩 checklist

- [ ] Tested a
[snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases)
- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide

---------

Co-authored-by: Aaron Cassanova <aaron.cassanova@shopify.com>
  • Loading branch information
Yuraima Estevez and Aaron Cassanova authored Jan 28, 2024
1 parent 88c90b2 commit f2cfe07
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module.exports = {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.eslint.json',
...packages.map((pkg) => `./${pkg}/tsconfig.json`),
...packages
.filter((pkg) => pkg !== 'polaris-icons')
.map((pkg) => `./${pkg}/tsconfig.json`),
],
},
settings: {
Expand Down
3 changes: 2 additions & 1 deletion polaris-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"clean": "rm -rf .turbo node_modules dist",
"dev": "rollup -c -w",
"test": "jest",
"optimize": "svgo -f icons"
"optimize": "svgo -f icons",
"lint": "TIMING=1 eslint --cache ."
},
"exports": {
".": {
Expand Down
12 changes: 2 additions & 10 deletions polaris-icons/tests/validate-svg-content.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');
const path = require('path');

// eslint-disable-next-line import/no-extraneous-dependencies
const svgo = require('svgo');
const globby = require('globby');
const unified = require('unified');
Expand All @@ -9,8 +10,6 @@ const {select, selectAll} = require('hast-util-select');

const svgoConfig = require('../svgo.config');

const nameRegex = /(?<=)(Major|Minor)(?=\.svg)/;

const allIconFiles = globby
.sync(path.resolve(__dirname, '../icons/*.svg'))
.map((absoluteIconPath) => {
Expand All @@ -29,14 +28,7 @@ const allIconFiles = globby
});

allIconFiles.forEach(
({
iconPath,
iconSource,
optimizedSource,
iconAst,
expectedViewbox,
expectedFillColors,
}) => {
({iconPath, iconSource, optimizedSource, iconAst, expectedViewbox}) => {
describe(`SVG Contents: packages/${iconPath}`, () => {
it(`is optimized`, () => {
expect(iconSource).toStrictEqual(optimizedSource);
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
// Root config used to specify which TS files to lint
// https://typescript-eslint.io/docs/linting/monorepo/#one-root-tsconfigjson

"compilerOptions": {
// Ensures this config is not used for a build
"noEmit": true
Expand All @@ -14,6 +13,7 @@
"polaris-react",
"polaris-tokens",
"polaris.shopify.com",
"stylelint-polaris"
"stylelint-polaris",
"polaris-icons"
]
}

0 comments on commit f2cfe07

Please sign in to comment.