Skip to content

Commit

Permalink
eslint-plugin: classify stories as examples not tests (#20681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 authored Dec 14, 2021
1 parent 21ac4f3 commit e839eaa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Classify .stories.tsx as examples not tests",
"packageName": "@fluentui/eslint-plugin",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
}
12 changes: 11 additions & 1 deletion packages/eslint-plugin/src/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,22 @@ const getOverrides = () => [
},
{
// Example overrides
files: '**/*.Example.tsx',
files: '**/*.{Example,stories}.tsx',
rules: {
'no-alert': 'off',
'no-console': 'off',
},
},
{
files: '**/*.stories.tsx',
rules: {
// allow arrow functions in stories for now (may want to change this later since using
// constantly-mutating functions can be an anti-pattern which we may not want to demonstrate
// in our converged components docs; it happened to be allowed starting out because .stories
// files were being linted as tests)
'react/jsx-no-bind': 'off',
},
},
{
// Docs overrides (excluding examples)
files: [...configHelpers.docsFiles],
Expand Down
19 changes: 13 additions & 6 deletions packages/eslint-plugin/src/utils/configHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const path = require('path');
const jju = require('jju');

const testFiles = [
'**/*{.,-}test.{ts,tsx}',
'**/*.stories.tsx',
'**/{common,test,tests,stories}/**',
'**/*{.,-}{test,spec}.{ts,tsx}',
'**/{test,tests}/**',
'**/testUtilities.{ts,tsx}',
'**/common/isConformant.{ts,tsx}',
'**/common/{isConformant,snapshotSerializers}.{ts,tsx}',
];

const docsFiles = ['**/*Page.tsx', '**/{docs,demo}/**', '**/*.doc.{ts,tsx}'];
Expand Down Expand Up @@ -47,8 +46,16 @@ module.exports = {
/** Files for build configuration */
configFiles,

/** Files which may reference devDependencies: tests, docs (excluding examples), config/build */
devDependenciesFiles: [...testFiles, ...docsFiles, ...configFiles],
/**
* Files which may reference `devDependencies`:
* - tests
* - docs (excluding v8 examples)
* - config/build
* - stories, for now
* - may need to reconsider for converged components depending on website approach
* - the stories suffix is also used for screener stories in `vr-tests`
*/
devDependenciesFiles: [...testFiles, ...docsFiles, ...configFiles, '**/*.stories.tsx'],

/**
* Whether linting is running in context of lint-staged (which should disable rules requiring
Expand Down

0 comments on commit e839eaa

Please sign in to comment.