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

feat: create core/base for react/node/legacy lint configs #22128

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "style: fix lint errors",
"packageName": "@fluentui/api-docs",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "style: fix lint errors",
"packageName": "@fluentui/codemods",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: create core base for react/node/legacy lint configs",
"packageName": "@fluentui/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "none"
Copy link
Member

Choose a reason for hiding this comment

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

Awesome that you set dependentChangeType to none

Copy link
Contributor Author

Choose a reason for hiding this comment

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

learned my lesson from the best ;)

}
3 changes: 3 additions & 0 deletions packages/api-docs/src/generatePageJsonFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function generatePageJsonFiles(options: IPageJsonOptions): void {
// Load api-extractor output from packages into a model
const apiModel = new ApiModel();
for (const apiJsonPath of apiJsonPaths) {
// eslint-disable-next-line no-console
console.log('Loading ' + apiJsonPath);

// If the file belongs to the compat layer.
Expand Down Expand Up @@ -53,6 +54,7 @@ export function generatePageJsonFiles(options: IPageJsonOptions): void {
const requestedPages = ([] as string[]).concat(...Object.values(pageGroups));
for (const pageName of requestedPages) {
if (!pageJsonByName.has(pageName)) {
// eslint-disable-next-line no-console
console.warn('Warning: no API items found for expected @docCategory ' + pageName);
}
}
Expand All @@ -61,6 +63,7 @@ export function generatePageJsonFiles(options: IPageJsonOptions): void {
for (const [pageName, pageJson] of pageJsonByName.entries()) {
const pageJsonPath = path.join(outputRoot, pageJson.group || '', pageName + '.page.json');

// eslint-disable-next-line no-console
console.log('Writing ' + pageJsonPath);
const json = min ? JSON.stringify(pageJson) : JSON.stringify(pageJson, null, 2);
fse.writeFileSync(pageJsonPath, json);
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["plugin:@fluentui/eslint-plugin/node"],
"extends": ["plugin:@fluentui/eslint-plugin/node", "plugin:@fluentui/eslint-plugin/react"],
Copy link
Contributor Author

@Hotell Hotell Mar 16, 2022

Choose a reason for hiding this comment

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

looks like --legacy isn't being used as it should. this is v8 package so it shouldn't use v9 lint rules at all.

This will need additional refactoring/checking across whole monorepo

"root": true,
"overrides": [
{
Expand Down
4 changes: 4 additions & 0 deletions packages/codemods/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export class CommandParser {
}
if (parsed.list) {
const mods = getEnabledMods(console, getModsPaths);
// eslint-disable-next-line no-console
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lint errors that appeared during config reshuffling

console.log('Here are the enabled code mod names:\n');
mods.forEach(mod => {
// eslint-disable-next-line no-console
console.log(mod.name);
});
return { shouldExit: true, modsFilter: () => true };
Expand All @@ -86,6 +88,7 @@ export class CommandParser {
if (configResult.ok) {
configObj = configResult.value;
} else {
// eslint-disable-next-line no-console
console.log(configResult.value);
return { shouldExit: true, modsFilter: () => true };
}
Expand Down Expand Up @@ -115,6 +118,7 @@ function getModRunnerConfig(): Result<ModRunnerConfigType, ModError> {
sync: true,
});
let configObj: ModRunnerConfigType = { stringFilters: [], regexFilters: [], includeMods: false };
// eslint-disable-next-line no-console
console.log('Configuration detected. Attempting to run mods from config...');
if (!foundJsonFile.found || foundJsonFile.found.length !== 1) {
return Err<ModRunnerConfigType, ModError>({ error: new Error('Error, could not locate correct config file.') });
Expand Down
9 changes: 5 additions & 4 deletions packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

Usage: in your [ESLint config file](https://eslint.org/docs/user-guide/configuring), add `{ "extends": ["plugin:@fluentui/<name>"] }` or `{ "extends": ["plugin:@fluentui/eslint-plugin/<name>"] }` (the two are equivalent).

- `react`: For `@fluentui/react` and related packages
- `react--legacy`: Like `react` but requiring an `I` prefix for interfaces
- `node`: Like `react` but for packages which run in a Node environment (not the browser)
- `node--legacy`: Like `node` but requiring an `I` prefix for interfaces
- `react`: react specific configuration for fluentui vNext
- `node`: node specific configuration for fluentui vNext
- `react--legacy`: react specific configuration for fluentui v7,8
- `node--legacy`: node specific configuration for fluentui v7,8
- `react-northstar`: For `@fluentui/react-northstar` and related packages
- `imports`: auto import statements sorting configuration

Helpers for customizing configuration are exported under a `configHelpers` object.

Expand Down
18 changes: 18 additions & 0 deletions packages/eslint-plugin/src/configs/base-legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @ts-check

const path = require('path');

const { getNamingConventionRule } = require('../utils/configHelpers');

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [path.join(__dirname, 'core')],
rules: {
/**
* `@typescript-eslint`plugin eslint rules
* @see https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin
*/
...getNamingConventionRule({ prefixInterface: true }),
},
overrides: [],
};
26 changes: 26 additions & 0 deletions packages/eslint-plugin/src/configs/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @ts-check

const path = require('path');

const { getNamingConventionRule } = require('../utils/configHelpers');

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [path.join(__dirname, 'core')],
rules: {
/**
* `@typescript-eslint`plugin eslint rules
* @see https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin
*/
...getNamingConventionRule(),
},
overrides: [
{
files: '**/src/index.{ts,tsx,js}',
rules: {
// TODO: propagate to `error` once all packages barrel files have been fixed
'@rnx-kit/no-export-all': ['warn', { expand: 'all' }],
},
},
],
};
Loading