Skip to content

Commit 0ba9593

Browse files
committed
refactor: make plugin name constant
1 parent ddee0b3 commit 0ba9593

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

.eslintrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ module.exports = {
1818
rules: {
1919
'@typescript-eslint/indent': ['error', 2, {SwitchCase: 1}],
2020
'comma-dangle': ['error', 'always-multiline'],
21-
'max-len': ['error', {ignoreStrings: true, ignoreUrls: true}],
21+
'max-len': ['error', {
22+
ignoreStrings: true,
23+
ignoreTemplateLiterals: true,
24+
ignoreUrls: true,
25+
}],
2226
'no-trailing-spaces': 2,
2327
'object-shorthand': 2,
2428
'prefer-template': 2,

src/configs/recommended.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Linter } from 'eslint';
22

3-
import { WORKFLOW_DIR, WORKFLOW_FILE } from '../util/constants';
3+
import { PLUGIN_NAME, WORKFLOW_DIR, WORKFLOW_FILE } from '../util/constants';
44

55
const ignorePatterns = [
66
// ignore other YAML files
@@ -15,11 +15,11 @@ if (WORKFLOW_DIR.startsWith('.')) {
1515
}
1616

1717
const recommended: Linter.Config = {
18-
plugins: ['actions'],
18+
plugins: [PLUGIN_NAME],
1919
ignorePatterns,
2020
overrides: [{
2121
files: WORKFLOW_FILE.map(f => `${WORKFLOW_DIR}/${f}`),
22-
processor: 'actions/actions',
22+
processor: `${PLUGIN_NAME}/actions`,
2323
}, {
2424
files: WORKFLOW_FILE.map(f => `${WORKFLOW_DIR}/${f}/**/*.js`),
2525
env: { // Node.js 12

src/processors/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { YAMLError, YAMLWarning } from 'yaml/util';
44
import { CST } from 'yaml/parse-cst';
55
import { Linter } from 'eslint';
66

7-
import { SCRIPT_ACTIONS } from '../util/constants';
7+
import { PLUGIN_NAME, SCRIPT_ACTIONS } from '../util/constants';
88
import { Delta, Position, Block, ESLintBlock } from '../util/types';
99

1010
let blocks: Block[] = [];
@@ -114,7 +114,7 @@ function preprocess(text: string): ESLintBlock[] {
114114
if (script.type !== 'BLOCK_LITERAL') {
115115
warnings.push({
116116
name: 'YAMLWarning',
117-
message: 'Only a literal block is supported by eslint-plugin-actions',
117+
message: `Only a literal block is supported by eslint-plugin-${PLUGIN_NAME}`,
118118
linePos,
119119
makePretty: () => null,
120120
});
@@ -160,7 +160,7 @@ function postprocess(messages: Linter.LintMessage[][]): Linter.LintMessage[] {
160160
return errors.concat(warnings).map((
161161
{name, message, linePos}
162162
): Linter.LintMessage => ({
163-
ruleId: `actions/${name}`,
163+
ruleId: `${PLUGIN_NAME}/${name}`,
164164
severity: name === 'YAMLWarning' ? 1 : 2,
165165
message: message.split(' at line ')[0], // strip pretty context
166166
line: linePos && linePos.start.line || 1,

src/util/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Action } from './types';
22

3+
export const PLUGIN_NAME = 'actions';
4+
35
export const WORKFLOW_DIR = '.github/workflows';
46
export const WORKFLOW_FILE = ['*.yml', '*.yaml'];
57

0 commit comments

Comments
 (0)