@blueprintjs/eslint-plugin
Advanced tools
Comparing version 2.1.4 to 2.2.0
@@ -20,3 +20,3 @@ "use strict"; | ||
/** | ||
* Enable Blueprint-specific lint rules defined in this package. | ||
* Enable all Blueprint-specific lint rules defined in this package. | ||
*/ | ||
@@ -30,2 +30,3 @@ module.exports = { | ||
"@blueprintjs/html-components": "error", | ||
"@blueprintjs/no-deprecated-components": "error", | ||
}, | ||
@@ -32,0 +33,0 @@ }, |
@@ -6,3 +6,8 @@ declare const _default: { | ||
"no-deprecated-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-core-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-datetime-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-select-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-table-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
"no-deprecated-timezone-components": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"migration", unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>; | ||
}; | ||
export default _default; |
@@ -28,3 +28,8 @@ "use strict"; | ||
"no-deprecated-components": no_deprecated_components_1.noDeprecatedComponentsRule, | ||
"no-deprecated-core-components": no_deprecated_components_1.noDeprecatedCoreComponentsRule, | ||
"no-deprecated-datetime-components": no_deprecated_components_1.noDeprecatedDatetimeComponentsRule, | ||
"no-deprecated-select-components": no_deprecated_components_1.noDeprecatedSelectComponentsRule, | ||
"no-deprecated-table-components": no_deprecated_components_1.noDeprecatedTableComponentsRule, | ||
"no-deprecated-timezone-components": no_deprecated_components_1.noDeprecatedTimezoneComponentsRule, | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@blueprintjs/eslint-plugin", | ||
"version": "2.1.4", | ||
"version": "2.2.0", | ||
"description": "ESLint rules for use with @blueprintjs packages", | ||
@@ -16,7 +16,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@typescript-eslint/utils": "^5.21.0", | ||
"eslint": "^8.14.0" | ||
"@typescript-eslint/utils": "^5.32.0", | ||
"eslint": "^8.21.0" | ||
}, | ||
"devDependencies": { | ||
"@blueprintjs/node-build-scripts": "^5.0.2", | ||
"@blueprintjs/node-build-scripts": "^5.1.0", | ||
"@types/dedent": "^0.7.0", | ||
@@ -23,0 +23,0 @@ "dedent": "^0.7.0", |
154
README.md
@@ -21,22 +21,35 @@ <img height="204" src="https://cloud.githubusercontent.com/assets/464822/20228152/d3f36dc2-a804-11e6-80ff-51ada2d13ea7.png"> | ||
Simply add this plugin in your `.eslintrc` file to use the add the plugin. The plugin includes Blueprint-specific rules which enforce semantics particular to usage with `@blueprintjs` packages, but does not turn them on by default. | ||
Add the `"@blueprintjs"` plugin to your ESLint config: | ||
`.eslintrc` | ||
```json | ||
{ | ||
"plugins": [ | ||
"@blueprintjs" | ||
] | ||
} | ||
``` | ||
### Configure all built-in rules | ||
To enable _all_ rules provided by the plugin the Blueprint-specific rules, extend the `plugin:@blueprintjs/recommended` configuration: | ||
```json | ||
plugins: [ | ||
"@blueprintjs" | ||
] | ||
{ | ||
"extends": [ | ||
"plugin:@blueprintjs/recommended" | ||
] | ||
} | ||
``` | ||
### Rules-only usage | ||
### Configure specific rules | ||
To enable the Blueprint-specific rules, extend the `plugin:@blueprintjs/recommended` config inside the package: | ||
Alternatively, you may enable specific rules provided the plugin: | ||
`tslint.json` | ||
```diff | ||
extends: [ | ||
+ "plugin:@blueprintjs/recommended" | ||
] | ||
```json | ||
{ | ||
"rules": { | ||
"@blueprintjs/classes-constants" | ||
"@blueprintjs/no-deprecated-components": "error" | ||
} | ||
} | ||
``` | ||
@@ -48,10 +61,13 @@ | ||
Enforce usage of `Classes` constants over namespaced string literals. | ||
Enforce usage of class names exported as public API via the `Classes` object instead of string literals like `"bp4-dark"`. | ||
Each `@blueprintjs` package exports a `Classes` object that contains constants for every CSS class defined by the package. While the values of the constants may change between releases, the names of the constants will remain more stable. | ||
Each `@blueprintjs` package exports a `Classes` object which contains constants for every CSS class defined by the package. | ||
__Rationale__: This is useful to avoid typos in styling or creating Blueprint components, and also helps future-proof your code for major | ||
version bumps of Blueprint where the class namespace (e.g. `bp4-`) changes. | ||
```json | ||
{ | ||
"rules": { | ||
"@blueprintjs/classes-constants": ["error"] | ||
"@blueprintjs/classes-constants":"error" | ||
} | ||
@@ -61,5 +77,7 @@ } | ||
__Has auto-fixer__: ✅ | ||
```diff | ||
-const element = <div className="pt-navbar" />; | ||
+const element = <div className={Classes.NAVBAR} />; | ||
- const element = <div className="pt-navbar" />; | ||
+ const element = <div className={Classes.NAVBAR} />; | ||
``` | ||
@@ -69,3 +87,3 @@ | ||
Enforce usage of Blueprint components over regular html components. | ||
Enforce usage of Blueprint components over regular HTML JSX tags: | ||
@@ -78,7 +96,11 @@ - h1-6 -> H1-6 | ||
```js | ||
__Rationale__: This is uesful to ensure consistent styling of common typographic elements and other basic markup. | ||
__Has auto-fixer__: ✅ | ||
```json | ||
{ | ||
"rules": { | ||
"@blueprintjs/html-components": ["error"], | ||
} | ||
"rules": { | ||
"@blueprintjs/html-components": ["error"] | ||
} | ||
} | ||
@@ -89,4 +111,7 @@ ``` | ||
Enforce usage of JSX `Icon` components over `IconName` string literals (or vice-versa) in `icon` JSX props. Note that this rule only supports hardcoded values in the `icon` prop; it does not handle expressions or conditionals. | ||
:warning: DEPRECATED: this rule is no longer recommended. Icons modularity / tree shaking will be a first-class feature of Blueprint v5.0. | ||
Enforce usage of JSX `Icon` components instead of `IconName` string literals (or vice-versa) in `icon` JSX props. | ||
Note that this rule only supports hardcoded values in the `icon` prop; it does not handle expressions or conditionals. | ||
A fixer is available for this rule that will convert between string literals and named `Icon` components. Note that the implementation is naive and may require intervention, such as to import a component or fix an invalid name. | ||
@@ -102,3 +127,3 @@ | ||
// default uses "component" | ||
"@blueprintjs/icon-components": ["error"], | ||
"@blueprintjs/icon-components" | ||
// expanded syntax | ||
@@ -124,2 +149,81 @@ "@blueprintjs/icon-components": ["error", "component" | "literal"] // choose one | ||
### `@blueprintjs/no-deprecated-components` | ||
Ban usage of deprecated Blueprint components, including: | ||
- AbstractComponent | ||
- AbstractPureComponent | ||
- Breadcrumbs | ||
- CollapsibleList | ||
- DateInput | ||
- DateRangeInput | ||
- DateTimePicker | ||
- MenuItem | ||
- MultiSelect | ||
- PanelStack | ||
- Popover | ||
- Select | ||
- Suggest | ||
- TimezonePicker | ||
- Tooltip | ||
__Rationale__: Many Blueprint components have "V2" variants as a part of their natural API evolution. | ||
Blueprint consumers are recommended to migrate from the deprecated V1 components to their newer V2 counterparts | ||
in order to future-proof their code for the next major version of Blueprint, where the V2 components will become the | ||
only available API and the V1 variants will be removed. Flagging usage of deprecated APIs can be done with other | ||
ESLint rules like `deprecation/deprecation`, but that rule is often too broad to enable as an "error" globally across | ||
a large code base. `@blueprintjs/no-deprecated-components` provides a simpler, more scoped rule which only flags | ||
usage of deprecated Blueprint components in JSX. The idea here is that you can enable this rule as an "error" in ESLint | ||
to prevent any backwards progress in your Blueprint migration as you move from V1 -> V2 APIs in preparation for v5.0. | ||
### `@blueprintjs/no-deprecated-core-components` | ||
Similar to `@blueprintjs/no-deprecated-components`, but only flags usage of deprecated components from the | ||
`@blueprintjs/core` package instead of all `@blueprintjs/` packages. | ||
__Rationale__: In migrations of large code bases, it may be useful to apply more granular rule configuration of | ||
"no-deprecated-components" to make incremental progress towards the newer APIs. This allows you, for example, to flag | ||
deprecated `@blueprintjs/core` component usage as errors while allowing deprecated components from other packages | ||
to pass as lint warnings. | ||
### `@blueprintjs/no-deprecated-datetime-components` | ||
Similar to `@blueprintjs/no-deprecated-components`, but only flags usage of deprecated components from the | ||
`@blueprintjs/core` package instead of all `@blueprintjs/` packages. | ||
__Rationale__: In migrations of large code bases, it may be useful to apply more granular rule configuration of | ||
"no-deprecated-components" to make incremental progress towards the newer APIs. This allows you, for example, to flag | ||
deprecated `@blueprintjs/datetime` component usage as errors while allowing deprecated components from other packages | ||
to pass as lint warnings. | ||
### `@blueprintjs/no-deprecated-select-components` | ||
Similar to `@blueprintjs/no-deprecated-components`, but only flags usage of deprecated components from the | ||
`@blueprintjs/core` package instead of all `@blueprintjs/` packages. | ||
__Rationale__: In migrations of large code bases, it may be useful to apply more granular rule configuration of | ||
"no-deprecated-components" to make incremental progress towards the newer APIs. This allows you, for example, to flag | ||
deprecated `@blueprintjs/select` component usage as errors while allowing deprecated components from other packages | ||
to pass as lint warnings. | ||
### `@blueprintjs/no-deprecated-table-components` | ||
Similar to `@blueprintjs/no-deprecated-components`, but only flags usage of deprecated components from the | ||
`@blueprintjs/table` package instead of all `@blueprintjs/` packages. | ||
__Rationale__: In migrations of large code bases, it may be useful to apply more granular rule configuration of | ||
"no-deprecated-components" to make incremental progress towards the newer APIs. This allows you, for example, to flag | ||
deprecated `@blueprintjs/table` component usage as errors while allowing deprecated components from other packages | ||
to pass as lint warnings. | ||
### `@blueprintjs/no-deprecated-timezone-components` | ||
Similar to `@blueprintjs/no-deprecated-components`, but only flags usage of deprecated components from the | ||
`@blueprintjs/core` package instead of all `@blueprintjs/` packages. | ||
__Rationale__: In migrations of large code bases, it may be useful to apply more granular rule configuration of | ||
"no-deprecated-components" to make incremental progress towards the newer APIs. This allows you, for example, to flag | ||
deprecated `@blueprintjs/timezone` component usage as errors while allowing deprecated components from other packages | ||
to pass as lint warnings. | ||
### [Full Documentation](http://blueprintjs.com/docs) | [Source Code](https://github.com/palantir/blueprint) |
@@ -19,3 +19,3 @@ /* | ||
/** | ||
* Enable Blueprint-specific lint rules defined in this package. | ||
* Enable all Blueprint-specific lint rules defined in this package. | ||
*/ | ||
@@ -29,2 +29,3 @@ module.exports = { | ||
"@blueprintjs/html-components": "error", | ||
"@blueprintjs/no-deprecated-components": "error", | ||
}, | ||
@@ -31,0 +32,0 @@ }, |
@@ -20,3 +20,10 @@ /* | ||
import { iconComponentsRule } from "./icon-components"; | ||
import { noDeprecatedComponentsRule } from "./no-deprecated-components"; | ||
import { | ||
noDeprecatedComponentsRule, | ||
noDeprecatedCoreComponentsRule, | ||
noDeprecatedDatetimeComponentsRule, | ||
noDeprecatedSelectComponentsRule, | ||
noDeprecatedTableComponentsRule, | ||
noDeprecatedTimezoneComponentsRule, | ||
} from "./no-deprecated-components"; | ||
@@ -29,2 +36,7 @@ // eslint-disable-next-line import/no-default-export | ||
"no-deprecated-components": noDeprecatedComponentsRule, | ||
"no-deprecated-core-components": noDeprecatedCoreComponentsRule, | ||
"no-deprecated-datetime-components": noDeprecatedDatetimeComponentsRule, | ||
"no-deprecated-select-components": noDeprecatedSelectComponentsRule, | ||
"no-deprecated-table-components": noDeprecatedTableComponentsRule, | ||
"no-deprecated-timezone-components": noDeprecatedTimezoneComponentsRule, | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133750
78
2379
222
Updatedeslint@^8.21.0