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(eslint-plugin): replacace deprecation/deprecation with etc/no-deprecated #22251

Closed
2 changes: 1 addition & 1 deletion apps/public-docsite-resources/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/member-ordering": "off",
"deprecation/deprecation": "off"
"etc/no-deprecated": "off"
}
}
2 changes: 1 addition & 1 deletion apps/public-docsite/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"root": true,
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"deprecation/deprecation": "off",
"etc/no-deprecated": "off",
"import/no-webpack-loader-syntax": "off", // ok in this project
"prefer-const": "off",
"react/jsx-no-bind": "off"
Expand Down
2 changes: 1 addition & 1 deletion apps/theming-designer/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"root": true,
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"deprecation/deprecation": "off",
"etc/no-deprecated": "off",
"prefer-const": "off"
}
}
2 changes: 1 addition & 1 deletion apps/vr-tests-react-components/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/jsx-no-bind": "off",
"deprecation/deprecation": "off",
"etc/no-deprecated": "off",
"import/no-extraneous-dependencies": ["error", { "packageDir": [".", "../.."] }]
}
}
2 changes: 1 addition & 1 deletion apps/vr-tests/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/jsx-no-bind": "off",
"deprecation/deprecation": "off",
"etc/no-deprecated": "off",
"import/no-extraneous-dependencies": ["error", { "packageDir": [".", "../.."] }]
}
}
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"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"check:change": "beachball check --scope \"!packages/fluentui/*\"",
"check:modified-files": "yarn workspace @fluentui/scripts just check-for-modified-files",
"check:affected-package": "node ./scripts/monorepo/checkIfPackagesAffected.js",
"check:installed-dependencies-versions": "satisfied --skip-invalid --ignore \"prettier|angular|lit|sass|@storybook/web-components|@storybook/html|svelte|@testing-library|vue\"",
"check:installed-dependencies-versions": "satisfied --skip-invalid --ignore \"prettier|angular|lit|sass|@storybook/web-components|@storybook/html|svelte|@testing-library|vue|eslint\"",
"clean": "lage clean --verbose",
"code-style": "lage code-style --verbose",
"codepen": "cd packages/react && node ../../scripts/local-codepen.js",
Expand Down Expand Up @@ -174,8 +174,8 @@
"eslint-config-airbnb": "18.2.1",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-deprecation": "1.2.1",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-etc": "2.0.2",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-jsdoc": "^36.0.7",
Expand Down Expand Up @@ -320,7 +320,7 @@
"eslint-config-airbnb",
"eslint-config-prettier",
"eslint-import-resolver-typescript",
"eslint-plugin-deprecation",
"eslint-plugin-etc",
"eslint-plugin-import",
"eslint-plugin-jest",
"eslint-plugin-jsx-a11y",
Expand Down
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
4 changes: 2 additions & 2 deletions 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"],
"root": true,
"overrides": [
{
Expand All @@ -9,7 +9,7 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/naming-convention": "off",
"import/no-extraneous-dependencies": "off",
"deprecation/deprecation": "off"
"etc/no-deprecated": "off"
}
}
]
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
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
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-deprecation": "^1.2.1",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^23.13.2",
"eslint-plugin-jsdoc": "^36.0.7",
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